iet-auth-rbac-timescale
Persists roles, permissions, and assignments for RBAC policy.
iet-auth-rbac-timescaleimplementationTimescaleDB role storeHow to use it
Owns fw_auth_roles, fw_auth_permissions, and fw_auth_role_assignments and implements
iet_authz::RoleStore. Register it after the identity table, then attach an optional profile
policy with with_profiles(...) so a disabled persona stops granting permissions.
// examples/htmx-starter/servers/web/tests/framework_live_generated.rs
use RoleStore as _;
// Registration (framework_auth_common/mod.rs): identity first, then the capability.
let mut registry = default;
register?;
register?;
let roles = new;
let profiled_roles = roles.clone.with_profiles;
let allowed = profiled_roles.allows.await?;
- Assignments are keyed by
(subject, profile, role); the empty profile covers identity-only principals. - Disabling a role, or a profile, immediately denies (
allowsreturnsfalse), not an error.
How it works
RoleStore::allows checks the attached ProfileStore policy, then runs one repository::allows query that joins fw_auth_role_assignments through fw_auth_roles and fw_auth_permissions, requiring an enabled fw_auth_identities row; it re-checks the policy before returning.
flowchart LR Call["RoleStore allows"] --> Policy["profile_enabled"] Policy --> Store["ProfileStore"] Policy --> Repo["repository allows"] Repo --> Assign["fw_auth_role_assignments"] Repo --> Roles["fw_auth_roles"] Repo --> Perm["fw_auth_permissions"] Repo --> Id["fw_auth_identities"]
What it implements
- Implements
iet_authz::RoleStorefromiet-authz. - Implements
iet_auth::ProfileStore (policy)fromiet-auth.
Database schema
fw_auth_rolesentity Role · hard deleteroleStringenabledboolfw_auth_permissionsentity Permission · hard deleteroleStringpermissionStringfw_auth_role_assignmentsentity RoleAssignment · hard deletesubjectuuid::UuidprofileStringroleStringThe details below come from #[derive(Persistent)] entity metadata:
fw_auth_roles
Entity Role (hard delete).
| Column | Rust type | Attributes |
|---|---|---|
role | String | primary key |
enabled | bool |
fw_auth_permissions
Entity Permission (hard delete).
| Column | Rust type | Attributes |
|---|---|---|
role | String | primary key |
permission | String | primary key |
Foreign key auth_permission_role: (role) → fw_auth_roles (role)
fw_auth_role_assignments
Entity RoleAssignment (hard delete).
| Column | Rust type | Attributes |
|---|---|---|
subject | uuid::Uuid | primary key |
profile | String | primary key |
role | String | primary key |
Foreign key auth_assignment_subject: (subject) → fw_auth_identities (id)
Foreign key auth_assignment_role: (role) → fw_auth_roles (role)
Entities register into an EntityRegistry; EntityRegistry::initial
emits a reviewed migration pair, and Migrations applies reviewed files.
See iet-db-timescale and
iet-db.
What's inside
Modules
src/entity.rssrc/lib.rssrc/repository.rssrc/stores.rs
Public API
(root)
pub fn register(registry: &mut EntityRegistry) -> AppResult<()>— Register only RBAC tables; register the shared identity table separately.
entity
- struct
Role - struct
Permission - struct
RoleAssignment
stores
- struct
RoleStore pub fn new(database: TimescaleDatabase) -> Selfpub fn with_profiles<Q: ProfileStore>(self, profiles: Q) -> RoleStore<Q>
Impl map
iet_authz::RoleStore for RoleStore<P>
Depends on
External crates: sqlx, uuid
Used by
- No other framework crate depends on it directly.
In this repository
examples/htmx-starter
Source: crates/integrations/iet-auth-rbac-timescale