ASP.NET Core JWT Authentication and role-based authorization

  Рет қаралды 14,970

Julio Casal

Julio Casal

Күн бұрын

💻Get the source code: go.dotnetacade...
A solid REST API should make sure that its resources are protected so that only authorized users and clients can get access to them. And thanks to the latest innovations in ASP.NET Core, protecting your Web API could not be easier.
Here I'll show you how to protect your ASP.NET Core Web API in just a few steps.
Topics covered:
00:28 Understanding Token-Based Authentication
01:56 Creating a simple minimal API
08:13 Using JWT authentication and requiring authorization
13:02 Generating tokens with dotnet user-jwts
14:50 Understanding Json Web Tokens (JWT)
21:42 Implementing role based authorization
24:43 Extracting user information via ClaimsPrincipal
33:03 Evaluating user claims
🔥Become a Senior C# Backend Engineer: juliocasal.com...
🗺️Get My Free .NET Backend Developer Roadmap: juliocasal.com...
Join me on Patreon: / juliocasal
Follow me on LinkedIn: / juliocasal
Follow me on X: x.com/julioc
#dotnet #aspnetcore #aspnet

Пікірлер: 28
@damianjankov3343
@damianjankov3343 Ай бұрын
Finally a video where I understood the concept! Thanks
@juliocasal
@juliocasal Ай бұрын
Glad it helped!
@vinaysoni4363
@vinaysoni4363 Жыл бұрын
This is the amazing explanation regarding Api authentication and authorisation process along with real action demonstration. I really appreciate your efforts to make this concept easy to understand and digest. ❤️
@juliocasal
@juliocasal Жыл бұрын
Glad it was helpful, Vinay!
@Kibinas
@Kibinas 11 ай бұрын
Great tutorial, I appreciate simplicity and you deliver quality content without any cumbersome code
@juliocasal
@juliocasal 11 ай бұрын
Glad you like it!
@praveenverma7470
@praveenverma7470 2 ай бұрын
Great tutorial, learned a new way to test the API without switching to postman, swagger or using curl. 🙂
@juliocasal
@juliocasal 2 ай бұрын
Great to hear!
@rohitnaiksawal6925
@rohitnaiksawal6925 3 ай бұрын
You are simply Awesome Julio! Thank you for your efforts....
@juliocasal
@juliocasal 3 ай бұрын
My pleasure!
@EldonElledge
@EldonElledge Жыл бұрын
This was very well done and great content. I would like to call out that, it is best practice to use a Reference Token for communicating from the UI to an API, in place of a jwt token. Jwt tokens are still a valid choice to use between services.
@juliocasal
@juliocasal Жыл бұрын
Great tip Eldon!
@abdurrehman-bx1yo
@abdurrehman-bx1yo 9 ай бұрын
Thanks, very much helpful 👌
@juliocasal
@juliocasal 9 ай бұрын
Glad it helped!
@messenja2547
@messenja2547 Жыл бұрын
Love ur explanation Julio, thanks for sharing
@juliocasal
@juliocasal Жыл бұрын
My pleasure!
@testtest-c4z
@testtest-c4z Жыл бұрын
What is the difference between Claim and Signature? what does each one reference?
@juliocasal
@juliocasal Жыл бұрын
Claims are the pieces of information being asserted about a subject (the user, typically). The signature is used to verify that the sender of the JWT is who it says it is and to ensure that the message wasn't changed along the way.
@abdurrehman-bx1yo
@abdurrehman-bx1yo 7 ай бұрын
Hi, I Have a question. If we do not want to call RequireAuthorization on a endpoint (I just want the user to be authenticated for a specific endpoint and no other things needed like role etc.), it's not even validating the token. I mean, if token is not there it still returns result. What is happening here, could you please explain.
@juliocasal
@juliocasal 7 ай бұрын
Without the RequireAuthorization call you basically have an anonymous endpoint. Call RequireAuthorization with no parameters instead.
@sidisidahmed755
@sidisidahmed755 Жыл бұрын
Thank you
@flash7919
@flash7919 2 ай бұрын
Thank you for this great tutorial How I can generate a code and make register page and login
@juliocasal
@juliocasal 2 ай бұрын
dotnet new blazor -au Individual
@flash7919
@flash7919 2 ай бұрын
@@juliocasal I wanna make a webapi and for front-end I wanna use reactjs how I can make this mix
@awaisshabir9169
@awaisshabir9169 Жыл бұрын
Great content
@juliocasal
@juliocasal Жыл бұрын
Glad you think so!
@geraldsonperez6287
@geraldsonperez6287 Жыл бұрын
How would I generate token for the users of my API with this package?
@juliocasal
@juliocasal Жыл бұрын
Geraldson, generating tokens for real users involves introducing an identity provider, either built by yourself or already built for you. I cover that in my .NET microservices program, here: dotnetmicroservices.com/building-microservices-with-dotnet
ASP.NET Core Exception Handling Tutorial | .NET 8
20:21
Julio Casal
Рет қаралды 13 М.
Как мы играем в игры 😂
00:20
МЯТНАЯ ФАНТА
Рет қаралды 2,8 МЛН
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 50 МЛН
ASP.NET Core Logging Crash Course
30:36
Julio Casal
Рет қаралды 6 М.
Creating .Net Core Microservices using Clean Architecture
26:02
Rahul Sahay
Рет қаралды 20 М.
Master Claims Transformation for Flexible JWT Auth in ASP.NET Core
14:10
Milan Jovanović
Рет қаралды 12 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 189 М.
Secure a .NET Core API with Bearer Authentication
1:06:56
Les Jackson
Рет қаралды 190 М.