Documentation
¶
Index ¶
- type Manager
- func (r *Manager) AddRoleForUser(user, role string) (bool, error)
- func (r *Manager) AssignUserRole(userID int, roleType ...Role) error
- func (r *Manager) DeleteRoleForUser(user, role string) (bool, error)
- func (r *Manager) Enforce(sub, obj, act string) (bool, error)
- func (r *Manager) GetRolesForUser(user string) ([]string, error)
- func (r *Manager) HasRoleForUser(user, role string) (bool, error)
- type Role
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager represents the role-based access control manager
func NewManager ¶
NewManager creates a new RBAC manager It initializes the Casbin enforcer with a model and a policy file. The model defines the structure of the policy, and the policy file contains the actual rules.
Example usage:
policyFile := "pkg/rbac/policy_example.csv"
func (*Manager) AddRoleForUser ¶
AddRoleForUser adds a role for a user
func (*Manager) AssignUserRole ¶
AssignUserRole assigns a role to a user based on the role type It should be called after the user login or signup Usually on login, so when the database is changes, the next login user can get the new role
func (*Manager) DeleteRoleForUser ¶
DeleteRoleForUser removes a role from a user
func (*Manager) GetRolesForUser ¶
GetRolesForUser gets roles for a user
Click to show internal directories.
Click to hide internal directories.