Fine-grained authorization (FGA) with roles
A common implementation pattern for FGA is permit users access to resources based on the user’s role. For example, an administrator can edit all resources while a member can only view those resources. Consider the following policy in Polar.User
who is an admin
can edit
all Items
. A User
who is
a member
can only view
all Items
.
To learn more about implementing this FGA pattern, check out
our guide on RBAC.
Fine-grained authorization (FGA) with relationships
Often, FGA is implemented based on the relationships between users and resources. For example, a user can edit all resources the user owns, while other users can only view those resources. Consider the following policy in Polar.User
who is the creator
of an Item
can edit. A User
who is a viewer
can only view the Item
.
To learn more about implementing this FGA pattern, check out our guide on
ReBAC.
Fine-grained authorization (FGA) with attributes
FGA can also be implemented to permit users access to resources based on an attribute of the user. For example, any user can view a resource if it is public, while if it is private they cannot. Consider the following policy in Polar.User
can view an Item
if it is_public
. If the Item
is not public, the user cannot.
Attributes that can be leveraged to build permissions can include time based
checks. For example, a user can be entitled to view an item only for a certain
period of time.
Consider the following policy in Polar.
Combining fine-grained authorization (FGA) implementation patterns
These FGA implementation patterns are not exclusive. They can be used in combination to control access to specific resources on roles, relationships, and attributes. For example, a resource that is premium should be able to be viewed by subscribers while unsubscribed users should not. Consider the following policy in Polar.User
to view
an
Item
that is_premium
only if the user has the subscriber
role.
The combination of FGA patterns (RBAC, ReBAC, ABAC) can model complex authorization policies to decide which users can access which resources. However, FGA typically governs access to entire resources, not to individual fields within them. To control access at the field level, see our guide on field-level authorization.
Next Steps
Explore these topics next:- Add facts - learn how to add your authorization data to Oso Cloud.
- Field Level Authorization - learn to control authorization even deeper with permissions on attributes of resources.
- Get started - Learn how to take your first steps learning Oso.