Expand description
Authentication & Authorization
Provides user management, RBAC, and token-based auth for RedDB.
§Roles
admin: Full access (user management, index ops, read, write)write: Read + write dataread: Read-only access
§Auth Methods
- User/Password login -> session token
- API key -> direct auth with assigned role
Modules§
- cert
- Client-certificate authentication (Phase 3.4 PG parity).
- column_
policy_ gate - Column-level IAM policy gate.
- locks
- Advisory locks (PG-compatible
pg_advisory_*family). - middleware
- Auth middleware helpers.
- oauth
- OAuth / OIDC token validation (Phase 3.4 PG parity).
- policies
- IAM-style policy kernel: data model, JSON codec, validator, evaluator, and simulator.
- privileges
- Granular RBAC: per-table/action privileges plus user attributes.
- scope_
cache (tenant, principal, role) → HashSet<CollectionId>visibility cache.- scram
- SCRAM-SHA-256 (RFC 5802 + RFC 7677) primitives.
- store
- AuthStore – manages users, sessions, and API keys in memory.
- vault
- Encrypted vault for auth state persistence.
Structs§
- ApiKey
- A persistent API key bound to a user.
- Auth
Cache - Visible-collections cache. Thread-safe; cheaply cloneable through
an enclosing
Arc. Construction usesDefault::default()so the cache can sit onAuthStorewithout extra plumbing. - Auth
Cache Stats - Hit/miss/invalidate counters surfaced by
AuthCache::stats(). - Auth
Config - Configuration knobs for the auth subsystem.
- Auth
Store - Central in-process authority for auth state.
- Authz
Context - Caller identity threaded through the privilege check.
- Cert
Auth Config - Per-deployment cert-auth policy. Enabled on a per-listener basis (the TLS listeners inject this into their accept loop).
- Cert
Authenticator - Stateless validator. Holds the config + lookup closure; TLS
listeners wrap it in an Arc and call
validateon every accepted connection. - Cert
Identity - Parsed identity extracted from a validated client certificate.
- Column
Access Request - A set of resolved columns from one table-like source.
- Column
Decision - Per-column decision after table inheritance is applied.
- Column
Policy Gate - Thin evaluator wrapper over effective IAM policies.
- Column
Policy Outcome - Full gate result for one projected table source.
- Column
Ref - One resolved table column requested by a query path.
- Decoded
Jwt - Parsed JWT header + payload that the validator consumes. Listeners
wire an actual JWT parser (e.g.
jsonwebtokencrate) and produce this struct; tests build one directly. - Grant
- A single GRANT row.
- Grants
View - Inputs to
check_grant. Decoupled fromAuthStoreso unit tests can construct fixtures without booting a vault. - Jwk
- A single key from the JWKS endpoint. Phase 3.4 keeps the JWK in
pre-parsed form (algorithm-specific byte buffers) so the validator
can delegate verification to any signing library the deployment
chooses (
ring,rsa, etc.) without tying the core module to a crypto dependency. - JwtClaims
- JwtHeader
- OAuth
Config - Configuration for OAuth/OIDC auth. Multiple issuers can be registered in parallel — the validator tries each until one’s signature verification succeeds.
- OAuth
Identity - Identity produced after successful token validation.
- OAuth
Validator - Parsed
Client Cert - Subset of the cert surface the validator consumes. TLS listeners
construct this from their
rustls::Certificatepayload via an ASN.1 parser (x509-parseror similar); we model the fields we actually look at so tests don’t need a real PEM. - Permission
Cache - Compact (resource, action) lookup pre-built from a user’s grants
- Scope
Key - Cache key —
(tenant, principal, role).Nonetenant = platform tenant. - Session
- An ephemeral session created by login.
- User
- A registered user in the RedDB auth system.
- User
Attributes - Per-user account attributes that PG exposes via
ALTER USER. None of these are tied to the underlying password hash — they live alongside theUserrecord so they can be modified without rotating credentials. - UserId
- Composite identity key:
(tenant_id, username).
Enums§
- Action
- SQL action covered by a grant. Mirrors PG’s privilege vocabulary.
- Auth
Error - Errors produced by auth operations.
- Authz
Error - Privilege-check error.
- Cert
Auth Error - Errors raised while validating a client certificate.
- Cert
Identity Mode - How to derive the RedDB username from a client certificate.
- Column
Decision Effect - Grant
Principal - Who the grant applies to.
- OAuth
Error - OAuth
Identity Mode - Resource
- Object the grant covers. Schemas and tables form a hierarchy: a grant
on
Schema("public")implicitly covers every table inpublic. - Role
- Access role within the RedDB authorization model.
Constants§
- DEFAULT_
SCOPE_ TTL - Default TTL for a
visible_collectionscache entry.
Functions§
- check_
grant - Core privilege check. See module docstring for the resolution order.