Documentation ¶
Index ¶
- Constants
- Variables
- func Register(mux Router, backend Backend, opt *Options)
- type Backend
- type Handler
- type Op
- type Options
- type Permission
- type RBAC
- func (rbac *RBAC) Errors() []error
- func (rbac *RBAC) IsGranted(ctx context.Context, subject Subject, policy _CheckPolicy, perms ...string) error
- func (rbac *RBAC) IsGrantedAll(ctx context.Context, subject Subject, perms ...string) error
- func (rbac *RBAC) IsGrantedAny(ctx context.Context, subject Subject, perms ...string) error
- func (rbac *RBAC) Load(ctx context.Context)
- func (rbac *RBAC) MustGrantedAll(ctx context.Context, subject Subject, perms ...string)
- func (rbac *RBAC) MustGrantedAny(ctx context.Context, subject Subject, perms ...string)
- func (rbac *RBAC) RoleConflict(ctx context.Context, roleIDs []uint32) []error
- func (rbac *RBAC) RolePermissions(ctx context.Context, role string) []Permission
- func (rbac *RBAC) Warnings() []string
- type Request
- type Role
- type Router
- type Subject
Constants ¶
View Source
const ( PolicyAll = _CheckPolicy(iota) PolicyAny )
Variables ¶
View Source
var ( PermApiLogin = perm("rbac.api.login") PermApiWrite = perm("rbac.api.write") PermApiRead = perm("rbac.api.read") )
View Source
var ErrPermissionDenied = errors.New("rbac: permission denied")
Functions ¶
Types ¶
type Backend ¶ added in v0.0.2
type Backend interface { GetAllPermissions(ctx context.Context) []Permission GetAllRoles(ctx context.Context) []Role GetSubjectRoleIDs(ctx context.Context, subject Subject) []uint32 NewPermission(ctx context.Context, name string) error DelPermission(ctx context.Context, name string) error NewRole(ctx context.Context, name string) error DelRole(ctx context.Context, name string) error RoleAddPermission(ctx context.Context, role, perm string) error RoleDelPermission(ctx context.Context, role, perms string) error RoleAddSuper(ctx context.Context, role, super string) error RoleDelSuper(ctx context.Context, role, super string) error RoleAddWildcard(ctx context.Context, role, wildcard string) error RoleDelWildcard(ctx context.Context, role, wildcard string) error RoleAddConflict(ctx context.Context, role, conflict string) error RoleDelConflict(ctx context.Context, role, conflict string) error SubjectAddRole(ctx context.Context, sid int64, role string) error SubjectDelRole(ctx context.Context, sid int64, role string) error }
type Handler ¶
type Handler func(w http.ResponseWriter, req Request)
type Options ¶
type Options struct { PathPrefix string ErrorHandler func(w http.ResponseWriter, r Request, v interface{}) }
type Permission ¶ added in v0.0.2
type Permission interface {
// contains filtered or unexported methods
}
type RBAC ¶
func (*RBAC) IsGrantedAll ¶
func (*RBAC) IsGrantedAny ¶
func (*RBAC) MustGrantedAll ¶
func (*RBAC) MustGrantedAny ¶
func (*RBAC) RoleConflict ¶
func (*RBAC) RolePermissions ¶
func (rbac *RBAC) RolePermissions(ctx context.Context, role string) []Permission
Click to show internal directories.
Click to hide internal directories.