Before you start
To better understand this guide, you should be familiar with some Auth0 FGA Concepts and know how to develop the things listed below.What are direct relationships?
Direct relationships are relationships where a user has a relationship to an object that is not dependent on any other relationship they have with that object. When checking for a relationship, a direct relationship exists if a relationship tuple is present in the system with the exact same object and relation that were in the query and where the user is one of:- the same user ID as that in the query
- type bound public access (
<type>:*) - a set of users that contains the user ID present in the query
Enable or disable direct relationships
Direct relationships can be enabled for a specific relation on an object type by adding direct relationship type restrictions from that relation’s definition. Likewise, they can be disabled by removing the direct relationship type restrictions.The authorization model describes two object types:
document and team.The document type definition has two relations, editor and viewer. Both relations allow a direct relationship; viewer also allows an indirect relationship through editor.In the team type definition, there is a single member relation that only allows direct relationships.How it affects your system
To illustrate the effect enabling or disabling direct relationships on a specific relation has, we’ll investigate several situations.1. With direct relationships enabled
Let us start with the authorization model we had above: Now choose the type of relation to see how it affects your system:- Direct User
- Type Bound Public Access
- Userset
- Indirect Relationship
Assume you have a tuple that states that Anne is a Now if we do a check request to see if Anne can view the planning document, we will get a response of
viewer of document:planning{"allowed": true}.This is because:- There is a relationship tuple specifying that Anne has a
viewerrelationship withdocument:planning. - Direct relationships are allowed in the
viewerrelation definition in thedocumenttype definition.
2. With direct relationships disabled
In this section, we will investigate the effect of disabling direct relationships on the document’sviewer relation.
Notice that in this updated authorization model, the direct relationship keyword has been removed from the document’s
viewer relation definition.- Direct User
- Everyone
- Userset
- Indirect Relationship
Assume you have a tuple that states that Fred is a Now if we do a check request to see if Fred can view the planning document, we will get a response of
viewer of document:planning{"allowed": false}.This is because:- Even though there is a relationship tuple specifying that Fred has a
viewerrelationship withdocument:planning. - Direct relationships are NOT allowed in the
viewerrelation definition in thedocumenttype definition.