Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Token credential request handling #3647

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/commands/oscommands/cmd_obj_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ const (
Username
Passphrase
PIN
Token
)

// Whenever we're asked for a password we just enter a newline, which will
Expand Down Expand Up @@ -376,6 +377,7 @@ func (self *cmdObjRunner) getCheckForCredentialRequestFunc() func([]byte) (Crede
`Username\s*for\s*'.+':`: Username,
`Enter\s*passphrase\s*for\s*key\s*'.+':`: Passphrase,
`Enter\s*PIN\s*for\s*.+\s*key\s*.+:`: PIN,
`.*2FA Token.*`: Token,
}

compiledPrompts := map[*regexp.Regexp]CredentialType{}
Expand Down
8 changes: 8 additions & 0 deletions pkg/commands/oscommands/cmd_obj_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func TestProcessOutput(t *testing.T) {
return "passphrase"
case PIN:
return "pin"
case Token:
return "token"
default:
panic("unexpected credential type")
}
Expand Down Expand Up @@ -92,6 +94,12 @@ func TestProcessOutput(t *testing.T) {
output: "Enter PIN for key '123':",
expectedToWrite: "pin",
},
{
name: "2FA token prompt",
promptUserForCredential: defaultPromptUserForCredential,
output: "testuser 2FA Token (citadel)",
expectedToWrite: "token",
},
{
name: "username and password prompt",
promptUserForCredential: defaultPromptUserForCredential,
Expand Down
2 changes: 2 additions & 0 deletions pkg/gui/controllers/helpers/credentials_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func (self *CredentialsHelper) getTitleAndMask(passOrUname oscommands.Credential
return self.c.Tr.CredentialsPassphrase, true
case oscommands.PIN:
return self.c.Tr.CredentialsPIN, true
case oscommands.Token:
return self.c.Tr.CredentialsToken, true
}

// should never land here
Expand Down
2 changes: 2 additions & 0 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type TranslationSet struct {
CredentialsPassword string
CredentialsPassphrase string
CredentialsPIN string
CredentialsToken string
PassUnameWrong string
Commit string
CommitTooltip string
Expand Down Expand Up @@ -1004,6 +1005,7 @@ func EnglishTranslationSet() *TranslationSet {
CredentialsPassword: "Password",
CredentialsPassphrase: "Enter passphrase for SSH key",
CredentialsPIN: "Enter PIN for SSH key",
CredentialsToken: "Enter Token for SSH key",
PassUnameWrong: "Password, passphrase and/or username wrong",
Commit: "Commit",
CommitTooltip: "Commit staged changes.",
Expand Down
Loading