Documentation
¶
Index ¶
- Constants
- func BuildKey(principalSubject, principalType, organization, resType, resID, action string) string
- type Cache
- type CachedDecision
- type CoreCacheAdapter
- func (a *CoreCacheAdapter) GetDecision(ctx context.Context, key string) (*CachedDecision, bool, error)
- func (a *CoreCacheAdapter) InvalidateAll(ctx context.Context) error
- func (a *CoreCacheAdapter) InvalidatePrincipal(ctx context.Context, principalSubject string) error
- func (a *CoreCacheAdapter) InvalidateResource(ctx context.Context, resourceType, resourceID string) error
- func (a *CoreCacheAdapter) SetDecision(ctx context.Context, key string, decision *CachedDecision, ttl time.Duration) error
- type MemoryCache
- func (m *MemoryCache) GetDecision(_ context.Context, key string) (*CachedDecision, bool, error)
- func (m *MemoryCache) InvalidateAll(_ context.Context) error
- func (m *MemoryCache) InvalidatePrincipal(_ context.Context, principalSubject string) error
- func (m *MemoryCache) InvalidateResource(_ context.Context, resourceType, resourceID string) error
- func (m *MemoryCache) SetDecision(_ context.Context, key string, decision *CachedDecision, ttl time.Duration) error
Constants ¶
View Source
const DefaultTTL = 5 * time.Minute
DefaultTTL is the default cache duration for policy evaluation decisions.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
GetDecision(ctx context.Context, key string) (*CachedDecision, bool, error)
SetDecision(ctx context.Context, key string, decision *CachedDecision, ttl time.Duration) error
InvalidatePrincipal(ctx context.Context, principalSubject string) error
InvalidateResource(ctx context.Context, resourceType, resourceID string) error
InvalidateAll(ctx context.Context) error
}
Cache defines the semantic contract for caching authorization decisions.
type CachedDecision ¶
type CachedDecision struct {
Effect string `json:"effect"`
Reason string `json:"reason,omitempty"`
Challenge map[string]any `json:"challenge,omitempty"`
PolicyID string `json:"policy_id,omitempty"`
CachedAt time.Time `json:"cached_at"`
}
CachedDecision is the stored authorization decision payload.
type CoreCacheAdapter ¶
type CoreCacheAdapter struct {
// contains filtered or unexported fields
}
CoreCacheAdapter implements Cache using the shared GoModularAuth Core Cache.
func NewCoreCacheAdapter ¶
func NewCoreCacheAdapter(c corecache.Cache, defaultTTL time.Duration) *CoreCacheAdapter
func (*CoreCacheAdapter) GetDecision ¶
func (a *CoreCacheAdapter) GetDecision(ctx context.Context, key string) (*CachedDecision, bool, error)
func (*CoreCacheAdapter) InvalidateAll ¶
func (a *CoreCacheAdapter) InvalidateAll(ctx context.Context) error
func (*CoreCacheAdapter) InvalidatePrincipal ¶
func (a *CoreCacheAdapter) InvalidatePrincipal(ctx context.Context, principalSubject string) error
func (*CoreCacheAdapter) InvalidateResource ¶
func (a *CoreCacheAdapter) InvalidateResource(ctx context.Context, resourceType, resourceID string) error
func (*CoreCacheAdapter) SetDecision ¶
func (a *CoreCacheAdapter) SetDecision(ctx context.Context, key string, decision *CachedDecision, ttl time.Duration) error
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache provides an in-memory thread-safe cache for policy evaluations.
func NewMemoryCache ¶
func NewMemoryCache(ttl time.Duration) *MemoryCache
func (*MemoryCache) GetDecision ¶
func (m *MemoryCache) GetDecision(_ context.Context, key string) (*CachedDecision, bool, error)
func (*MemoryCache) InvalidateAll ¶
func (m *MemoryCache) InvalidateAll(_ context.Context) error
func (*MemoryCache) InvalidatePrincipal ¶
func (m *MemoryCache) InvalidatePrincipal(_ context.Context, principalSubject string) error
func (*MemoryCache) InvalidateResource ¶
func (m *MemoryCache) InvalidateResource(_ context.Context, resourceType, resourceID string) error
func (*MemoryCache) SetDecision ¶
func (m *MemoryCache) SetDecision(_ context.Context, key string, decision *CachedDecision, ttl time.Duration) error
Click to show internal directories.
Click to hide internal directories.