Policy Structure
How Policies Work
When a policy is created:Policy Created
A policy record is stored in Frontier’s database with role, principal, and resource information
Role Binding in SpiceDB
Frontier creates a
app/rolebinding object in SpiceDB with three key relationsPermission Graph Built
SpiceDB constructs a permission graph connecting the user to permissions via the role
SpiceDB Relations Created
For each policy, three relations are established:Example: John as Organization Owner
User → RoleBinding → Role → Permissions
Group Policies
When binding a role to a group, the subject includes a sub-relation:engineering group automatically receive the role’s permissions.
Policy Usage with Check API
After creating policies, use the Check API to verify permissions.Basic Permission Check
How the Check Works
Extract Principal
Frontier extracts user credentials from:
- Session cookies (if logged in)
Authorizationheader (Basic auth with client ID/secret)- Access token
Parse Resource
The resource string is parsed into namespace and ID:
compute/instance:92f69c3a-334b-4f25-90b8-4d4f3be6b825- Namespace:
compute/instance - ID:
92f69c3a-334b-4f25-90b8-4d4f3be6b825
Graph Traversal
SpiceDB traverses the permission graph:
- Find role bindings where user is bearer
- Check if role has the requested permission
- Verify role binding is granted on the resource
Resource Formats
The Check API accepts flexible resource formats:- Full Namespace
- Alias
- UUID
- Custom Resource
Managing Policies via API
Create Policy
Assign a role to a user on a resource:The
roleId can be either the role UUID or role name (e.g., app_organization_manager). Frontier automatically resolves names to IDs.List Policies
Retrieve policies for a resource:Delete Policy
Revoke a role assignment:- Removes the policy record from Frontier
- Deletes the
app/rolebindingrelations from SpiceDB - Immediately revokes the user’s access
Policy Internals
Understanding how policies work under the hood:Policy Creation Process
Group Policy Sub-Relations
When the principal is a group:Hierarchical Role Based Access Control
Frontier implements hierarchical RBAC where permissions cascade through organizational structures.Organization-Level Policies
Granting a role at the organization level provides access to:- The organization itself
- All projects within the organization
- All groups within the organization
- Resources in those projects
This is implemented via synthetic permissions in the SpiceDB schema (e.g.,
project_get, group_update).Example Hierarchy
app_organization_owner on ACME Corp can:
- Manage the organization
- Access all projects (Backend API, Frontend)
- Manage all resources in those projects
Real-World Policy Examples
Example 1: Organization Manager
Grant organization management access:Example 2: Project Viewer
Grant read-only project access:Example 3: Custom Role Policy
Assign a custom shopping cart manager role:potato_cart_update, potato_cart_get, and potato_cart_delete permissions.
Example 4: Group-Based Access
Grant access to all engineering team members:Policy Filtering and Listing
Retrieve policies with filters:Best Practices
Grant Least Privilege
Grant Least Privilege
Assign the minimum role necessary for users to perform their tasks. Use viewer roles for read-only access, manager roles for operational tasks, and owner roles sparingly.
Use Groups for Team Access
Use Groups for Team Access
Instead of creating individual policies for each team member, create a group and assign the role to the group. This simplifies management and ensures consistency.
Leverage Hierarchical Permissions
Leverage Hierarchical Permissions
Grant roles at the organization level when users need broad access, and at project/resource level for targeted permissions.
Regular Access Reviews
Regular Access Reviews
Periodically audit policies to ensure users still need their assigned roles. Remove policies for departed team members or changed responsibilities.
Use Service Accounts for Applications
Use Service Accounts for Applications
Create service users and assign roles via policies for application-to-application authorization rather than using user credentials.
Document Custom Policies
Document Custom Policies
Add metadata to policies explaining why specific access was granted, especially for custom roles or unusual assignments.
Next Steps
Examples
Explore real-world authorization patterns and use cases
API Reference
View complete API documentation for policy management