core

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

type Action struct {
	Name string
	// LowestScope indicates the lowest resource hierarchy level at which this action is evaluated
	LowestScope ActionScope
	// IsInternal indicates if the action is internal (not publicly visible)
	IsInternal bool
}

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 ActionScope added in v1.0.0

type ActionScope string

ActionScope represents the resource hierarchy level at which an action is evaluated.

const (
	// ScopeCluster indicates the action is evaluated at the cluster level (no hierarchy).
	ScopeCluster ActionScope = "cluster"
	// ScopeNamespace indicates the action is evaluated at the namespace level.
	ScopeNamespace ActionScope = "namespace"
	// ScopeProject indicates the action is evaluated at the project level.
	ScopeProject ActionScope = "project"
	// ScopeComponent indicates the action is evaluated at the component level.
	ScopeComponent ActionScope = "component"
)

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 Context

type Context struct {
}

Context additional resource instance level context

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 PAP

type PAP interface {
	// ListActions lists all public actions in the system
	ListActions(ctx context.Context) ([]Action, error)

	// CreateClusterRole creates a new cluster-scoped role and returns the full CRD object
	CreateClusterRole(ctx context.Context, role *openchoreov1alpha1.ClusterAuthzRole) (*openchoreov1alpha1.ClusterAuthzRole, error)
	// GetClusterRole retrieves a cluster-scoped role by name
	GetClusterRole(ctx context.Context, name string) (*openchoreov1alpha1.ClusterAuthzRole, error)
	// ListClusterRoles lists all cluster-scoped roles
	ListClusterRoles(ctx context.Context, limit int, cursor string) (*PaginatedList[openchoreov1alpha1.ClusterAuthzRole], error)
	// UpdateClusterRole updates a cluster-scoped role and returns the updated CRD object
	UpdateClusterRole(ctx context.Context, role *openchoreov1alpha1.ClusterAuthzRole) (*openchoreov1alpha1.ClusterAuthzRole, error)
	// DeleteClusterRole deletes a cluster-scoped role by name
	DeleteClusterRole(ctx context.Context, name string) 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, limit int, cursor string) (*PaginatedList[openchoreov1alpha1.AuthzRole], error)
	// UpdateNamespacedRole updates a namespace-scoped role and returns the updated CRD object
	UpdateNamespacedRole(ctx context.Context, role *openchoreov1alpha1.AuthzRole) (*openchoreov1alpha1.AuthzRole, error)
	// DeleteNamespacedRole deletes a namespace-scoped role by name and namespace
	DeleteNamespacedRole(ctx context.Context, name string, namespace string) error

	// CreateClusterRoleBinding creates a new cluster-scoped role binding and returns the full CRD object
	CreateClusterRoleBinding(ctx context.Context, binding *openchoreov1alpha1.ClusterAuthzRoleBinding) (*openchoreov1alpha1.ClusterAuthzRoleBinding, error)
	// GetClusterRoleBinding retrieves a cluster-scoped role binding by name
	GetClusterRoleBinding(ctx context.Context, name string) (*openchoreov1alpha1.ClusterAuthzRoleBinding, error)
	// ListClusterRoleBindings lists all cluster-scoped role bindings
	ListClusterRoleBindings(ctx context.Context, limit int, cursor string) (*PaginatedList[openchoreov1alpha1.ClusterAuthzRoleBinding], error)
	// UpdateClusterRoleBinding updates a cluster-scoped role binding and returns the updated CRD object
	UpdateClusterRoleBinding(ctx context.Context, binding *openchoreov1alpha1.ClusterAuthzRoleBinding) (*openchoreov1alpha1.ClusterAuthzRoleBinding, error)
	// DeleteClusterRoleBinding deletes a cluster-scoped role binding by name
	DeleteClusterRoleBinding(ctx context.Context, name string) 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, limit int, cursor string) (*PaginatedList[openchoreov1alpha1.AuthzRoleBinding], error)
	// UpdateNamespacedRoleBinding updates a namespace-scoped role binding and returns the updated CRD object
	UpdateNamespacedRoleBinding(ctx context.Context, binding *openchoreov1alpha1.AuthzRoleBinding) (*openchoreov1alpha1.AuthzRoleBinding, error)
	// DeleteNamespacedRoleBinding deletes a namespace-scoped role binding by name and namespace
	DeleteNamespacedRoleBinding(ctx context.Context, name string, namespace string) 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 PaginatedList added in v0.17.0

type PaginatedList[T any] struct {
	Items      []T
	NextCursor string
}

PaginatedList holds a page of items along with pagination metadata. This type is used by the PAP layer to return paginated results

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 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

Jump to

Keyboard shortcuts

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