# Multi-Tenant Authorization

**URL:** <https://community.auth0.com/t/multi-tenant-authorization/40030>\
**Category:** Get Help\
**Tags:** multi-tenant, jwt, authorization, permissions\
**Created:** [March 26, 2020, 10:26pm UTC](https://community.auth0.com/t/multi-tenant-authorization/40030 "2020-03-26T22:26:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhouse153](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jhouse153/32/19630_2.png) [@jhouse153](https://community.auth0.com/u/jhouse153)\
**Post date:** [March 26, 2020, 10:26pm UTC](https://community.auth0.com/t/multi-tenant-authorization/40030/1 "2020-03-26T22:26:48Z")

</div>

I’m following up to a previous post [http://community.auth0.com/t/help-with-multi-tenant-spa-rest-application/38893](http://community.auth0.com/t/help-with-multi-tenant-spa-rest-application/38893)

I believe I have Option C working. But I have a follow up question regarding permissions. Please see this image to help me describe:

[![Imgur](https://global.discourse-cdn.com/auth0/original/3X/a/3/a3eb1c37541dc16c62659c79b2e1c26e9b5e8618.png "imgur.com") ](https://imgur.com/s8OtNpz)

My question is basically, once I have the tenant(s) as permissions in the JWT, how do I know in the express API that the user is authorized to perform CRUD operations on one of those tenants?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 30, 2020, 5:48pm UTC](https://community.auth0.com/t/multi-tenant-authorization/40030/3 "2020-03-30T17:48:06Z")

</div>

Hi @jhouse153,

The `sub` claim in the access token contains the user id.

You could use RBAC to assign the user roles based on organization and permissions (like a user and an admin role). Would that work in your scenario?

> **[Role-Based Access Control](https://auth0.com/docs/manage-users/access-control/rbac)**
>
> Understand the concept of role-based access control and how it applies in Auth0.

---

<div class="post-metadata">

**Author:** ![jhouse153](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jhouse153/32/19630_2.png) [@jhouse153](https://community.auth0.com/u/jhouse153)\
**Post date:** [April 8, 2020, 3:44am UTC](https://community.auth0.com/t/multi-tenant-authorization/40030/4 "2020-04-08T03:44:57Z")

</div>

Right, I have RBAC enabled, and that seems to be working fine. But in the API, how do I check that the organization ID in the request is in the users permissions?

I’m looking for something like this:

```
    const orgID = req.query.org_id; //gets organization ID in the request
    if(jwtAuthz([orgID]) === false){ // uses jwtAuthz to make sure the org ID is in their permission list
        return 401; // if it's not, return unauthorized. 
    }

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 8, 2020, 10:11pm UTC](https://community.auth0.com/t/multi-tenant-authorization/40030/5 "2020-04-08T22:11:36Z")

</div>

@mathiasconradt might be able to help here.

---

<div class="post-metadata">

**Author:** ![jhouse153](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jhouse153/32/19630_2.png) [@jhouse153](https://community.auth0.com/u/jhouse153)\
**Post date:** [April 9, 2020, 7:38pm UTC](https://community.auth0.com/t/multi-tenant-authorization/40030/6 "2020-04-09T19:38:02Z")

</div>

Great. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![juliesmi266](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/juliesmi266/32/13081_2.png) [@juliesmi266](https://community.auth0.com/u/juliesmi266)\
**Post date:** [April 13, 2020, 3:22pm UTC](https://community.auth0.com/t/multi-tenant-authorization/40030/7 "2020-04-13T15:22:45Z")

</div>

Thank you for posting something like this [mcdvoice](https://www.mcdvoice.one/)

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 13, 2020, 10:18pm UTC](https://community.auth0.com/t/multi-tenant-authorization/40030/8 "2020-07-13T22:18:05Z")

</div>

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