MCPcopy Index your code
hub / github.com/coder/coder / giteaDefaults

Function giteaDefaults

coderd/externalauth/externalauth.go:1203–1233  ·  view source on GitHub ↗
(config *codersdk.ExternalAuthConfig)

Source from the content-addressed store, hash-verified

1201}
1202
1203func giteaDefaults(config *codersdk.ExternalAuthConfig) codersdk.ExternalAuthConfig {
1204 defaults := codersdk.ExternalAuthConfig{
1205 DisplayName: "Gitea",
1206 Scopes: []string{"read:repository", " write:repository", "read:user"},
1207 DisplayIcon: "/icon/gitea.svg",
1208 CodeChallengeMethodsSupported: []string{string(promoauth.PKCEChallengeMethodSha256)},
1209 }
1210 // Gitea's servers will have some base url, e.g: https://gitea.coder.com.
1211 // If an auth url is not set, we will assume they are using the default
1212 // public Gitea.
1213 if config.AuthURL == "" {
1214 config.AuthURL = "https://gitea.com/login/oauth/authorize"
1215 }
1216
1217 auth, err := url.Parse(config.AuthURL)
1218 if err != nil {
1219 // We need a valid URL to continue with.
1220 return defaults
1221 }
1222
1223 // Default regex should be anything using the same host as the auth url.
1224 defaults.Regex = fmt.Sprintf(`^(https?://)?%s(/.*)?$`, strings.ReplaceAll(auth.Host, ".", `\.`))
1225
1226 tokenURL := auth.ResolveReference(&url.URL{Path: "/login/oauth/access_token"})
1227 defaults.TokenURL = tokenURL.String()
1228
1229 validate := auth.ResolveReference(&url.URL{Path: "/login/oauth/userinfo"})
1230 defaults.ValidateURL = validate.String()
1231
1232 return defaults
1233}
1234
1235func azureDevopsEntraDefaults(config *codersdk.ExternalAuthConfig) codersdk.ExternalAuthConfig {
1236 defaults := codersdk.ExternalAuthConfig{

Callers 1

applyDefaultsToConfigFunction · 0.85

Calls 2

ParseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected