policy

package
v0.8.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	GetObject(ctx context.Context, key string, value interface{}) error
	SetObject(ctx context.Context, key string, value interface{}, expiration time.Duration) error
	Delete(ctx context.Context, key string) error
}

Cache is the subset of the cache service used for policy caching.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service reads org policies, caches them in Redis (5-min TTL), and provides typed accessors for enforcement. Per D16 the effective policy is `org ∩ platform`; platform policies are injected via the PlatformPolicy field.

func New

func New(store policyStore, cache Cache) *Service

New constructs the PolicyService. cache may be nil (no caching, every call hits the DB) — useful for tests.

func (*Service) GetEffectivePolicy

func (s *Service) GetEffectivePolicy(ctx context.Context, orgID string) (*types.OrgPolicyValues, error)

GetEffectivePolicy returns the org's policy intersected with the platform policy. When the org has no policy set, returns the platform policy alone. When neither is set, returns an empty (unrestricted) values struct.

func (*Service) InvalidateCache

func (s *Service) InvalidateCache(ctx context.Context, orgID string)

InvalidateCache evicts the cached policy for an org. Called after SetOrgPolicy or DeleteOrgPolicy so the next read picks up the change immediately.

func (*Service) SetPlatformPolicy

func (s *Service) SetPlatformPolicy(p types.OrgPolicyValues)

SetPlatformPolicy sets the platform-wide policy floor. Per D16 the effective policy is the intersection of org and platform: org can only restrict further, never loosen. Called once at startup from instance settings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL