
RBAC Example 1: Use Get Record
Now, let’s set up an API endpoint that GETs all users but only if the user trying to call the endpoint has a role of admin. Take note of the endpoint below, user authentication is required. Additionally, take note of the Function Stack:- Get Record from user: This will use the authToken to find the user’s ID and look up their information.
- Precondition: This will enforce that the user’s role is equal to admin. If it is not, then it will throw and error and stop the endpoint.
- Query all records from user: This will only be performed if the user’s role is an admin by passing the precondition.




RBAC Example 2: Use Extras
Extras allow you to store data within the authentication token, which you can access and use on authenticated API endpoints. First, you must set up the sign-up & login to include the user’s role at the time of authentication. In this example, we will use the login endpoint to pass the user’s role into extras of the auth token at the time of authentication.

