Documentation
¶
Index ¶
- func WithIdentity(ctx context.Context, id *Identity) context.Context
- type Action
- type AllwaysMatchObjectScope
- type Authenticator
- type AuthorizationRule
- type Authorizer
- type CompositeAuthenticator
- type DefaultObjectScope
- type Identity
- type IdentityScope
- type ObjectScope
- type ObjectType
- type Role
- type RuleBasedAuthorizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AllwaysMatchObjectScope ¶
type AllwaysMatchObjectScope struct{}
AllwaysMatchObjectScope is a special ObjectScope that always matches any identity
func (AllwaysMatchObjectScope) Matches ¶
func (a AllwaysMatchObjectScope) Matches(identity *Identity) bool
type Authenticator ¶
type AuthorizationRule ¶
type AuthorizationRule struct {
Roles []Role
Action Action
Object ObjectType
}
AuthorizationRule represents a single authorization rule with roles, action, and object
type Authorizer ¶
type Authorizer interface {
Authorize(identity *Identity, action Action, oject ObjectType, objectScope ObjectScope) error
}
type CompositeAuthenticator ¶
type CompositeAuthenticator struct {
// contains filtered or unexported fields
}
CompositeAuthenticator implements Authenticator by trying multiple authenticators in order
func NewCompositeAuthenticator ¶
func NewCompositeAuthenticator(authenticators ...Authenticator) *CompositeAuthenticator
NewCompositeAuthenticator creates a new composite authenticator
func (*CompositeAuthenticator) Authenticate ¶
Authenticate tries each authenticator in order until one succeeds Returns nil if all authenticators fail
type DefaultObjectScope ¶
type DefaultObjectScope struct {
ParticipantID *properties.UUID
ProviderID *properties.UUID
ConsumerID *properties.UUID
AgentID *properties.UUID
}
DefaultObjectScope is the default implementation of ObjectScope
func (*DefaultObjectScope) Matches ¶
func (target *DefaultObjectScope) Matches(id *Identity) bool
Matches checks if the given identity matches the object scope
type Identity ¶
type Identity struct {
ID properties.UUID
Name string
Role Role
Scope IdentityScope
}
Identity implements the Identifier interface
func MustGetIdentity ¶
MustGetIdentity retrieves the authenticated identity from the request context
type IdentityScope ¶
type IdentityScope struct {
ParticipantID *properties.UUID
AgentID *properties.UUID
}
type ObjectScope ¶
ObjectScope defines the target object scope in the authorization system
type ObjectType ¶
type ObjectType string
ObjectType represents a target object type in the authorization system
type RuleBasedAuthorizer ¶
type RuleBasedAuthorizer struct {
// contains filtered or unexported fields
}
RuleBasedAuthorizer implements the Authorizer interface using a set of predefined rules
func NewRuleBasedAuthorizer ¶
func NewRuleBasedAuthorizer(rules []AuthorizationRule) *RuleBasedAuthorizer
NewRuleBasedAuthorizer creates a new RuleBasedAuthorizer with the given rules
func (*RuleBasedAuthorizer) Authorize ¶
func (a *RuleBasedAuthorizer) Authorize(identity *Identity, action Action, object ObjectType, objectContext ObjectScope) error
Authorize checks if the given identity is authorized to perform the action on the object It matches against the predefined rules based on the identity's roles