@@ -41,19 +41,42 @@ func GetSettings(conf *DexConfig) (*oidc.Settings, error) {
4141 if err != nil {
4242 return nil , err
4343 }
44+
4445 settings := & oidc.Settings {
4546 URL : conf .Url ,
4647 OIDCConfig : oidc.OIDCConfig {CLIClientID : conf .DexClientID ,
4748 ClientSecret : conf .DexClientSecret ,
4849 Issuer : proxyUrl ,
4950 ServerSecret : conf .ServerSecret ,
50- RequestedScopes : conf .DexScopes ,
51+ RequestedScopes : conf .GetDexScopes () ,
5152 },
5253 UserSessionDuration : time .Duration (conf .UserSessionDurationSeconds ) * time .Second ,
5354 AdminPasswordMtime : conf .AdminPasswordMtime ,
5455 }
5556 return settings , nil
5657}
58+ func (conf * DexConfig ) GetDexScopes () []string {
59+ // passing empty array to get default scopes
60+ defaultScopes := oidc .GetScopesOrDefault ([]string {})
61+ additionalScopes := conf .DexScopes
62+
63+ occurrenceMap := make (map [string ]bool )
64+ finalScopes := make ([]string , 0 , len (defaultScopes )+ len (additionalScopes ))
65+
66+ // first add all the default
67+ for _ , scope := range defaultScopes {
68+ occurrenceMap [scope ] = true
69+ finalScopes = append (finalScopes , scope )
70+ }
71+ // append extra configs
72+ for _ , scope := range additionalScopes {
73+ if _ , exists := occurrenceMap [scope ]; ! exists {
74+ occurrenceMap [scope ] = true
75+ finalScopes = append (finalScopes , scope )
76+ }
77+ }
78+ return finalScopes
79+ }
5780func getOidcClient (dexServerAddress string , settings * oidc.Settings , userVerifier oidc.UserVerifier , RedirectUrlSanitiser oidc.RedirectUrlSanitiser ) (* oidc.ClientApp , func (writer http.ResponseWriter , request * http.Request ), error ) {
5881 dexClient := & http.Client {
5982 Transport : & http.Transport {
0 commit comments