Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit152103b

Browse files
authored
fix: add default value for RevokeURL property in external auth config for GitHub (#20272)
This PR adds setting default value of `RevokeURL` property of externalauth config for GitHub.
1 parent9158e46 commit152103b

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

‎coderd/externalauth/externalauth.go‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,9 @@ func applyDefaultsToConfig(config *codersdk.ExternalAuthConfig) {
781781

782782
// Dynamic defaults
783783
switchcodersdk.EnhancedExternalAuthProvider(config.Type) {
784+
casecodersdk.EnhancedExternalAuthProviderGitHub:
785+
copyDefaultSettings(config,gitHubDefaults(config))
786+
return
784787
casecodersdk.EnhancedExternalAuthProviderGitLab:
785788
copyDefaultSettings(config,gitlabDefaults(config))
786789
return
@@ -855,6 +858,29 @@ func copyDefaultSettings(config *codersdk.ExternalAuthConfig, defaults codersdk.
855858
}
856859
}
857860

861+
// gitHubDefaults returns default config values for GitHub.
862+
// The only dynamic value is the revocation URL which depends on client ID.
863+
funcgitHubDefaults(config*codersdk.ExternalAuthConfig) codersdk.ExternalAuthConfig {
864+
defaults:= codersdk.ExternalAuthConfig{
865+
AuthURL:xgithub.Endpoint.AuthURL,
866+
TokenURL:xgithub.Endpoint.TokenURL,
867+
ValidateURL:"https://api.github.com/user",
868+
DisplayName:"GitHub",
869+
DisplayIcon:"/icon/github.svg",
870+
Regex:`^(https?://)?github\.com(/.*)?$`,
871+
// "workflow" is required for managing GitHub Actions in a repository.
872+
Scopes: []string{"repo","workflow"},
873+
DeviceCodeURL:"https://github.com/login/device/code",
874+
AppInstallationsURL:"https://api.github.com/user/installations",
875+
}
876+
877+
ifconfig.RevokeURL==""&&config.ClientID!="" {
878+
defaults.RevokeURL=fmt.Sprintf("https://api.github.com/applications/%s/grant",config.ClientID)
879+
}
880+
881+
returndefaults
882+
}
883+
858884
funcbitbucketServerDefaults(config*codersdk.ExternalAuthConfig) codersdk.ExternalAuthConfig {
859885
defaults:= codersdk.ExternalAuthConfig{
860886
DisplayName:"Bitbucket Server",
@@ -1053,18 +1079,6 @@ var staticDefaults = map[codersdk.EnhancedExternalAuthProvider]codersdk.External
10531079
Regex:`^(https?://)?bitbucket\.org(/.*)?$`,
10541080
Scopes: []string{"account","repository:write"},
10551081
},
1056-
codersdk.EnhancedExternalAuthProviderGitHub: {
1057-
AuthURL:xgithub.Endpoint.AuthURL,
1058-
TokenURL:xgithub.Endpoint.TokenURL,
1059-
ValidateURL:"https://api.github.com/user",
1060-
DisplayName:"GitHub",
1061-
DisplayIcon:"/icon/github.svg",
1062-
Regex:`^(https?://)?github\.com(/.*)?$`,
1063-
// "workflow" is required for managing GitHub Actions in a repository.
1064-
Scopes: []string{"repo","workflow"},
1065-
DeviceCodeURL:"https://github.com/login/device/code",
1066-
AppInstallationsURL:"https://api.github.com/user/installations",
1067-
},
10681082
codersdk.EnhancedExternalAuthProviderSlack: {
10691083
AuthURL:"https://slack.com/oauth/v2/authorize",
10701084
TokenURL:"https://slack.com/api/oauth.v2.access",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp