Documentation
¶
Overview ¶
Package authz contains the server authorization port. It is deliberately independent of transports and repositories so every use-case can enforce BOLA/BFLA before touching storage.
Index ¶
- Constants
- Variables
- func DeriveTenantContext(p domain.Principal, requested Tenant) (domain.TenantContext, error)
- func Enforce(ctx context.Context, a Authorizer, req Request) error
- func WithAuthorizedContext(ctx context.Context, a AuthorizedContext) context.Context
- type Action
- type AuditEvent
- type AuditSink
- type AuditedAuthorizer
- type AuthorizedContext
- type Authorizer
- type Decision
- type MemoryAudit
- type OpaqueResolver
- type Policy
- type Request
- type Resource
- type ResourceRef
- type Role
- type Tenant
Constants ¶
View Source
const ( DenyUnauthenticated = "unauthenticated" DenyUnknownAction = "unknown_action" DenyRole = "role_not_permitted" DenyScope = "scope_not_granted" DenyTenantMismatch = "tenant_mismatch" DenyWorkspace = "workspace_not_granted" DenyProject = "project_not_granted" DenyOwnership = "ownership_required" DenyClassification = "classification_not_allowed" DenyResourceNotFound = "resource_not_found" DenyRevoked = "credential_revoked" )
Variables ¶
View Source
var ErrForbidden = errors.New("forbidden")
View Source
var ErrResourceNotFound = errors.New(DenyResourceNotFound)
Functions ¶
func DeriveTenantContext ¶
DeriveTenantContext ignores all client-provided tenant fields. requested is retained only to detect an attempted spoof; the authenticated org wins.
func Enforce ¶
func Enforce(ctx context.Context, a Authorizer, req Request) error
Enforce is the mandatory use-case seam. Repositories must not be called until this check succeeds. The stable reason is safe for audit/metrics and never includes a resource's existence or contents.
func WithAuthorizedContext ¶
func WithAuthorizedContext(ctx context.Context, a AuthorizedContext) context.Context
Types ¶
type AuditEvent ¶
type AuditedAuthorizer ¶
type AuthorizedContext ¶
type AuthorizedContext struct {
Principal domain.Principal
Tenant domain.TenantContext
GrantDigest string
}
func AuthorizedFromContext ¶
func AuthorizedFromContext(ctx context.Context) (AuthorizedContext, bool)
func NewAuthorizedContext ¶
func NewAuthorizedContext(ctx context.Context, a Authorizer, req Request) (AuthorizedContext, error)
NewAuthorizedContext binds only verified principal data to a request. A caller cannot construct a server context by supplying an arbitrary tenant.
type MemoryAudit ¶
type MemoryAudit struct {
Events []AuditEvent
// contains filtered or unexported fields
}
func (*MemoryAudit) Record ¶
func (a *MemoryAudit) Record(_ context.Context, e AuditEvent) error
type OpaqueResolver ¶
type OpaqueResolver struct {
// contains filtered or unexported fields
}
func NewOpaqueResolver ¶
func NewOpaqueResolver() *OpaqueResolver
func (*OpaqueResolver) Put ¶
func (r *OpaqueResolver) Put(tenant, kind, opaque, internal string)
type ResourceRef ¶
type ResourceRef struct{ TenantID, WorkspaceID, ProjectID, OwnerSubject, Classification, OpaqueID string }
Click to show internal directories.
Click to hide internal directories.