# Usage of aud claim?

**URL:** <https://community.auth0.com/t/usage-of-aud-claim/57416>\
**Category:** Get Help\
**Created:** [February 5, 2021, 7:18am UTC](https://community.auth0.com/t/usage-of-aud-claim/57416 "2021-02-05T07:18:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![huyennbl](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/huyennbl/32/14067_2.png) [@huyennbl](https://community.auth0.com/u/huyennbl)\
**Post date:** [February 5, 2021, 7:18am UTC](https://community.auth0.com/t/usage-of-aud-claim/57416/1 "2021-02-05T07:18:19Z")

</div>

Hi, I would like to ask about how people use aud claim. It’s a bit vague to me. I’m using it like this, could you please this is a correct way to do it?

Suppose that:  
I’m having 2 frontend apps, admin portal, and user portal.  
I’m having server to do login function, that will handle login, then sign a jwt token, send it back to browser. \<1\>

I’m having an api gateway that will handle requests from browser, including jwt created by \<1\>. After validation, this gateway decide whether to route the request to **admin** (e.g. [admin.foo.com](http://admin.foo.com)) system or to a **user** (e.g. [user.foo.com](http://user.foo.com)) system. \<2\>

I’m using the aud like this:  
During the \<1\> step, I check if the login request comes from a user portal, or admin portal, then put the value of the audience field like **[admin.foo.com](http://admin.foo.com)** and **[user.foo.com](http://user.foo.com)**

During \<2\> I’ll check if the jwt value of **aud** claim then redirect the traffic respectively. The purpose of this usage is to avoid users from user portal to use their valid jwt token to access some admin resources.

Assuming that the system of [admin.foo.com](http://admin.foo.com) and [user.foo.com](http://user.foo.com) don’t have additional authorization layer, can I do as above?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [February 5, 2021, 4:18pm UTC](https://community.auth0.com/t/usage-of-aud-claim/57416/3 "2021-02-05T16:18:47Z")

</div>

Hi @huyennbl,

According to the [JWT spec](https://tools.ietf.org/html/rfc7519#section-4.1.3), the use of `aud` refers to the recipient of the Access Token. When following the [OAuth 2.0 protocol,](https://auth0.com/docs/protocols/protocol-oauth2) this would be the resource server (your API in this case).

The spec also states that the interpretation of `aud` is application-specific, so I believe your flow follows the general use of the claim:

> [4.1.3](https://tools.ietf.org/html/rfc7519#section-4.1.3). “aud” (Audience) Claim  
> The “aud” (audience) claim identifies the recipients that the JWT is intended for. Each principal intended to process the JWT MUST identify itself with a value in the audience claim. If the principal processing the claim does not identify itself with a value in the “aud” claim when this claim is present, then the JWT MUST be rejected. … The interpretation of audience values is generally application specific…

I think it’s more common to follow [role-based access control (RBAC)](https://auth0.com/docs/authorization/rbac) for authorization. RBAC may be more scaleable if you’d like to ever introduce more types of users than “user” and “admin” and there are resources to help you set it up such as [Auth0’s core authorization and the authorization extension](https://auth0.com/docs/authorization/authorization-core-vs-authorization-extension).

However, given that the use of `aud` is application-specific, to my knowledge, there isn’t anything wrong with how you are currently using it.

Hope that helps!

Stephanie

---

<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:** [February 20, 2021, 4:18pm UTC](https://community.auth0.com/t/usage-of-aud-claim/57416/4 "2021-02-20T16:18:53Z")

</div>

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