FaunaDB RBAC and External Identity Providers: Secret Key Rotation Logic
0 reputation · 30 Mar 2020, 08:14 UTC
0 reputation · 30 Mar 2020, 08:14 UTC
FaunaDB implements a granular Role-Based Access Control (RBAC) system where secret keys are mapped to specific roles to enforce least-privilege access. While roles can be modified in real-time to update permissions across all associated keys, the platform does not natively provide a time-to-live (TTL) or expiration timestamp for these secret keys.
When integrating FaunaDB into an architecture that requires short-lived credentials—such as those issued by an external identity provider or a secrets manager—the responsibility for key expiration and rotation falls on the external orchestrator.
There is uncertainty regarding the most efficient method to synchronize external credential expiration with FaunaDB's permanent key model without creating an excessive number of orphaned keys or roles.
Recommended pattern: Create a dedicated FaunaDB key for each external session, persist the key's id (not the secret) in your session store alongside the external session identifier, and run a scheduled job that calls the Admin API DELETE /keys/{key_id} when the external session expires or is revoked.
Bulk revocation: FaunaDB's Admin API does not expose a single bulk-delete endpoint for keys. You must iterate the list of key IDs you want to revoke and issue individual delete requests, or use a client library that batches the underlying HTTP calls.
FaunaDB keys have no native TTL or expiration field. The only revocation mechanism is the Admin API delete operation, which requires the key's internal id. Because keys are immutable once created, rotating credentials means creating a new key and deleting the old one.
Mapping each external session to its own FaunaDB key keeps the blast radius small: if a session is compromised, only that one key needs revocation. Storing the key id (not the secret) in your session store lets you revoke without ever handling the secret again.
POST /keys with a role that grants the minimal privileges needed for that session. Capture the returned id and secret.id in your session store keyed by the external session ID. Deliver only the secret to the client (or exchange it for a short-lived token in your own layer).id and call DELETE /keys/{key_id}.GET /keys), cross-references with your session store, and deletes any keys whose external session no longer exists.external-session) to all short-lived keys so the reconciliation job can filter with ?role=external-session.# List keys for a role
curl -H "Authorization: Bearer $ADMIN_KEY" \
"https://db.fauna.com/admin/keys?role=external-session"
# Delete a specific key
curl -X DELETE -H "Authorization: Bearer $ADMIN_KEY" \
"https://db.fauna.com/admin/keys/$KEY_ID"
# Confirm deletion
curl -H "Authorization: Bearer $ADMIN_KEY" \
"https://db.fauna.com/admin/keys/$KEY_ID"
# Expect 404
What is the expected peak sessions-per-minute? This determines whether per-session keys are viable or if you need a token-exchange layer to reduce Admin API write volume.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.