# How to "Protect a route based on specific claims" for "Standard Web Application" (NodeJS/Express) and

**URL:** <https://community.auth0.com/t/how-to-protect-a-route-based-on-specific-claims-for-standard-web-application-nodejs-express-and/75582>\
**Category:** Get Help\
**Tags:** rbac, roles, auth0\
**Created:** [December 29, 2021, 12:16pm UTC](https://community.auth0.com/t/how-to-protect-a-route-based-on-specific-claims-for-standard-web-application-nodejs-express-and/75582 "2021-12-29T12:16:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![uscheidegger](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/uscheidegger/32/34065_2.png) [@uscheidegger](https://community.auth0.com/u/uscheidegger)\
**Post date:** [December 29, 2021, 12:16pm UTC](https://community.auth0.com/t/how-to-protect-a-route-based-on-specific-claims-for-standard-web-application-nodejs-express-and/75582/1 "2021-12-29T12:16:00Z")

</div>

Hi there

I’m following the [Express Quickstart](https://auth0.com/docs/quickstart/webapp/express/01-login) and the [Auth0 Express Pug tutorial](https://github.com/auth0-blog/auth0-express-pug-sample/blob/main/src/index.js) to protect a **standard web application**. Login / logout works fine.

But now, I need to protect the application further, so that only users with a certain role can access certain routes. I found an [example page](https://github.com/auth0/express-openid-connect/blob/master/EXAMPLES.md#6-protect-a-route-based-on-specific-claims) with some brief info, but checking claims as failed miserably so far. When I examine the user info in `req.oidc.user`, I cannot see any role info, despite the fact that I created a role and assigned it to the user in the Auth0 dashboard.

I did search for this extensively, but have not yet found a good NodeJS/Express example. Instead I’ve seen lots of discussions about “Authorization Core” (which I’m using AFAICT) vs. “Authorization Extension”, APIs and C# 🤣  
In any case, while the standard authentication was actually super simple, the authorization seems to be a lot harder then one would expect. Can someone point me to the pieces I’m missing, a working example, tutorial, documentation? Thanks!

Happy holidays!  
Will

---

<div class="post-metadata">

**Author:** ![uscheidegger](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/uscheidegger/32/34065_2.png) [@uscheidegger](https://community.auth0.com/u/uscheidegger)\
**Post date:** [January 17, 2022, 12:06pm UTC](https://community.auth0.com/t/how-to-protect-a-route-based-on-specific-claims-for-standard-web-application-nodejs-express-and/75582/2 "2022-01-17T12:06:26Z")

</div>

Ok, either my question is super stupid and I’m simply missing the obvious, or this standard use case is too complex of Auth0? In any case I guess I’ll have to solve this myself – without Auth0. 😥

---

<div class="post-metadata">

**Author:** ![lily.wisecarver](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lily.wisecarver/32/20402_2.png) [@lily.wisecarver](https://community.auth0.com/u/lily.wisecarver)\
**Post date:** [March 2, 2022, 4:07am UTC](https://community.auth0.com/t/how-to-protect-a-route-based-on-specific-claims-for-standard-web-application-nodejs-express-and/75582/3 "2022-03-02T04:07:32Z")

</div>

Hi @uscheidegger ,

Sorry for the huge delay. I hope you were able to solve the issue. If not, looks like you are close to the solution. I checked the express example you shared, and it looks like it’s checking the claims for a user. In Auth0, you will have to add those roles in token using rules to receive user permissions in your Access Tokens. Check this example here: [Sample Use Cases: Rules with Authorization](https://auth0.com/docs/manage-users/access-control/sample-use-cases-rules-with-authorization#add-user-roles-to-tokens)  
Then you can map those claims in your express app.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 2, 2022, 3:11pm UTC](https://community.auth0.com/t/how-to-protect-a-route-based-on-specific-claims-for-standard-web-application-nodejs-express-and/75582/4 "2022-03-02T15:11:32Z")

</div>

Kudos @lily.wisecarver for helping on this one!

---

<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:** [March 17, 2022, 3:11pm UTC](https://community.auth0.com/t/how-to-protect-a-route-based-on-specific-claims-for-standard-web-application-nodejs-express-and/75582/5 "2022-03-17T15:11:48Z")

</div>

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