mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-06-05 22:44:17 +00:00
Abstract filling up maps.
This commit is contained in:
@@ -350,3 +350,11 @@ func (t *TraefikOidc) exchangeCodeForToken(code string) (map[string]interface{},
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func createStringMap(keys []string) map[string]struct{} {
|
||||
result := make(map[string]struct{})
|
||||
for _, key := range keys {
|
||||
result[key] = struct{}{}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -220,37 +220,19 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h
|
||||
tokenBlacklist: NewTokenBlacklist(),
|
||||
jwkCache: &JWKCache{},
|
||||
|
||||
clientID: config.ClientID,
|
||||
clientSecret: config.ClientSecret,
|
||||
forceHTTPS: config.ForceHTTPS,
|
||||
scopes: config.Scopes,
|
||||
limiter: rate.NewLimiter(rate.Every(time.Second), config.RateLimit),
|
||||
tokenCache: NewTokenCache(),
|
||||
httpClient: httpClient,
|
||||
logger: NewLogger(config.LogLevel),
|
||||
excludedURLs: func() map[string]struct{} {
|
||||
m := make(map[string]struct{})
|
||||
for _, url := range config.ExcludedURLs {
|
||||
m[url] = struct{}{}
|
||||
}
|
||||
return m
|
||||
}(),
|
||||
redirectURL: "",
|
||||
allowedUserDomains: func() map[string]struct{} {
|
||||
m := make(map[string]struct{})
|
||||
for _, domain := range config.AllowedUserDomains {
|
||||
m[domain] = struct{}{}
|
||||
}
|
||||
return m
|
||||
}(),
|
||||
allowedRolesAndGroups: func() map[string]struct{} {
|
||||
m := make(map[string]struct{})
|
||||
for _, roleOrGroup := range config.AllowedRolesAndGroups {
|
||||
m[roleOrGroup] = struct{}{}
|
||||
}
|
||||
return m
|
||||
}(),
|
||||
initComplete: make(chan struct{}),
|
||||
clientID: config.ClientID,
|
||||
clientSecret: config.ClientSecret,
|
||||
forceHTTPS: config.ForceHTTPS,
|
||||
scopes: config.Scopes,
|
||||
limiter: rate.NewLimiter(rate.Every(time.Second), config.RateLimit),
|
||||
tokenCache: NewTokenCache(),
|
||||
httpClient: httpClient,
|
||||
logger: NewLogger(config.LogLevel),
|
||||
excludedURLs: createStringMap(config.ExcludedURLs),
|
||||
redirectURL: "",
|
||||
allowedUserDomains: createStringMap(config.AllowedUserDomains),
|
||||
allowedRolesAndGroups: createStringMap(config.AllowedRolesAndGroups),
|
||||
initComplete: make(chan struct{}),
|
||||
}
|
||||
|
||||
t.initiateAuthenticationFunc = t.defaultInitiateAuthentication
|
||||
|
||||
Reference in New Issue
Block a user