@@ -781,6 +781,9 @@ func applyDefaultsToConfig(config *codersdk.ExternalAuthConfig) {
781781
782782// Dynamic defaults
783783switch codersdk .EnhancedExternalAuthProvider (config .Type ) {
784+ case codersdk .EnhancedExternalAuthProviderGitHub :
785+ copyDefaultSettings (config ,gitHubDefaults (config ))
786+ return
784787case codersdk .EnhancedExternalAuthProviderGitLab :
785788copyDefaultSettings (config ,gitlabDefaults (config ))
786789return
@@ -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+ func gitHubDefaults (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+ if config .RevokeURL == "" && config .ClientID != "" {
878+ defaults .RevokeURL = fmt .Sprintf ("https://api.github.com/applications/%s/grant" ,config .ClientID )
879+ }
880+
881+ return defaults
882+ }
883+
858884func bitbucketServerDefaults (config * codersdk.ExternalAuthConfig ) codersdk.ExternalAuthConfig {
859885defaults := codersdk.ExternalAuthConfig {
860886DisplayName :"Bitbucket Server" ,
@@ -1053,18 +1079,6 @@ var staticDefaults = map[codersdk.EnhancedExternalAuthProvider]codersdk.External
10531079Regex :`^(https?://)?bitbucket\.org(/.*)?$` ,
10541080Scopes : []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- },
10681082codersdk .EnhancedExternalAuthProviderSlack : {
10691083AuthURL :"https://slack.com/oauth/v2/authorize" ,
10701084TokenURL :"https://slack.com/api/oauth.v2.access" ,