jajaperson / nestjs-auth0

An example NestJS application that uses Auth0 via Passport for authentication.
MIT License
207 stars 25 forks source link

Using Roles to determine Access #1

Closed crivera closed 4 years ago

crivera commented 5 years ago

Hi

I saw your project and preferred it over using an express middleware as described in other Auth0 tutorials.

I am very new with NestJS but do you know a way of adding a Role to the AuthGuard.

So that I could annotate it like @AuthGuard('ADMIN') and in the JwtStrategy.validate() could check the roles against the passed in role?

Thanks for your project though! Very nice

jajaperson commented 4 years ago

Sorry for the incredibly late reply, I've been busy with other things. I think it would definitely be worth adding an example of role-based authentication to this project, I'll look into it.

jajaperson commented 4 years ago

For now, this tutorial shows how to implement Auth0 role guards in NestJS https://auth0.com/blog/developing-a-secure-api-with-nestjs-adding-role-based-access-control/

jajaperson commented 4 years ago

Unfortunately, I don't have time to do this atm. If anyone wants to add roles to this example, I'll accept a pull request but, for now, I will close this issue.