Documentation
¶
Index ¶
- Variables
- func ContextWithAuthClaims(parent context.Context, claims *AuthClaims) context.Context
- func Register(typ Type, f FactoryFunc) error
- func Unregister(typ Type) bool
- type Action
- type Actions
- type AuthClaims
- type AuthErrorCode
- type Authorizer
- type Engine
- type FactoryFunc
- type Pair
- type Pairs
- type PolicyMap
- type Project
- type Projects
- type Resource
- type Resources
- type RoleMap
- type Subject
- type Subjects
- type Type
- type Writer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMissingAuthClaims = status.Error(codes.Code(AuthErrorCodeMissingAuthClaims), "context missing authz claims") ErrInvalidClaims = status.Error(codes.Code(AuthErrorCodeInvalidClaims), "invalid claims") )
Functions ¶
func ContextWithAuthClaims ¶
func ContextWithAuthClaims(parent context.Context, claims *AuthClaims) context.Context
ContextWithAuthClaims injects the provided AuthClaims into the parent context.
func Register ¶
func Register(typ Type, f FactoryFunc) error
Register an authz engine factory function
func Unregister ¶
Unregister removes a registered factory by Type. It returns true if a factory was removed. Use with caution in concurrent environments (primarily intended for tests).
Types ¶
type AuthClaims ¶
type AuthClaims struct {
Subjects *[]string
Pairs *Pairs
Projects *[]string
Subject *Subject
Action *Action
Resource *Resource
Project *Project
}
func AuthClaimsFromContext ¶
func AuthClaimsFromContext(ctx context.Context) (*AuthClaims, bool)
AuthClaimsFromContext extracts the AuthClaims from the provided ctx (if any).
type AuthErrorCode ¶
type AuthErrorCode int32
const ( AuthErrorCodeMissingAuthClaims AuthErrorCode = 2001 AuthErrorCodeInvalidClaims AuthErrorCode = 2002 )
type Authorizer ¶
type Authorizer interface {
Name() string
ProjectsAuthorized(ctx context.Context, subjects Subjects, action Action, resource Resource, projects Projects) (Projects, error)
FilterAuthorizedPairs(ctx context.Context, subjects Subjects, pairs Pairs) (Pairs, error)
FilterAuthorizedProjects(ctx context.Context, subjects Subjects) (Projects, error)
IsAuthorized(ctx context.Context, subjects Subject, action Action, resource Resource, project Project) (bool, error)
}
type Engine ¶
type Engine interface {
Authorizer
Writer
}
type FactoryFunc ¶
func GetFactory ¶
func GetFactory(typ Type) (FactoryFunc, bool)
GetFactory returns a registered FactoryFunc for a given Type and whether it existed. Safe for concurrent use.
Click to show internal directories.
Click to hide internal directories.