Skip to main content

Crate adminx_rbac

Crate adminx_rbac 

Source

Structs§

Ability
Grants for a single role. Build with Ability::role then chain can*.
DbAuthorizer
The registered authorization backend. Cheap to clone — the cache is shared (Arc), so the instance handed to set_authorizer and the one kept for reload see the same data.
PermissionResource
Editable adminx_permissions rows: one grant = (role, resource, action).
RoleResource
Editable adminx_roles metadata (name + description). Not consulted by the can check, so no cache reload is needed on write.

Constants§

ANY_RESOURCE
Wildcard resource: a grant on "*" applies to every resource.
MANAGE
Wildcard action: a grant of "manage" applies to every action on its resource.

Functions§

init
Seed the abilities into the DB if the permission table is empty, load all grants into the cache, and register the authorizer with adminx-core. Call after storage is set (and, on SQL, after running migrate_sql).
migrate_sql
SQL CREATE TABLE IF NOT EXISTS statements for the RBAC tables. Run once on a SQL backend via adminx_core::seed(adminx_rbac::migrate_sql()). Mongo needs nothing (collections auto-create). See schema for the dialect note.
register_resources
Register the in-panel editors for roles and permissions (admin-only). Optional — omit it if you manage grants only in code/SQL.
reload
Re-read grants from the database into the cache. Called automatically after a permission edit via the panel; also available for programmatic edits. A no-op if init was never called.