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

Function copyDefaultSettings

coderd/externalauth/externalauth.go:984–1057  ·  view source on GitHub ↗
(config *codersdk.ExternalAuthConfig, defaults codersdk.ExternalAuthConfig)

Source from the content-addressed store, hash-verified

982}
983
984func copyDefaultSettings(config *codersdk.ExternalAuthConfig, defaults codersdk.ExternalAuthConfig) {
985 if config.AuthURL == "" {
986 config.AuthURL = defaults.AuthURL
987 }
988 if config.TokenURL == "" {
989 config.TokenURL = defaults.TokenURL
990 }
991 if config.ValidateURL == "" {
992 config.ValidateURL = defaults.ValidateURL
993 }
994 if config.RevokeURL == "" {
995 config.RevokeURL = defaults.RevokeURL
996 }
997 if config.AppInstallURL == "" {
998 config.AppInstallURL = defaults.AppInstallURL
999 }
1000 if config.AppInstallationsURL == "" {
1001 config.AppInstallationsURL = defaults.AppInstallationsURL
1002 }
1003 if config.Regex == "" {
1004 config.Regex = defaults.Regex
1005 }
1006 if len(config.Scopes) == 0 {
1007 config.Scopes = defaults.Scopes
1008 }
1009 if config.DeviceCodeURL == "" {
1010 config.DeviceCodeURL = defaults.DeviceCodeURL
1011 }
1012 if config.DisplayName == "" {
1013 config.DisplayName = defaults.DisplayName
1014 }
1015 if config.DisplayIcon == "" {
1016 config.DisplayIcon = defaults.DisplayIcon
1017 }
1018 if len(config.ExtraTokenKeys) == 0 {
1019 config.ExtraTokenKeys = defaults.ExtraTokenKeys
1020 }
1021 if config.CodeChallengeMethodsSupported == nil {
1022 config.CodeChallengeMethodsSupported = defaults.CodeChallengeMethodsSupported
1023 }
1024
1025 // Apply defaults if it's still empty...
1026 if config.ID == "" {
1027 config.ID = config.Type
1028 }
1029 if config.DisplayName == "" {
1030 config.DisplayName = config.Type
1031 }
1032 if config.DisplayIcon == "" {
1033 // This is a key emoji.
1034 config.DisplayIcon = "/emojis/1f511.png"
1035 }
1036 if config.CodeChallengeMethodsSupported == nil {
1037 config.CodeChallengeMethodsSupported = []string{string(promoauth.PKCEChallengeMethodSha256)}
1038 }
1039
1040 // Set default API base URL for providers that need one.
1041 if config.APIBaseURL == "" {

Callers 1

applyDefaultsToConfigFunction · 0.85

Calls 2

ParseMethod · 0.65

Tested by

no test coverage detected