Documentation
¶
Index ¶
- Constants
- func BuildKey(principal auth.Principal, permission 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) 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) 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 authorization 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
InvalidateAll(ctx context.Context) error
}
Cache defines the semantic contract for caching authorization decisions.
type CachedDecision ¶
type CachedDecision struct {
Allowed bool `json:"allowed"`
Reason string `json:"reason,omitempty"`
MatchedRole string `json:"matched_role,omitempty"`
Permission string `json:"permission"`
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 adapter.
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) 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 a fast, standalone thread-safe in-memory cache for RBAC 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) 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.