mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-06-05 22:44:17 +00:00
@@ -7,13 +7,14 @@ import (
|
||||
|
||||
// UniversalCacheManager manages all cache instances using the universal cache
|
||||
type UniversalCacheManager struct {
|
||||
tokenCache *UniversalCache
|
||||
blacklistCache *UniversalCache
|
||||
metadataCache *UniversalCache
|
||||
jwkCache *UniversalCache
|
||||
sessionCache *UniversalCache
|
||||
mu sync.RWMutex
|
||||
logger *Logger
|
||||
tokenCache *UniversalCache
|
||||
blacklistCache *UniversalCache
|
||||
metadataCache *UniversalCache
|
||||
jwkCache *UniversalCache
|
||||
sessionCache *UniversalCache
|
||||
introspectionCache *UniversalCache // OAuth 2.0 Token Introspection cache (RFC 7662)
|
||||
mu sync.RWMutex
|
||||
logger *Logger
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -85,6 +86,14 @@ func GetUniversalCacheManager(logger *Logger) *UniversalCacheManager {
|
||||
DefaultTTL: 30 * time.Minute,
|
||||
Logger: logger,
|
||||
})
|
||||
|
||||
// Initialize introspection cache for OAuth 2.0 Token Introspection (RFC 7662)
|
||||
universalCacheManager.introspectionCache = NewUniversalCache(UniversalCacheConfig{
|
||||
Type: CacheTypeToken, // Use token cache type for introspection results
|
||||
MaxSize: 1000, // Cache up to 1000 introspection results
|
||||
DefaultTTL: 5 * time.Minute, // Short TTL for security (introspect frequently)
|
||||
Logger: logger,
|
||||
})
|
||||
})
|
||||
|
||||
return universalCacheManager
|
||||
@@ -125,13 +134,20 @@ func (m *UniversalCacheManager) GetSessionCache() *UniversalCache {
|
||||
return m.sessionCache
|
||||
}
|
||||
|
||||
// GetIntrospectionCache returns the token introspection cache
|
||||
func (m *UniversalCacheManager) GetIntrospectionCache() *UniversalCache {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
return m.introspectionCache
|
||||
}
|
||||
|
||||
// Close shuts down all caches
|
||||
func (m *UniversalCacheManager) Close() error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
for _, cache := range []*UniversalCache{
|
||||
m.tokenCache, m.blacklistCache, m.metadataCache, m.jwkCache, m.sessionCache,
|
||||
m.tokenCache, m.blacklistCache, m.metadataCache, m.jwkCache, m.sessionCache, m.introspectionCache,
|
||||
} {
|
||||
if cache != nil {
|
||||
cache.Close()
|
||||
|
||||
Reference in New Issue
Block a user