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 PolicyWriter
- type Project
- type Projects
- type Resource
- type Resources
- type RoleMap
- type Subject
- type Subjects
- type Tenant
- type Tenants
- 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
Tenant *Tenant
Tenants *[]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)
}
Authorizer 定义鉴权决策与批量过滤能力。
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.
type PolicyWriter ¶ added in v0.0.20
type PolicyWriter interface {
SetPolicies(ctx context.Context, policies PolicyMap, roles RoleMap) error
}
PolicyWriter 定义可选的策略更新能力。
Click to show internal directories.
Click to hide internal directories.