NestJS Role Based Authorization | RBAC

In this video we set up Role Based Authorization to guard our end points. We create a custom decorator and guard. Role Based Access Control or RBAC builds up on authentication (previous video) by protecting the routes based on the user type i.e. Admin, Premium, User.
--------------------------------------------------
Recommended Udemy courses
--------------------------------------------------
NestJS - Zero to Hero: tinyurl.com/3rxsz669
Angular - The Complete Guide: tinyurl.com/4h5rmpsj
Understanding TypeScript: tinyurl.com/9wz6fp7k
React - The Complete Guide: tinyurl.com/2t6v5yeu
Docker Mastery (with Kubernetes + Swarm): tinyurl.com/yeymdnhn
Playlist: • LinkedIn Clone - Ionic...
GitHub: github.com/Jon-Peppinck/linke...

Пікірлер: 42

  • @mixxxer
    @mixxxer2 жыл бұрын

    This whole Nest series is absolute gold mate. Fantatstic stuff. Thanks.

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Thanks so much mixxxer! Glad you have been liking it so far. Big fan of NestJS after working with Angular, Java, and Node.

  • @nguyenkien5558
    @nguyenkien5558 Жыл бұрын

    Amazing work! Thank you so much for making this.

  • @JonPeppinck

    @JonPeppinck

    Жыл бұрын

    Thanks so much for watching! Cheers!

  • @hollynderisse645
    @hollynderisse6452 жыл бұрын

    Great tutorial.Thank you for sharing!

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Thanks so much Hollyn - I'm glad it was helpful!

  • @HieuHuynh-xr6kj
    @HieuHuynh-xr6kj2 жыл бұрын

    This video very helpful, from Vietnam with love

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Thank you Hieu! Glad it helped. I've been to Halong Bay before. It was wonderful

  • @aydentait6699
    @aydentait66993 жыл бұрын

    This video got me pumping great stuff!

  • @JonPeppinck

    @JonPeppinck

    3 жыл бұрын

    Thank you very much. I'm glad you are pumping. Pump city!

  • @wol2231
    @wol22312 жыл бұрын

    Thank you for this video. Very clearly explained!

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Awesome! Thanks so much!

  • @mandacor
    @mandacor2 ай бұрын

    thanks a lot bro, so useful

  • @JonPeppinck

    @JonPeppinck

    2 ай бұрын

    Thanks so much for checking it out!

  • @familiaananias
    @familiaananias2 жыл бұрын

    Hello from Brazil, this video is amazing.

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Thanks so much Rodrigo!

  • @nthinh226
    @nthinh226 Жыл бұрын

    It's worked!!! Thank you so much ♥

  • @JonPeppinck

    @JonPeppinck

    Жыл бұрын

    Awesome, nice stuff!

  • @Marco-ef5yk
    @Marco-ef5yk2 жыл бұрын

    Another great video!

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Thanks Marco! You are doing a great job working through the series.

  • @silvanopereira5588
    @silvanopereira55882 жыл бұрын

    Hey, i have been receiving this folow exception: [Nest] 11656 - 16/02/2022 16:36:25 ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'role') can you give a tip about the problem?

  • @christinele5832
    @christinele58322 жыл бұрын

    great !

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Thanks Gia!

  • @tristheflash6928
    @tristheflash69282 жыл бұрын

    you awsome

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Thanks so much tris!

  • @yog207
    @yog2072 жыл бұрын

    superb explanation !! i miss out n one thing , what makes the guard throw 403 forbidden error , as we are not specifying it anywhere :)

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Thank you Yog! I believe it is because the roles guard implements CanActivate, which enforces the canActivate method to be called when we use the guard. From reading through the documentation, it is inferred that there is some code built into NestJS's common library which controls this behaviour. When a user with insufficient privileges requests an endpoint, Nest automatically returns a 403. If you want to return a different error response, you should throw your own specific exception instead of returning a boolean value.

  • @jsdev-sl6mp
    @jsdev-sl6mp5 ай бұрын

    how can this project be deployed?

  • @user-sy5ol1gz7s
    @user-sy5ol1gz7s2 жыл бұрын

    Thanks a lot, it was very helpful for me! One minor remark on 23:49 it can be done more simply. Just use includes directly on requiredRoles array, should be like this requiredRoles.includes(user.role). It will also work.

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    Thanks Tapac. Glad it was helpful. You are right, that is better. Thanks for pointing that out.

  • @saurabhsinha3319
    @saurabhsinha3319 Жыл бұрын

    I'm confused, how to make someone admin?? I logged in using all accounts but none of them are admin, how to make one?

  • @JonPeppinck

    @JonPeppinck

    Жыл бұрын

    Probably easiest to just go to the pg database and change the account type to admin for a particular user.

  • @saurabhsinha3319

    @saurabhsinha3319

    Жыл бұрын

    @@JonPeppinck Thanks so much

  • @andideveloper8345
    @andideveloper8345 Жыл бұрын

    why should we return true if not requiredRoles?

  • @JonPeppinck

    @JonPeppinck

    Жыл бұрын

    18:19

  • @JonPeppinck

    @JonPeppinck

    Жыл бұрын

    The roles guard works in conjunction with the role decorator. If the role annotations are removed by the programmer, it is assumed that you don't want to protect the end point by the role.

  • @andideveloper8345

    @andideveloper8345

    Жыл бұрын

    @@JonPeppinck thank you for your answer, can you do a tutorial implementing middleware + guard + interceptors using best practices, a simple system where a user can login based on roles like: guest,admin,manager and this roles are updated from the main ADMIN.

  • @GamingClubGermany
    @GamingClubGermany2 жыл бұрын

    Please turn your mic arround and speak into the right side xD

  • @JonPeppinck

    @JonPeppinck

    2 жыл бұрын

    I was doing that. I have been meaning to buy a good mic for some time though.

  • @GamingClubGermany

    @GamingClubGermany

    2 жыл бұрын

    @@JonPeppinck oh sounded Like you were speaking in to the wrong Side my appologise :). Sounds exaclty that way thats why haha. What mic do you have?

  • @cali4484
    @cali4484 Жыл бұрын

    previous video : kzread.info/dash/bejne/g6CDxrixnZjAltY.html

  • @cholasimmons
    @cholasimmons10 ай бұрын

    dark mode PLEASE