FaunaDB RBAC: Transitioning from Secret Keys to Role-Based Access Control
0 reputation · 20 Aug 2021, 09:02 UTC
0 reputation · 20 Aug 2021, 09:02 UTC
FaunaDB has evolved its security architecture from legacy Secret keys toward a more granular Role-Based Access Control (RBAC) system. While the current model adheres to a deny-by-default principle, managing access for large-scale schemas requires a precise mapping of tokens to specific roles to prevent accidental public exposure.
As schemas grow in complexity, defining permissions at the collection, index, and document levels can create deeply nested hierarchies. There is uncertainty regarding the most efficient way to maintain these boundaries without introducing overlapping permissions that might inadvertently grant broader access than intended.
What is the recommended strategy for auditing deeply nested RBAC hierarchies to ensure no unintended public access exists? How does the system handle permission conflicts when a token is associated with multiple roles containing overlapping scopes?
To ensure no unintended public access exists in a deeply nested FaunaDB RBAC hierarchy, the recommended strategy is to implement a deny-by-default audit. Because FaunaDB does not provide a built-in "permission simulator" for complex nested roles, auditing requires a systematic verification of the least-privileged token.
To prevent accidental public exposure, follow these verification steps:
Get or Update operation on a collection that should be restricted. A 403 Forbidden response confirms the boundary is intact.FaunaDB handles overlapping scopes through additive permissioning. If a token is associated with multiple roles, the system grants the union of all permissions provided by those roles.
Example Scenario:
| Role A | Role B | Resulting Access |
|---|---|---|
| Read-Only (Collection X) | Write-Only (Collection X) | Read and Write (Collection X) |
| Read (Collection Y) | No Access (Collection Y) | Read (Collection Y) |
Because there is no "explicit deny" that overrides an "allow," a conflict is resolved in favor of the most permissive role. To restrict access, you must remove the permissive role from the token rather than attempting to block it with a more restrictive role.
To verify that a specific token is restricted as intended, use a scoped request via the Fauna Shell or API. If the following returns a permission error, the RBAC boundary is functioning:
// Attempt to read a restricted collection using a limited role token
Get(Collection('restricted_data'))
Missing Diagnostic: Are you utilizing Attribute-Based Access Control (ABAC) within your roles (e.g., using Match to restrict documents to a specific user_id)? This significantly changes the auditing process from collection-level checks to document-level logic verification.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 20 Aug 2021, 20:32 UTC
The additive-union description is accurate, but two practical gaps deserve attention during audits:
Paginate(Roles()) and expanding each role's privileges — flag any entry lacking a specific resource or document predicate, not just entries on sensitive collections.Both checks complement the deny-by-default testing already suggested: one catches stale state, the other catches over-broad grants that per-collection negative tests won't reach.