Skip to main content

How to perform a check

note
Auth0 Fine Grained Authorization (FGA) is the early-stage product we are building at Auth0 to solve fine-grained authorization at scale. Sign up for the Developer Community Preview to try it out, and join our Discord community if you are interested in learning more about our plans.

Please note that at this point in time, it is not considered production-ready and does not come with any SLAs; availability and uptime are not guaranteed. Limitations of Auth0 FGA during the Developer Community Preview can be found here.

This section will illustrate how to perform a check request to determine whether a user has a certain relationship with an object.

Before you start

  1. You have obtained the environment, store id, client id and client secret.
  2. You have installed the SDK.
  3. You have configured the authorization model and updated the relationship tuples.
  4. You have loaded FGA_ENVIRONMENT, FGA_STORE_ID, FGA_CLIENT_ID and FGA_CLIENT_SECRET as environment variables.

Step by Step

Assume that you want to check whether user anne has relationship reader with object document:Z

01. Configure the Auth0 FGA API client

Before calling the check API, you will need to configure the API client.

// import the SDK
const { Auth0FgaApi } = require('@auth0/fga');

// Initialize the SDK
const fgaClient = new Auth0FgaApi({
environment: process.env.FGA_ENVIRONMENT,
storeId: process.env.FGA_STORE_ID,
clientId: process.env.FGA_CLIENT_ID,
clientSecret: process.env.FGA_CLIENT_SECRET,
});

02. Calling Check API

To check whether user anne has relationship reader with object document:Z


// Run a check
const { allowed } = await fgaClient.check({
tuple_key: {
user: 'anne',
relation: 'reader',
object: 'document:Z',
},});

// allowed = true

The result's allowed field will return true if the relationship exists and false if the relationship does not exist.

Auth0 FGA Check API

Read the Check API documentation and see how it works.

Have Feedback?

Join us on the Discord community if you have any questions or suggestions.