Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EvaluateOption ¶
type EvaluateOption func(*EvaluateOptions)
EvaluateOption is a functional option for Evaluate
func WithExplainer ¶
func WithExplainer(explainer Explainer) EvaluateOption
WithExplainer adds an explainer to track the evaluation process
type EvaluateOptions ¶
type EvaluateOptions struct {
Explainer Explainer
}
EvaluateOptions contains options for the Evaluate method
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator evaluates RBAC policies using a PolicyProvider
func NewEvaluator ¶
NewEvaluator creates a new RBAC evaluator with a PolicyProvider
func (*Evaluator) ClearCache ¶
func (e *Evaluator) ClearCache()
ClearCache clears the decision cache
type Explainer ¶
type Explainer interface {
// RuleConsidered is called for each rule that is evaluated
RuleConsidered(rule *Rule)
// RuleSkipped is called when a rule is skipped with the reason
RuleSkipped(rule *Rule, reason string)
// RuleMatched is called when a rule matches and grants permission
RuleMatched(rule *Rule, resource string, action string)
// NoRulesMatched is called when no rules grant the requested permission
NoRulesMatched()
}
Explainer receives information about the evaluation process
type Permission ¶
Permission represents a permission in a rule
type Policy ¶
type Policy struct {
Rules []Rule `json:"rules"`
ClusterID string `json:"cluster_id,omitempty"`
ClusterName string `json:"cluster_name,omitempty"`
}
Policy represents the RBAC policy document from miren.cloud
type PolicyProvider ¶
type PolicyProvider interface {
// GetPolicy returns the current policy
GetPolicy() *Policy
}
PolicyProvider is an interface for providing RBAC policies
type Request ¶
type Request struct {
Subject string // Subject identifier (from JWT)
Groups []string // Group IDs the subject belongs to
Resource string // Resource being accessed
Action string // Action being performed
Tags map[string]any // Tags to match against rule selectors
Context map[string]any // Additional context
}
Request represents an authorization request with tags
type Rule ¶
type Rule struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
TagSelector TagSelector `json:"tag_selector"`
Groups []string `json:"groups"`
Permissions []Permission `json:"permissions"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Rule represents a single RBAC rule from miren.cloud
func (*Rule) HasPermission ¶
HasPermission checks if the rule grants permission for a resource and action
type TagExpression ¶
type TagExpression struct {
Tag string `json:"tag"`
Value any `json:"value"` // Can be a string, number, boolean, or array
Operator string `json:"operator"` // "equals", "not_equals", "in", "not_in", "exists", "not_exists"
}
TagExpression represents a single tag matching expression
type TagSelector ¶
type TagSelector struct {
Expressions []TagExpression `json:"expressions"`
}
TagSelector defines tag matching criteria using expressions