mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
Add Token credential request handling (#3647)
- **PR Description** Asking for 2FA Token prompt when an additional authentication is configured for git over SSH - **Please check if the PR fulfills these requirements** * [x] Cheatsheets are up-to-date (run `go generate ./...`) * [x] Code has been formatted (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting)) * [x] Tests have been added/updated (see [here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md) for the integration test guide) * [x] Text is internationalised (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation)) * [x] Docs have been updated if necessary * [x] You've read through your own file changes for silly mistakes etc <!-- Be sure to name your PR with an imperative e.g. 'Add worktrees view' see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for examples -->
This commit is contained in:
commit
3d14893c65
@ -284,6 +284,7 @@ const (
|
|||||||
Username
|
Username
|
||||||
Passphrase
|
Passphrase
|
||||||
PIN
|
PIN
|
||||||
|
Token
|
||||||
)
|
)
|
||||||
|
|
||||||
// Whenever we're asked for a password we just enter a newline, which will
|
// Whenever we're asked for a password we just enter a newline, which will
|
||||||
@ -376,6 +377,7 @@ func (self *cmdObjRunner) getCheckForCredentialRequestFunc() func([]byte) (Crede
|
|||||||
`Username\s*for\s*'.+':`: Username,
|
`Username\s*for\s*'.+':`: Username,
|
||||||
`Enter\s*passphrase\s*for\s*key\s*'.+':`: Passphrase,
|
`Enter\s*passphrase\s*for\s*key\s*'.+':`: Passphrase,
|
||||||
`Enter\s*PIN\s*for\s*.+\s*key\s*.+:`: PIN,
|
`Enter\s*PIN\s*for\s*.+\s*key\s*.+:`: PIN,
|
||||||
|
`.*2FA Token.*`: Token,
|
||||||
}
|
}
|
||||||
|
|
||||||
compiledPrompts := map[*regexp.Regexp]CredentialType{}
|
compiledPrompts := map[*regexp.Regexp]CredentialType{}
|
||||||
|
@ -39,6 +39,8 @@ func TestProcessOutput(t *testing.T) {
|
|||||||
return "passphrase"
|
return "passphrase"
|
||||||
case PIN:
|
case PIN:
|
||||||
return "pin"
|
return "pin"
|
||||||
|
case Token:
|
||||||
|
return "token"
|
||||||
default:
|
default:
|
||||||
panic("unexpected credential type")
|
panic("unexpected credential type")
|
||||||
}
|
}
|
||||||
@ -92,6 +94,12 @@ func TestProcessOutput(t *testing.T) {
|
|||||||
output: "Enter PIN for key '123':",
|
output: "Enter PIN for key '123':",
|
||||||
expectedToWrite: "pin",
|
expectedToWrite: "pin",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "2FA token prompt",
|
||||||
|
promptUserForCredential: defaultPromptUserForCredential,
|
||||||
|
output: "testuser 2FA Token (citadel)",
|
||||||
|
expectedToWrite: "token",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "username and password prompt",
|
name: "username and password prompt",
|
||||||
promptUserForCredential: defaultPromptUserForCredential,
|
promptUserForCredential: defaultPromptUserForCredential,
|
||||||
|
@ -56,6 +56,8 @@ func (self *CredentialsHelper) getTitleAndMask(passOrUname oscommands.Credential
|
|||||||
return self.c.Tr.CredentialsPassphrase, true
|
return self.c.Tr.CredentialsPassphrase, true
|
||||||
case oscommands.PIN:
|
case oscommands.PIN:
|
||||||
return self.c.Tr.CredentialsPIN, true
|
return self.c.Tr.CredentialsPIN, true
|
||||||
|
case oscommands.Token:
|
||||||
|
return self.c.Tr.CredentialsToken, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// should never land here
|
// should never land here
|
||||||
|
@ -36,6 +36,7 @@ type TranslationSet struct {
|
|||||||
CredentialsPassword string
|
CredentialsPassword string
|
||||||
CredentialsPassphrase string
|
CredentialsPassphrase string
|
||||||
CredentialsPIN string
|
CredentialsPIN string
|
||||||
|
CredentialsToken string
|
||||||
PassUnameWrong string
|
PassUnameWrong string
|
||||||
Commit string
|
Commit string
|
||||||
CommitTooltip string
|
CommitTooltip string
|
||||||
@ -1004,6 +1005,7 @@ func EnglishTranslationSet() *TranslationSet {
|
|||||||
CredentialsPassword: "Password",
|
CredentialsPassword: "Password",
|
||||||
CredentialsPassphrase: "Enter passphrase for SSH key",
|
CredentialsPassphrase: "Enter passphrase for SSH key",
|
||||||
CredentialsPIN: "Enter PIN for SSH key",
|
CredentialsPIN: "Enter PIN for SSH key",
|
||||||
|
CredentialsToken: "Enter Token for SSH key",
|
||||||
PassUnameWrong: "Password, passphrase and/or username wrong",
|
PassUnameWrong: "Password, passphrase and/or username wrong",
|
||||||
Commit: "Commit",
|
Commit: "Commit",
|
||||||
CommitTooltip: "Commit staged changes.",
|
CommitTooltip: "Commit staged changes.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user