Documentation
¶
Index ¶
- Variables
- type Action
- type ActionCapability
- type BatchEvaluateRequest
- type BatchEvaluateResponse
- type CapabilityResource
- type Context
- type Decision
- type DecisionContext
- type Entitlement
- type EvaluateRequest
- type MappingRef
- type PAP
- type PDP
- type PolicyEffectType
- type ProfileRequest
- type Resource
- type ResourceHierarchy
- type Role
- type RoleEntitlementMapping
- type RoleEntitlementMappingFilter
- type RoleFilter
- type RoleRef
- type SubjectContext
- type UserCapabilitiesResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuthzDisabled = fmt.Errorf("authorization is disabled - policy management operations are not available") ErrRoleAlreadyExists = fmt.Errorf("role already exists") ErrRoleNotFound = fmt.Errorf("role not found") ErrRoleInUse = fmt.Errorf("role is in use and cannot be deleted") ErrRoleMappingAlreadyExists = fmt.Errorf("role mapping already exists") ErrRoleMappingNotFound = fmt.Errorf("role mapping not found") ErrCannotDeleteSystemMapping = fmt.Errorf("cannot delete system mapping") ErrCannotModifySystemMapping = fmt.Errorf("cannot modify system mapping") ErrInvalidRequest = fmt.Errorf("invalid request") )
Functions ¶
This section is empty.
Types ¶
type Action ¶ added in v0.14.0
Action represents a system action with metadata
func AllActions ¶ added in v0.14.0
func AllActions() []Action
AllActions returns all system-defined actions
func ConcretePublicActions ¶ added in v0.14.0
func ConcretePublicActions() []Action
ConcretePublicActions returns only concrete (non-wildcarded) public actions, sorted by name
func PublicActions ¶ added in v0.14.0
func PublicActions() []Action
PublicActions returns all public (non-internal) actions, sorted by name
type ActionCapability ¶ added in v0.8.0
type ActionCapability struct {
Allowed []*CapabilityResource `json:"allowed"`
Denied []*CapabilityResource `json:"denied"`
}
ActionCapability represents capabilities for a specific action
type BatchEvaluateRequest ¶
type BatchEvaluateRequest struct {
Requests []EvaluateRequest `json:"requests"`
}
BatchEvaluateRequest represents a batch of authorization requests
type BatchEvaluateResponse ¶
type BatchEvaluateResponse struct {
Decisions []Decision `json:"decisions"`
}
BatchEvaluateResponse represents a batch of authorization decisions
type CapabilityResource ¶ added in v0.8.0
type CapabilityResource struct {
Path string `json:"path"` // Full resource path: "namespace/acme/project/payment"
Constraints *interface{} `json:"constraints"` // represents additional instance level restrictions
}
CapabilityResource represents a resource with permission details (SIMPLIFIED)
type Decision ¶
type Decision struct {
Decision bool `json:"decision"`
Context *DecisionContext `json:"context,omitempty"`
}
Decision represents the authorization decision response
type DecisionContext ¶
type DecisionContext struct {
Reason string `json:"reason,omitempty"`
}
DecisionContext contains additional context about the decision
type Entitlement ¶ added in v0.8.0
type Entitlement struct {
// Claim is the JWT claim name (e.g., "group", "sub")
Claim string `json:"claim" yaml:"claim"`
// Value is the entitlement value (e.g., "admin-group", "service-123")
Value string `json:"value" yaml:"value"`
}
Entitlement represents an entitlement with its claim and value
type EvaluateRequest ¶
type EvaluateRequest struct {
SubjectContext *SubjectContext `json:"subject_context"`
Resource Resource `json:"resource"`
Action string `json:"action"`
Context Context `json:"context"`
}
EvaluateRequest represents a single authorization request
type MappingRef ¶ added in v0.14.0
type MappingRef struct {
// Name is the binding name
Name string `json:"name" yaml:"name"`
// Namespace identifies the binding scope:
// - Empty string ("") = cluster-scoped binding (AuthzClusterRoleBinding)
// - Non-empty = namespace-scoped binding (AuthzRoleBinding) in the specified namespace
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
}
MappingRef identifies a role-entitlement binding
type PAP ¶
type PAP interface {
// Deprecated: Use CreateClusterRole or CreateNamespacedRole instead.
AddRole(ctx context.Context, role *Role) error
// Deprecated: Use the K8s client directly to delete roles.
RemoveRole(ctx context.Context, roleRef *RoleRef) error
// Deprecated: Use GetClusterRole or GetNamespacedRole instead.
GetRole(ctx context.Context, roleRef *RoleRef) (*Role, error)
// Deprecated: Use UpdateClusterRole or UpdateNamespacedRole instead.
UpdateRole(ctx context.Context, role *Role) error
// Deprecated: Use ListClusterRoles or ListNamespacedRoles instead.
ListRoles(ctx context.Context, filter *RoleFilter) ([]*Role, error)
// Deprecated: Use GetClusterRoleBinding or GetNamespacedRoleBinding instead.
GetRoleEntitlementMapping(ctx context.Context, mappingRef *MappingRef) (*RoleEntitlementMapping, error)
// Deprecated: Use CreateClusterRoleBinding or CreateNamespacedRoleBinding instead.
AddRoleEntitlementMapping(ctx context.Context, mapping *RoleEntitlementMapping) error
// Deprecated: Use UpdateClusterRoleBinding or UpdateNamespacedRoleBinding instead.
UpdateRoleEntitlementMapping(ctx context.Context, mapping *RoleEntitlementMapping) error
// Deprecated: Use the K8s client directly to delete role bindings.
RemoveRoleEntitlementMapping(ctx context.Context, mappingRef *MappingRef) error
// Deprecated: Use ListClusterRoleBindings or ListNamespacedRoleBindings instead.
ListRoleEntitlementMappings(ctx context.Context, filter *RoleEntitlementMappingFilter) ([]*RoleEntitlementMapping, error)
// ListActions lists all defined actions in the system
ListActions(ctx context.Context) ([]string, error)
// CreateClusterRole creates a new cluster-scoped role and returns the full CRD object
CreateClusterRole(ctx context.Context, role *openchoreov1alpha1.AuthzClusterRole) (*openchoreov1alpha1.AuthzClusterRole, error)
// GetClusterRole retrieves a cluster-scoped role by name
GetClusterRole(ctx context.Context, name string) (*openchoreov1alpha1.AuthzClusterRole, error)
// ListClusterRoles lists all cluster-scoped roles
ListClusterRoles(ctx context.Context) (*openchoreov1alpha1.AuthzClusterRoleList, error)
// UpdateClusterRole updates a cluster-scoped role and returns the updated CRD object
UpdateClusterRole(ctx context.Context, role *openchoreov1alpha1.AuthzClusterRole) (*openchoreov1alpha1.AuthzClusterRole, error)
// CreateNamespacedRole creates a new namespace-scoped role and returns the full CRD object
CreateNamespacedRole(ctx context.Context, role *openchoreov1alpha1.AuthzRole) (*openchoreov1alpha1.AuthzRole, error)
// GetNamespacedRole retrieves a namespace-scoped role by name and namespace
GetNamespacedRole(ctx context.Context, name string, namespace string) (*openchoreov1alpha1.AuthzRole, error)
// ListNamespacedRoles lists namespace-scoped roles in the given namespace
ListNamespacedRoles(ctx context.Context, namespace string) (*openchoreov1alpha1.AuthzRoleList, error)
// UpdateNamespacedRole updates a namespace-scoped role and returns the updated CRD object
UpdateNamespacedRole(ctx context.Context, role *openchoreov1alpha1.AuthzRole) (*openchoreov1alpha1.AuthzRole, error)
// CreateClusterRoleBinding creates a new cluster-scoped role binding and returns the full CRD object
CreateClusterRoleBinding(ctx context.Context, binding *openchoreov1alpha1.AuthzClusterRoleBinding) (*openchoreov1alpha1.AuthzClusterRoleBinding, error)
// GetClusterRoleBinding retrieves a cluster-scoped role binding by name
GetClusterRoleBinding(ctx context.Context, name string) (*openchoreov1alpha1.AuthzClusterRoleBinding, error)
// ListClusterRoleBindings lists all cluster-scoped role bindings
ListClusterRoleBindings(ctx context.Context) (*openchoreov1alpha1.AuthzClusterRoleBindingList, error)
// UpdateClusterRoleBinding updates a cluster-scoped role binding and returns the updated CRD object
UpdateClusterRoleBinding(ctx context.Context, binding *openchoreov1alpha1.AuthzClusterRoleBinding) (*openchoreov1alpha1.AuthzClusterRoleBinding, error)
// CreateNamespacedRoleBinding creates a new namespace-scoped role binding and returns the full CRD object
CreateNamespacedRoleBinding(ctx context.Context, binding *openchoreov1alpha1.AuthzRoleBinding) (*openchoreov1alpha1.AuthzRoleBinding, error)
// GetNamespacedRoleBinding retrieves a namespace-scoped role binding by name and namespace
GetNamespacedRoleBinding(ctx context.Context, name string, namespace string) (*openchoreov1alpha1.AuthzRoleBinding, error)
// ListNamespacedRoleBindings lists namespace-scoped role bindings in the given namespace
ListNamespacedRoleBindings(ctx context.Context, namespace string) (*openchoreov1alpha1.AuthzRoleBindingList, error)
// UpdateNamespacedRoleBinding updates a namespace-scoped role binding and returns the updated CRD object
UpdateNamespacedRoleBinding(ctx context.Context, binding *openchoreov1alpha1.AuthzRoleBinding) (*openchoreov1alpha1.AuthzRoleBinding, error)
}
PAP (Policy Administration Point) interface defines the contract for policy management
type PDP ¶
type PDP interface {
// Evaluate evaluates a single authorization request and returns a decision
Evaluate(ctx context.Context, request *EvaluateRequest) (*Decision, error)
// BatchEvaluate evaluates multiple authorization requests and returns corresponding decisions
BatchEvaluate(ctx context.Context, request *BatchEvaluateRequest) (*BatchEvaluateResponse, error)
// GetSubjectProfile retrieves the authorization profile for a given subject
GetSubjectProfile(ctx context.Context, request *ProfileRequest) (*UserCapabilitiesResponse, error)
}
PDP (Policy Decision Point) interface defines the contract for authorization evaluation
type PolicyEffectType ¶
type PolicyEffectType string
PolicyEffectType defines the effect of a policy: allow or deny
const ( PolicyEffectAllow PolicyEffectType = "allow" PolicyEffectDeny PolicyEffectType = "deny" )
type ProfileRequest ¶
type ProfileRequest struct {
// SubjectContext is the authenticated subject whose profile is being requested
SubjectContext *SubjectContext `json:"subject_context"`
// Scope is the resource hierarchy scope for the profile
Scope ResourceHierarchy `json:"scope"`
}
ProfileRequest represents a request to retrieve a subject's authorization profile
type Resource ¶
type Resource struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
Hierarchy ResourceHierarchy `json:"hierarchy"`
}
Resource represents a resource in the authorization request
type ResourceHierarchy ¶
type ResourceHierarchy struct {
Namespace string `json:"namespace,omitempty"`
Project string `json:"project,omitempty"`
Component string `json:"component,omitempty"`
}
ResourceHierarchy represents a single item in a resource hierarchy
type Role ¶
type Role struct {
// Name is the unique identifier for the role
Name string `json:"name"`
// Actions is the list of actions this role permits
Actions []string `json:"actions"`
// Namespace is the namespace for namespace-scoped roles, empty for cluster roles
Namespace string `json:"namespace,omitempty"`
// IsInternal indicates if this role should be hidden from public listings
IsInternal bool `json:"-"`
// Description provides a human-readable description of the role
Description string `json:"description,omitempty"`
}
Role represents a role with a set of allowed actions If Namespace is empty, it's a cluster-scoped role; otherwise it's namespace-scoped
type RoleEntitlementMapping ¶
type RoleEntitlementMapping struct {
// Name is the unique identifier for the mapping (CRD name)
Name string `json:"name" yaml:"name,omitempty"`
// RoleRef identifies the role being assigned
RoleRef RoleRef `json:"role" yaml:"role"`
// Entitlement contains the claim and value for this mapping
Entitlement Entitlement `json:"entitlement" yaml:"entitlement"`
// Hierarchy defines the resource hierarchy scope where this role applies
// Empty hierarchy means global scope (*)
Hierarchy ResourceHierarchy `json:"hierarchy" yaml:"hierarchy,omitempty"`
// Effect indicates whether the mapping is to allow or deny access
Effect PolicyEffectType `json:"effect" yaml:"effect"`
// Context provides optional additional context metadata for this mapping
Context Context `json:"context" yaml:"context,omitempty"`
// IsInternal indicates if this mapping should be hidden from public listings
IsInternal bool `json:"-" yaml:"-"`
}
RoleEntitlementMapping represents the assignment of a role to an entitlement within a hierarchical scope
type RoleEntitlementMappingFilter ¶ added in v0.9.0
type RoleEntitlementMappingFilter struct {
// RoleRef filters mappings by role reference (name and namespace)
RoleRef *RoleRef
// Entitlement filters mappings by entitlement claim and value
Entitlement *Entitlement
// Effect filters mappings by policy effect
Effect *PolicyEffectType
}
RoleEntitlementMappingFilter provides filters for listing role-entitlement mappings
type RoleFilter ¶ added in v0.12.0
type RoleFilter struct {
// Namespace filters roles by namespace scope:
// - "" (empty) = cluster-scoped roles only
// - "ns1" = namespace-scoped roles in "ns1" only
// Ignored when IncludeAll is true
Namespace string
// IncludeAll when true returns all roles (cluster + all namespaces)
IncludeAll bool
}
RoleFilter provides filters for listing roles
type RoleRef ¶ added in v0.12.0
type RoleRef struct {
// Name is the role name
Name string `json:"name" yaml:"name"`
// Namespace identifies the role scope:
// - Empty string ("") = cluster-scoped role
// - Non-empty = namespace-scoped role in the specified namespace
Namespace string `json:"namespace,omitempty" yaml:"namespace"`
}
RoleRef uniquely identifies a role by name and namespace
type SubjectContext ¶
type SubjectContext struct {
Type string `json:"type"`
EntitlementClaim string `json:"entitlement_claim"`
EntitlementValues []string `json:"entitlement_values"`
}
SubjectContext represents the authenticated subject making the authorization request
func GetAuthzSubjectContext ¶ added in v0.9.0
func GetAuthzSubjectContext(authCtx *auth.SubjectContext) *SubjectContext
GetAuthzSubjectContext converts auth.SubjectContext to authz SubjectContext
type UserCapabilitiesResponse ¶ added in v0.8.0
type UserCapabilitiesResponse struct {
User *SubjectContext `json:"user"`
Capabilities map[string]*ActionCapability `json:"capabilities"`
GeneratedAt time.Time `json:"evaluatedAt"`
}
UserCapabilitiesResponse represents the complete capabilities response