Refactor caches

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2023-04-19 17:32:25 +02:00
parent bc15b8a396
commit a900d0ed8d
4 changed files with 47 additions and 27 deletions
+2 -2
View File
@@ -30,8 +30,8 @@ func NewOIDCAuthenticator(opts ...Option) *OIDCAuthenticator {
return &OIDCAuthenticator{
Logger: options.Logger,
userInfoCache: options.Cache,
sessionLookupCache: options.Cache,
userInfoCache: options.UserInfoCache,
sessionLookupCache: options.SessionLookupCache,
DefaultTokenCacheTTL: options.DefaultAccessTokenTTL,
HTTPClient: options.HTTPClient,
OIDCIss: options.OIDCIss,
+14 -5
View File
@@ -54,8 +54,10 @@ type Options struct {
EnableBasicAuth bool
// DefaultAccessTokenTTL is used to calculate the expiration when an access token has no expiration set
DefaultAccessTokenTTL time.Duration
// Cache sets the access token cache store
Cache store.Store
// UserInfoCache sets the access token cache store
UserInfoCache store.Store
// SessionLookupCache maps the session to a hashed jwt token
SessionLookupCache store.Store
// CredentialsByUserAgent sets the auth challenges on a per user-agent basis
CredentialsByUserAgent map[string]string
// AccessTokenVerifyMethod configures how access_tokens should be verified but the oidc_auth middleware.
@@ -191,10 +193,17 @@ func DefaultAccessTokenTTL(ttl time.Duration) Option {
}
}
// Cache provides a function to set the Cache
func Cache(val store.Store) Option {
// UserInfoCache provides a function to set the UserInfoCache
func UserInfoCache(val store.Store) Option {
return func(o *Options) {
o.Cache = val
o.UserInfoCache = val
}
}
// SessionLookupCache provides a function to set the SessionLookupCache
func SessionLookupCache(val store.Store) Option {
return func(o *Options) {
o.SessionLookupCache = val
}
}