Documentation
¶
Index ¶
- Variables
- func RequestAuthorizer(authorizer Authorizer, actions func(*http.Request) []string) func(*http.Request) Decision
- func WithAssertions(ctx context.Context, assertions ...Assertion) context.Context
- func WithClaims(ctx context.Context, claims *Claims) context.Context
- func WithRequestInfo(ctx context.Context, info RequestInfo) context.Context
- type AccessConfig
- type Assertion
- type AssertionFunc
- type AuthorizationChecker
- type Authorizer
- type Claims
- type Config
- type Decision
- type DefaultAuthorizer
- type RBAC
- func (rbac *RBAC) AddRole(role any, parents ...any) error
- func (rbac *RBAC) Apply(cfg Config) error
- func (rbac *RBAC) CreateMissingRoles() bool
- func (rbac *RBAC) HasRole(role any) (bool, error)
- func (rbac *RBAC) IsGranted(ctx context.Context, role any, permission string, assertions ...Assertion) bool
- func (rbac *RBAC) IsGrantedE(ctx context.Context, role any, permission string, assertions ...Assertion) (granted bool, err error)
- func (rbac *RBAC) Role(name string) (*Role, error)
- func (rbac *RBAC) Roles() iter.Seq[*Role]
- func (rbac *RBAC) SetCreateMissingRoles(createMissingRoles bool) *RBAC
- type RequestInfo
- type Role
- func (r *Role) AddChild(child *Role) error
- func (r *Role) AddParent(parent *Role) error
- func (r *Role) AddPermissions(permissions ...string)
- func (r *Role) Children() iter.Seq[*Role]
- func (r *Role) HasAncestor(role *Role) bool
- func (r *Role) HasDescendant(role *Role) bool
- func (r *Role) HasPermission(permission string) bool
- func (r *Role) Name() string
- func (r *Role) Parents() iter.Seq[*Role]
- func (r *Role) Permissions(children bool) iter.Seq[string]
- func (r *Role) String() string
- type RoleConfig
- type Subject
- type Target
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCircularRef = errors.New("circular reference detected") ErrRoleNil = errors.New("role is nil") ErrRoleNotFound = errors.New("role not found") ErrInvalidRole = errors.New("role must be a string or implement the Role interface") )
View Source
var ErrDeny = errors.New("deny")
Functions ¶
func RequestAuthorizer ¶
func WithAssertions ¶
func WithRequestInfo ¶ added in v0.0.3
func WithRequestInfo(ctx context.Context, info RequestInfo) context.Context
Types ¶
type AccessConfig ¶
type Assertion ¶
func CtxAssertions ¶
type AssertionFunc ¶
type AuthorizationChecker ¶
type Authorizer ¶
type Config ¶
type Config struct {
CreateMissingRoles bool `env:"CREATE_MISSING_ROLES" json:"createMissingRoles,omitempty" yaml:"createMissingRoles,omitempty"`
RoleHierarchy []RoleConfig `envPrefix:"ROLE_CONFIG_" json:"roleHierarchy,omitempty" yaml:"roleHierarchy,omitempty"`
AccessControl []AccessConfig `envPrefix:"ACCESS_CONFIG_" json:"accessControl,omitempty" yaml:"accessControl,omitempty"`
}
type DefaultAuthorizer ¶
type DefaultAuthorizer struct {
// contains filtered or unexported fields
}
func NewDefaultAuthorizer ¶
func NewDefaultAuthorizer(rbac *RBAC) *DefaultAuthorizer
func (*DefaultAuthorizer) AuthorizeE ¶ added in v0.0.9
type RBAC ¶
type RBAC struct {
// contains filtered or unexported fields
}
func NewWithConfig ¶
func (*RBAC) CreateMissingRoles ¶
func (*RBAC) IsGrantedE ¶
func (*RBAC) SetCreateMissingRoles ¶
type RequestInfo ¶ added in v0.0.3
type RequestInfo struct {
Method string
Host string
RequestURI string
Pattern string
RemoteAddr string
Header http.Header
URL *url.URL
IsTLS bool
}
func CtxRequestInfo ¶ added in v0.0.3
func CtxRequestInfo(ctx context.Context) RequestInfo
type Role ¶
type Role struct {
// contains filtered or unexported fields
}
func (*Role) AddPermissions ¶
func (*Role) HasAncestor ¶
func (*Role) HasDescendant ¶
func (*Role) HasPermission ¶
type RoleConfig ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.