Create relations
Once you've created your relation definitions, you can start creating relations between resources and targets. Then, you can finally add the access control checks to your application. We'll start with looking at the relevant objects used in creation and checking of relations.
Understanding the Data Types
When creating a relation, we have the FGARelation
type which defines a relation between a resource and a target.
When checking to see if a relation exists, one of the options involves the AuthzRelationQuery
type which is used to query the service to see if a given relation exists.
The function that takes this object in will return it with the hasRelation
boolean field set to true or false depending on whether the relation exists or not.
Other functions include the ability to check what relations exist for a given resource or target.
Creating, Updating, and Deleting Relations
Install SDK
Import and initialize Management SDK
Create given relations
The createRelations
function creates a given array of relations.
Delete given relations
The deleteRelations
function deletes a given array of relations.
Delete all relations for given resources
The deleteRelationsForResources
function takes an array of resources and deletes all relations for those resources.
Next
We'll move on to checking relations.