mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Validate Git tokens before consuming them (#5167)
* feat: Validate Git tokens before consuming them This works the exact same way that the Git credential manager does. It ensures the user token is valid before returning it to the client. It's been manually tested on GitHub, GitLab, and BitBucket. * Fix requested changes
This commit is contained in:
@@ -179,6 +179,7 @@ func TestConfig(t *testing.T) {
|
||||
"CODER_GITAUTH_0_CLIENT_SECRET": "secret",
|
||||
"CODER_GITAUTH_0_AUTH_URL": "https://auth.com",
|
||||
"CODER_GITAUTH_0_TOKEN_URL": "https://token.com",
|
||||
"CODER_GITAUTH_0_VALIDATE_URL": "https://validate.com",
|
||||
"CODER_GITAUTH_0_REGEX": "github.com",
|
||||
"CODER_GITAUTH_0_SCOPES": "read write",
|
||||
"CODER_GITAUTH_0_NO_REFRESH": "true",
|
||||
@@ -200,6 +201,7 @@ func TestConfig(t *testing.T) {
|
||||
ClientSecret: "secret",
|
||||
AuthURL: "https://auth.com",
|
||||
TokenURL: "https://token.com",
|
||||
ValidateURL: "https://validate.com",
|
||||
Regex: "github.com",
|
||||
Scopes: []string{"read", "write"},
|
||||
NoRefresh: true,
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ func gitAskpass() *cobra.Command {
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
cmd.Printf("\nYou've been authenticated with Git!\n")
|
||||
cmd.Printf("You've been authenticated with Git!\n")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user