@@ -102,7 +102,8 @@ type Config struct {
102102 // injected into Coder AI Bridge upstream requests.
103103 // In the case of conflicts, items evaluated by this list override [MCPToolAllowRegex].
104104 // This field can be nil if unspecified in the config.
105- MCPToolDenyRegex * regexp.Regexp
105+ MCPToolDenyRegex * regexp.Regexp
106+ CodeChallengeMethodsSupported []promoauth.Oauth2PKCEChallengeMethod
106107}
107108
108109// GenerateTokenExtra generates the extra token data to store in the database.
@@ -800,9 +801,11 @@ func applyDefaultsToConfig(config *codersdk.ExternalAuthConfig) {
800801 copyDefaultSettings (config , azureDevopsEntraDefaults (config ))
801802 return
802803 default :
803- // No defaults for this type. We still want to run this apply with
804- // an empty set of defaults.
805- copyDefaultSettings (config , codersdk.ExternalAuthConfig {})
804+ // Defaults apply to any provider that doesn't have specific defaults.
805+ copyDefaultSettings (config , codersdk.ExternalAuthConfig {
806+ // PKCE should always be enabled by default.
807+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodSha256 )},
808+ })
806809 return
807810 }
808811}
@@ -856,6 +859,9 @@ func copyDefaultSettings(config *codersdk.ExternalAuthConfig, defaults codersdk.
856859 // This is a key emoji.
857860 config .DisplayIcon = "/emojis/1f511.png"
858861 }
862+ if config .CodeChallengeMethodsSupported == nil {
863+ config .CodeChallengeMethodsSupported = defaults .CodeChallengeMethodsSupported
864+ }
859865}
860866
861867// gitHubDefaults returns default config values for GitHub.
@@ -869,9 +875,10 @@ func gitHubDefaults(config *codersdk.ExternalAuthConfig) codersdk.ExternalAuthCo
869875 DisplayIcon : "/icon/github.svg" ,
870876 Regex : `^(https?://)?github\.com(/.*)?$` ,
871877 // "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" ,
878+ Scopes : []string {"repo" , "workflow" },
879+ DeviceCodeURL : "https://github.com/login/device/code" ,
880+ AppInstallationsURL : "https://api.github.com/user/installations" ,
881+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodSha256 )},
875882 }
876883
877884 if config .RevokeURL == "" && config .ClientID != "" {
@@ -886,6 +893,8 @@ func bitbucketServerDefaults(config *codersdk.ExternalAuthConfig) codersdk.Exter
886893 DisplayName : "Bitbucket Server" ,
887894 Scopes : []string {"PUBLIC_REPOS" , "REPO_READ" , "REPO_WRITE" },
888895 DisplayIcon : "/icon/bitbucket.svg" ,
896+ // TODO: PKCE support? Test 'S256' as the string value
897+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodNone )},
889898 }
890899 // Bitbucket servers will have some base url, e.g. https://bitbucket.coder.com.
891900 // We will grab this from the Auth URL. This choice is a bit arbitrary,
@@ -923,14 +932,15 @@ func bitbucketServerDefaults(config *codersdk.ExternalAuthConfig) codersdk.Exter
923932// Any user specific fields will override this if provided.
924933func gitlabDefaults (config * codersdk.ExternalAuthConfig ) codersdk.ExternalAuthConfig {
925934 cloud := codersdk.ExternalAuthConfig {
926- AuthURL : "https://gitlab.com/oauth/authorize" ,
927- TokenURL : "https://gitlab.com/oauth/token" ,
928- ValidateURL : "https://gitlab.com/oauth/token/info" ,
929- RevokeURL : "https://gitlab.com/oauth/revoke" ,
930- DisplayName : "GitLab" ,
931- DisplayIcon : "/icon/gitlab.svg" ,
932- Regex : `^(https?://)?gitlab\.com(/.*)?$` ,
933- Scopes : []string {"write_repository" },
935+ AuthURL : "https://gitlab.com/oauth/authorize" ,
936+ TokenURL : "https://gitlab.com/oauth/token" ,
937+ ValidateURL : "https://gitlab.com/oauth/token/info" ,
938+ RevokeURL : "https://gitlab.com/oauth/revoke" ,
939+ DisplayName : "GitLab" ,
940+ DisplayIcon : "/icon/gitlab.svg" ,
941+ Regex : `^(https?://)?gitlab\.com(/.*)?$` ,
942+ Scopes : []string {"write_repository" },
943+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodSha256 )},
934944 }
935945
936946 if config .AuthURL == "" || config .AuthURL == cloud .AuthURL {
@@ -946,14 +956,15 @@ func gitlabDefaults(config *codersdk.ExternalAuthConfig) codersdk.ExternalAuthCo
946956
947957 // At this point, assume it is self-hosted and use the AuthURL
948958 return codersdk.ExternalAuthConfig {
949- DisplayName : cloud .DisplayName ,
950- Scopes : cloud .Scopes ,
951- DisplayIcon : cloud .DisplayIcon ,
952- AuthURL : au .ResolveReference (& url.URL {Path : "/oauth/authorize" }).String (),
953- TokenURL : au .ResolveReference (& url.URL {Path : "/oauth/token" }).String (),
954- ValidateURL : au .ResolveReference (& url.URL {Path : "/oauth/token/info" }).String (),
955- RevokeURL : au .ResolveReference (& url.URL {Path : "/oauth/revoke" }).String (),
956- Regex : fmt .Sprintf (`^(https?://)?%s(/.*)?$` , strings .ReplaceAll (au .Host , "." , `\.` )),
959+ DisplayName : cloud .DisplayName ,
960+ Scopes : cloud .Scopes ,
961+ DisplayIcon : cloud .DisplayIcon ,
962+ AuthURL : au .ResolveReference (& url.URL {Path : "/oauth/authorize" }).String (),
963+ TokenURL : au .ResolveReference (& url.URL {Path : "/oauth/token" }).String (),
964+ ValidateURL : au .ResolveReference (& url.URL {Path : "/oauth/token/info" }).String (),
965+ RevokeURL : au .ResolveReference (& url.URL {Path : "/oauth/revoke" }).String (),
966+ Regex : fmt .Sprintf (`^(https?://)?%s(/.*)?$` , strings .ReplaceAll (au .Host , "." , `\.` )),
967+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodSha256 )},
957968 }
958969}
959970
@@ -962,6 +973,8 @@ func jfrogArtifactoryDefaults(config *codersdk.ExternalAuthConfig) codersdk.Exte
962973 DisplayName : "JFrog Artifactory" ,
963974 Scopes : []string {"applied-permissions/user" },
964975 DisplayIcon : "/icon/jfrog.svg" ,
976+ // TODO: PKCE support? Test 'S256' as the string value
977+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodNone )},
965978 }
966979 // Artifactory servers will have some base url, e.g. https://jfrog.coder.com.
967980 // We will grab this from the Auth URL. This choice is not arbitrary. It is a
@@ -997,9 +1010,10 @@ func jfrogArtifactoryDefaults(config *codersdk.ExternalAuthConfig) codersdk.Exte
9971010
9981011func giteaDefaults (config * codersdk.ExternalAuthConfig ) codersdk.ExternalAuthConfig {
9991012 defaults := codersdk.ExternalAuthConfig {
1000- DisplayName : "Gitea" ,
1001- Scopes : []string {"read:repository" , " write:repository" , "read:user" },
1002- DisplayIcon : "/icon/gitea.svg" ,
1013+ DisplayName : "Gitea" ,
1014+ Scopes : []string {"read:repository" , " write:repository" , "read:user" },
1015+ DisplayIcon : "/icon/gitea.svg" ,
1016+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodSha256 )},
10031017 }
10041018 // Gitea's servers will have some base url, e.g: https://gitea.coder.com.
10051019 // If an auth url is not set, we will assume they are using the default
@@ -1031,6 +1045,8 @@ func azureDevopsEntraDefaults(config *codersdk.ExternalAuthConfig) codersdk.Exte
10311045 DisplayName : "Azure DevOps (Entra)" ,
10321046 DisplayIcon : "/icon/azure-devops.svg" ,
10331047 Regex : `^(https?://)?dev\.azure\.com(/.*)?$` ,
1048+ // TODO: PKCE support? Test 'S256' as the string value
1049+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodNone )},
10341050 }
10351051 // The tenant ID is required for urls and is in the auth url.
10361052 if config .AuthURL == "" {
@@ -1069,6 +1085,8 @@ var staticDefaults = map[codersdk.EnhancedExternalAuthProvider]codersdk.External
10691085 DisplayIcon : "/icon/azure-devops.svg" ,
10701086 Regex : `^(https?://)?dev\.azure\.com(/.*)?$` ,
10711087 Scopes : []string {"vso.code_write" },
1088+ // TODO: PKCE support? Test 'S256' as the string value
1089+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodNone )},
10721090 },
10731091 codersdk .EnhancedExternalAuthProviderBitBucketCloud : {
10741092 AuthURL : "https://bitbucket.org/site/oauth2/authorize" ,
@@ -1078,6 +1096,8 @@ var staticDefaults = map[codersdk.EnhancedExternalAuthProvider]codersdk.External
10781096 DisplayIcon : "/icon/bitbucket.svg" ,
10791097 Regex : `^(https?://)?bitbucket\.org(/.*)?$` ,
10801098 Scopes : []string {"account" , "repository:write" },
1099+ // TODO: PKCE support? Test 'S256' as the string value
1100+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodNone )},
10811101 },
10821102 codersdk .EnhancedExternalAuthProviderSlack : {
10831103 AuthURL : "https://slack.com/oauth/v2/authorize" ,
@@ -1087,6 +1107,8 @@ var staticDefaults = map[codersdk.EnhancedExternalAuthProvider]codersdk.External
10871107 DisplayIcon : "/icon/slack.svg" ,
10881108 // See: https://api.slack.com/authentication/oauth-v2#exchanging
10891109 ExtraTokenKeys : []string {"authed_user" },
1110+ // TODO: PKCE support? Test 'S256' as the string value
1111+ CodeChallengeMethodsSupported : []string {string (promoauth .PKCEChallengeMethodNone )},
10901112 },
10911113}
10921114
0 commit comments