Raxol. RBAC
(Raxol v2.6.0)
View Source
Role-Based Access Control for Raxol.
Provides role definition and permission checking.
Example
Raxol.RBAC.define_role(:admin, [:read_all, :write_all, :delete_all])
Raxol.RBAC.define_role(:user, [:read_own, :write_own])
if Raxol.RBAC.can?(user, :delete_all) do
delete_resource()
end
Summary
Functions
Assign a role to a user.
Check if a user has a specific permission.
Returns a specification to start this module under a supervisor.
Define a role with a list of permissions.
Get all permissions for a user.
Get all roles for a user.
Remove a role from a user.
Start the RBAC agent.
Functions
Assign a role to a user.
Example
Raxol.RBAC.assign_role(user, :admin)
Check if a user has a specific permission.
Example
if Raxol.RBAC.can?(user, :delete_all) do
delete_resource()
end
Returns a specification to start this module under a supervisor.
See Supervisor.
Define a role with a list of permissions.
Example
Raxol.RBAC.define_role(:admin, [:read_all, :write_all, :delete_all])
Get all permissions for a user.
Example
permissions = Raxol.RBAC.get_permissions(user)
Get all roles for a user.
Example
roles = Raxol.RBAC.get_roles(user)
Remove a role from a user.
Example
Raxol.RBAC.remove_role(user, :admin)
Start the RBAC agent.
Usually started automatically by the application supervisor.