Documentation
¶
Index ¶
- Constants
- func IsSelfAssignableRole(role string) bool
- func NormalizeRole(raw string) (string, bool)
- func NormalizeRoleOrDefault(raw string) string
- func NormalizeSelfAssignableRoles(rawRoles []string) ([]string, error)
- type CasbinAuthorizer
- func NewCasbinAuthorizer(db *gorm.DB, defaultRole string, adminIdentityIDs []string) (*CasbinAuthorizer, error)
- func NewCasbinAuthorizerWithOptions(db *gorm.DB, opts Options) (*CasbinAuthorizer, error)
- func NewCasbinAuthorizerWithPolicies(db *gorm.DB, defaultRole string, adminIdentityIDs []string, policies []Policy) (*CasbinAuthorizer, error)
- func (a *CasbinAuthorizer) AddUserRole(_ context.Context, userID, role string) error
- func (a *CasbinAuthorizer) Can(_ context.Context, userID, dom, obj, act string) (bool, error)
- func (a *CasbinAuthorizer) EnsureDefaultRole(_ context.Context, userID string) (string, error)
- func (a *CasbinAuthorizer) GetUserRoles(ctx context.Context, userID string) ([]string, error)
- func (a *CasbinAuthorizer) HasUserRole(_ context.Context, userID, role string) (bool, error)
- func (a *CasbinAuthorizer) SetUserSelfSelectedRoles(_ context.Context, userID string, rawRoles []string) ([]string, error)
- type DomainAccessFunc
- type Options
- type Policy
- type RoleNormalizer
- type SelfAssignableRoleChecker
- type SelfAssignableRolesNormalizer
Constants ¶
View Source
const ( RoleUser = "user" RoleAdmin = "admin" )
Variables ¶
This section is empty.
Functions ¶
func IsSelfAssignableRole ¶
func NormalizeRole ¶
func NormalizeRoleOrDefault ¶
Types ¶
type CasbinAuthorizer ¶
type CasbinAuthorizer struct {
// contains filtered or unexported fields
}
func NewCasbinAuthorizer ¶
func NewCasbinAuthorizerWithOptions ¶
func NewCasbinAuthorizerWithOptions(db *gorm.DB, opts Options) (*CasbinAuthorizer, error)
NewCasbinAuthorizerWithOptions allows applications to provide domain ownership checks. Without a resolver, only the global "*" domain is allowed.
func NewCasbinAuthorizerWithPolicies ¶
func NewCasbinAuthorizerWithPolicies(db *gorm.DB, defaultRole string, adminIdentityIDs []string, policies []Policy) (*CasbinAuthorizer, error)
NewCasbinAuthorizerWithPolicies initializes RBAC with framework policies and application-owned policies. Policies are idempotently persisted by Casbin.
func (*CasbinAuthorizer) AddUserRole ¶
func (a *CasbinAuthorizer) AddUserRole(_ context.Context, userID, role string) error
func (*CasbinAuthorizer) EnsureDefaultRole ¶
func (*CasbinAuthorizer) GetUserRoles ¶
func (*CasbinAuthorizer) HasUserRole ¶
func (*CasbinAuthorizer) SetUserSelfSelectedRoles ¶
type DomainAccessFunc ¶
type Options ¶
type Options struct {
DefaultRole string
AdminIdentityIDs []string
Policies []Policy
DomainAccess DomainAccessFunc
NormalizeRole RoleNormalizer
NormalizeSelfAssignableRoles SelfAssignableRolesNormalizer
IsSelfAssignableRole SelfAssignableRoleChecker
RoleOrder []string
}
type RoleNormalizer ¶ added in v0.7.1
type SelfAssignableRoleChecker ¶ added in v0.7.1
type SelfAssignableRolesNormalizer ¶ added in v0.7.1
Click to show internal directories.
Click to hide internal directories.