# Correct way to use role base access for API and data

**URL:** <https://community.auth0.com/t/correct-way-to-use-role-base-access-for-api-and-data/115899>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [September 11, 2023, 12:05pm UTC](https://community.auth0.com/t/correct-way-to-use-role-base-access-for-api-and-data/115899 "2023-09-11T12:05:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeebzog](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zeebzog/32/13136_2.png) [@zeebzog](https://community.auth0.com/u/zeebzog)\
**Post date:** [September 11, 2023, 12:05pm UTC](https://community.auth0.com/t/correct-way-to-use-role-base-access-for-api-and-data/115899/1 "2023-09-11T12:05:35Z")

</div>

I have a front end web client which is split into different sections. Some sections available to admin, some available to senior managers etc.  
I also have data which is visible to supervisors but redacted for more junior staff.  
I have set up two APIs one which give access rights to the various sections  
The other that gives viewing rights to certain types of data

I then create roles such as administrator which have a number of these rights (both access and data) assigned to them.

I imagined that I would then have a user login and have details of what claims they have to access the front end and the data in a JWT which would be signed so it could be verified by the relevant APIS.

However I don’t think my understanding is correct. How should I be using Auth0 in this paradigm.

I appreciate this is a long winded question, but roles seem to be a bolt onto the product, and I am not sure of the best way to proceed.

Thank you for any assistance.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 15, 2023, 12:17am UTC](https://community.auth0.com/t/correct-way-to-use-role-base-access-for-api-and-data/115899/3 "2023-09-15T00:17:51Z")

</div>

Hey @zeebzog !

> [@zeebzog](#):
>
> I imagined that I would then have a user login and have details of what claims they have to access the front end and the data in a JWT which would be signed so it could be verified by the relevant APIS.

Your understanding sounds about right to me! There are lots of resources available that go over role-based access control (RBAC) in detail, some of which I’ll add below. Each API you register in Auth0 has an option to “include permissions in access token” - This will automatically include permissions the user has been assigned via a Role as a claim in their access token. There are many libraries/SDKS to achieve this, but at a high level your client application should include the access token as a header in all requests to your API. Your API at this point will validate/verify the access token and subsequently check for specific permissions (Admin, junior, etc.).

The following resources should be helpful 🙂

> **[What is Role-Based Access Control (RBAC) and How to Implement it in a Rails API?](https://auth0.com/blog/what-is-rbac-and-how-to-implement-it-rails-api/)**
>
> There are different ways to implement an authorization system and the one you chose depends on your application's needs. Role-Based Acces...

> **[Single-Page Applications (SPA) with API](https://auth0.com/docs/get-started/architecture-scenarios/spa-api)**
>
> Explains the architecture scenario where a single-page application (SPA) talks to an API using OpenID Connect (OIDC), and the OAuth 2.0 Implicit Grant Flow, to authenticate users with Auth0.

> **[Calling an API](https://auth0.com/docs/videos/learn-identity-series/calling-an-api#wistia_yw6hmdhnft?time=1205)**
>
> How to obtain and use access and refresh tokens for delegated authorization in a traditional web application.

Hope this helps to clarify!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [September 29, 2023, 12:18am UTC](https://community.auth0.com/t/correct-way-to-use-role-base-access-for-api-and-data/115899/4 "2023-09-29T00:18:26Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
