mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-18 04:47:28 +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
|
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(),
|
tokenBlacklist: NewTokenBlacklist(),
|
||||||
jwkCache: &JWKCache{},
|
jwkCache: &JWKCache{},
|
||||||
|
|
||||||
clientID: config.ClientID,
|
clientID: config.ClientID,
|
||||||
clientSecret: config.ClientSecret,
|
clientSecret: config.ClientSecret,
|
||||||
forceHTTPS: config.ForceHTTPS,
|
forceHTTPS: config.ForceHTTPS,
|
||||||
scopes: config.Scopes,
|
scopes: config.Scopes,
|
||||||
limiter: rate.NewLimiter(rate.Every(time.Second), config.RateLimit),
|
limiter: rate.NewLimiter(rate.Every(time.Second), config.RateLimit),
|
||||||
tokenCache: NewTokenCache(),
|
tokenCache: NewTokenCache(),
|
||||||
httpClient: httpClient,
|
httpClient: httpClient,
|
||||||
logger: NewLogger(config.LogLevel),
|
logger: NewLogger(config.LogLevel),
|
||||||
excludedURLs: func() map[string]struct{} {
|
excludedURLs: createStringMap(config.ExcludedURLs),
|
||||||
m := make(map[string]struct{})
|
redirectURL: "",
|
||||||
for _, url := range config.ExcludedURLs {
|
allowedUserDomains: createStringMap(config.AllowedUserDomains),
|
||||||
m[url] = struct{}{}
|
allowedRolesAndGroups: createStringMap(config.AllowedRolesAndGroups),
|
||||||
}
|
initComplete: make(chan 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{}),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t.initiateAuthenticationFunc = t.defaultInitiateAuthentication
|
t.initiateAuthenticationFunc = t.defaultInitiateAuthentication
|
||||||
|
|||||||
Reference in New Issue
Block a user