When to useGranting access with relationship tuples is a core part of OpenFGA. Without relationship tuples, any checks will fail. You should use:
- authorization model to represent what relations are possible between the users and objects in the system
- relationship tuples to represent the facts about the relationships between users and objects in your system.
Before you start
Familiarize yourself with OpenFGA Concepts to understand how to develop a relationship tuple and authorization model. Assume that you have the following authorization model.You have a type called
document that can have a viewer and/or an editor.
Step By Step
For an application to understand that user x has access to document y, it must provide OpenFGA that information with relationship tuples. Each relationship tuple has three basic parameters: a user, a relation and an object.01. Create A Relationship Tuple
Below, you’ll add a relationship tuple to indicate thatbob is an editor of document:meeting_notes.doc by adding the following:
02. Check That The Relationship Exists
Once you add that relationship tuple to OpenFGA, you can check if the relationship is valid by asking if bob is an editor of document:meeting_notes.doc: Checking whetherbob is an viewer of document:meeting_notes.doc returns false because that relationship tuple does not exist in OpenFGA yet.
Related Sections
Check the following sections for more on how to model with OpenFGA.OpenFGA Concepts
Learn about the OpenFGA Concepts.
Modeling: Getting Started
Learn about how to get started with modeling.
Configuration Language
Learn about OpenFGA Configuration Language.