Documentation
¶
Index ¶
- Constants
- func AliasesFor(key string) []string
- func IsAlias(key string) bool
- func NormalizeKey(key string) string
- func ResolveAlias(key string) (string, bool)
- type ActorClaims
- type ActorRef
- type ClaimsProvider
- type DefaultTrace
- type FeatureGate
- type MutableFeatureGate
- type OverrideMatchTrace
- type OverrideState
- type OverrideTrace
- type PermissionProvider
- type ResolveEvent
- type ResolveHook
- type ResolveHookFunc
- type ResolveOption
- type ResolveRequest
- type ResolveSource
- type ResolveTrace
- type ScopeChain
- type ScopeKind
- type ScopeRef
- type TraceableFeatureGate
Constants ¶
const ( FeatureUsersSignup = "users.signup" FeatureUsersPasswordReset = "users.password_reset" // FeatureUsersPasswordResetFinalize duplicates the go-auth string (go-auth owns the literal). FeatureUsersPasswordResetFinalize = "users.password_reset.finalize" )
Variables ¶
This section is empty.
Functions ¶
func AliasesFor ¶
AliasesFor returns the legacy alias keys for the provided key, if any.
func NormalizeKey ¶
NormalizeKey trims whitespace and resolves any known aliases (if configured).
func ResolveAlias ¶
ResolveAlias returns the normalized key and whether an alias was applied.
Types ¶
type ActorClaims ¶ added in v0.5.0
type ActorClaims struct {
SubjectID string
TenantID string
OrgID string
Roles []string
Perms []string
}
ActorClaims are the minimal inputs required to build a chain.
type ClaimsProvider ¶ added in v0.5.0
type ClaimsProvider interface {
ClaimsFromContext(ctx context.Context) (ActorClaims, error)
}
ClaimsProvider derives claims from context.
type DefaultTrace ¶
DefaultTrace captures config default resolution details.
type FeatureGate ¶
type FeatureGate interface {
Enabled(ctx context.Context, key string, opts ...ResolveOption) (bool, error)
}
FeatureGate resolves feature enablement for the current scope.
type MutableFeatureGate ¶
type MutableFeatureGate interface {
FeatureGate
Set(ctx context.Context, key string, scope ScopeRef, enabled bool, actor ActorRef) error
Unset(ctx context.Context, key string, scope ScopeRef, actor ActorRef) error
}
MutableFeatureGate supports runtime overrides for feature values.
type OverrideMatchTrace ¶ added in v0.5.0
type OverrideMatchTrace struct {
Scope ScopeRef
State OverrideState
Value *bool
}
OverrideMatchTrace captures a single matched override for trace output.
type OverrideState ¶
type OverrideState string
OverrideState captures the tri-state override status.
const ( OverrideStateMissing OverrideState = "missing" OverrideStateEnabled OverrideState = "enabled" OverrideStateDisabled OverrideState = "disabled" OverrideStateUnset OverrideState = "unset" )
type OverrideTrace ¶
type OverrideTrace struct {
State OverrideState
Value *bool
Error error
Match ScopeRef
Matches []OverrideMatchTrace
}
OverrideTrace captures override resolution details.
type PermissionProvider ¶ added in v0.5.0
type PermissionProvider interface {
Permissions(ctx context.Context, claims ActorClaims) ([]string, error)
}
PermissionProvider derives permissions from claims/roles.
type ResolveEvent ¶
type ResolveEvent struct {
Key string
NormalizedKey string
Chain ScopeChain
Value bool
Source ResolveSource
Error error
Trace ResolveTrace
}
ResolveEvent is emitted after resolution for hooks.
type ResolveHook ¶
type ResolveHook interface {
OnResolve(ctx context.Context, event ResolveEvent)
}
ResolveHook receives resolution events.
type ResolveHookFunc ¶
type ResolveHookFunc func(context.Context, ResolveEvent)
ResolveHookFunc wraps a function as a ResolveHook.
func (ResolveHookFunc) OnResolve ¶
func (fn ResolveHookFunc) OnResolve(ctx context.Context, event ResolveEvent)
OnResolve implements ResolveHook.
type ResolveOption ¶
type ResolveOption func(*ResolveRequest)
ResolveOption mutates a resolve request.
func WithScopeChain ¶ added in v0.5.0
func WithScopeChain(chain ScopeChain) ResolveOption
WithScopeChain forces a specific scope chain instead of deriving it from context.
type ResolveRequest ¶
type ResolveRequest struct {
ScopeChain *ScopeChain
}
ResolveRequest captures optional inputs for a resolve call.
type ResolveSource ¶
type ResolveSource string
ResolveSource captures which layer produced the final value.
const ( ResolveSourceOverride ResolveSource = "override" ResolveSourceDefault ResolveSource = "default" ResolveSourceFallback ResolveSource = "fallback" )
type ResolveTrace ¶
type ResolveTrace struct {
Key string
NormalizedKey string
Chain ScopeChain
Value bool
Source ResolveSource
Override OverrideTrace
Default DefaultTrace
CacheHit bool
Strategy string
ClaimsFailureMode string
}
ResolveTrace captures provenance for a single feature resolution.
type ScopeChain ¶ added in v0.5.0
type ScopeChain []ScopeRef
ScopeChain is an ordered list of scope references.
type TraceableFeatureGate ¶
type TraceableFeatureGate interface {
FeatureGate
ResolveWithTrace(ctx context.Context, key string, opts ...ResolveOption) (bool, ResolveTrace, error)
}
TraceableFeatureGate adds explainability for feature resolution.