Secure Your .NET API in 15 Minutes: JWT Authentication Tutorial

  Рет қаралды 28,920

Milan Jovanović

Milan Jovanović

Күн бұрын

Пікірлер: 84
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Do you want to simplify your development process? Grab my free Clean Architecture template here: bit.ly/3Andaly
@BeijoVegan
@BeijoVegan 4 ай бұрын
Can I make a suggestion? Please, use some kind of editing software that zoom in where you click with the mouse. It's very hard to follow your coding on mobile phones.
@19balazs86
@19balazs86 4 ай бұрын
JWT is a nice topic, and I can not wait for the continuation of Keycloak.
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
It's scheduled for next Friday :)
@dobjek
@dobjek Ай бұрын
Thanks!
@MilanJovanovicTech
@MilanJovanovicTech Ай бұрын
Much appreciated!
@pratikpandya2306
@pratikpandya2306 4 ай бұрын
You sound calm now. It’s great content, Keep it up.
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
It varies based on how many coffees I had prior ☕☕
@shanabunny
@shanabunny 4 ай бұрын
I was just about to implement it. Perfect timing thank you.
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Perfect! 😁
@Credi6464
@Credi6464 4 ай бұрын
Pure gold content! Thanks for that!
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Glad it was helpful!
@EzequielRegaldo
@EzequielRegaldo 4 ай бұрын
Awesome, your tutorials are the best !
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Thanks a lot!
@vbachris
@vbachris 4 ай бұрын
2 added bonus material? 1) token refresh 2) in conjunction with EntraID
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Good suggestions for future videos
@iq4u213
@iq4u213 4 ай бұрын
Awesome video ! next video should be about Refresh Token
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Good idea, actually!
@ukgames304d
@ukgames304d 4 ай бұрын
please Milan make a video about implementing refresh token :)
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
All right, all right
@dobjek
@dobjek Ай бұрын
Thanks Milan, excellent tutorial as always! Works as a charm out of box. How about next video of token expriration scenario as well as basic roles support? Coffee tips will be provided ;)
@MilanJovanovicTech
@MilanJovanovicTech Ай бұрын
I'm releasing a video about refresh tokens very soon! And then extending this with some baked in AuthZ support won't be too difficult.
@MarvinKleinMusic
@MarvinKleinMusic Ай бұрын
I really wish you would have showed the concept of refresh tokens here as well
@MilanJovanovicTech
@MilanJovanovicTech Ай бұрын
Have a video coming up on that!
@enricoroselino7557
@enricoroselino7557 4 ай бұрын
great video as always, do you have any tips on implementing role based access control using jwt ? or i shouldnt implement it inside jwt in the first place ?
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
You can add the roles as claims on the JWT, it's pretty simple. You then use these claims to implement an authorization policy.
@davidespada01
@davidespada01 4 ай бұрын
thank you can you show us how to consume the JWT token with validating
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
What do you mean by this?
@EzequielRegaldo
@EzequielRegaldo 4 ай бұрын
When you use Auth required in some route its automatically validated. Library does it for you
@EzequielRegaldo
@EzequielRegaldo 4 ай бұрын
@@MilanJovanovicTech maybe caducation or refreshing
@davidespada01
@davidespada01 4 ай бұрын
@@MilanJovanovicTech sorry i was not clear, i meant if i have an api application that will get jwt from other application and use it for further api calls what if i need to validate that jwt 1st in case it was encrypted Thank you ,, your amazing
@isahirzm
@isahirzm 4 ай бұрын
Great tutorial, when it comes to consume the API, what would be the best practices to do on the consumer(front-end)
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
As in where to store the JWT?
@isahirzm
@isahirzm 4 ай бұрын
@@MilanJovanovicTech yes
@ALOKSHARMAMD
@ALOKSHARMAMD 4 ай бұрын
do you have any videos explaining tools like open telemetry, application insights, grafana etc with dotnet. i have been going through different tools to implement in-app profiler for potential memory leaks handling and its very confusing on what to choose to identify & record basic memory/cpu usage for leaks and exceptions etc. As application insight is Azure specific, and other tools are not so easy to add by top attribute. any suggestions which doesn't rely on cloud deployments?
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Check out the OpenTelemetry video here: kzbin.info/www/bejne/fqO1o31rrLmnms0 You should be able to use the metrics in Aspire to gain some insights
@s.a.h.i1261
@s.a.h.i1261 3 ай бұрын
Would love to see a video on how to protect this system additionally from CSRF attacks
@MilanJovanovicTech
@MilanJovanovicTech 3 ай бұрын
Good suggestion
@abdullahm.3363
@abdullahm.3363 4 ай бұрын
Great video, how to create a refresh token, so the user don't have to login again and again.
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
You can use a similar approach to here. Just store the refresh token in the DB, and give it a longer lifetime. Then expose an endpoint to send the refresh token in exchange for a new access token.
@Mo-ef9yt
@Mo-ef9yt 4 ай бұрын
Thanks​@@MilanJovanovicTech
@WangAndrew
@WangAndrew 4 ай бұрын
how do you validate the jwt token on the client side, if blazor wasm ?
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
I believe you'd need the key to verify the hash, which isn't ideal. But if you just want to parse the content, that's not as hard.
@WangAndrew
@WangAndrew 4 ай бұрын
@@MilanJovanovicTech what if the server side use ‘asymmetric’ then the client side only need the public key not the private key
@agusbudianto4473
@agusbudianto4473 4 ай бұрын
Hi Milan, how to integrate this JWT token with SignInManager in Identitiy Core
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Use SignInManager to verify password, and then generate a JWT and return it
@denisgudiel5574
@denisgudiel5574 4 ай бұрын
Is the Manger user secrets more secure than the appsettings?
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
I didn't quite understand you there
@denisgudiel5574
@denisgudiel5574 4 ай бұрын
@@MilanJovanovicTech is that you use the "Manager user secrets" to save the jwt key
@theeusftn
@theeusftn 4 ай бұрын
can you teach how to make hmac authentication?
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Sure
@asesorwebvideos
@asesorwebvideos 4 ай бұрын
gracias saludos desde CHILE
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Many thanks!
@dhmilmile1
@dhmilmile1 4 ай бұрын
How can we implement refresh token?
@istovall2624
@istovall2624 4 ай бұрын
Do the same thing bit set the refresh token lifespan to longer then send them both. when the jwt expires resubmit them both to reissue. Still validate the jwt but make sure the only part invalid is the expires. Validate the refresh token. If valid and not expired, reissue new jwt.
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
There you go 😁
@ojhkhofdgfd
@ojhkhofdgfd 4 ай бұрын
@@MilanJovanovicTech That's a great video! I believe you mentioned it is possible to somehow use the refresh token generated by AddIdentityApiEndpoints Service login endpoint to refresh JWTs?
@dhmilmile1
@dhmilmile1 4 ай бұрын
@@istovall2624 got it thanks
@Arshaad786000
@Arshaad786000 4 ай бұрын
this is brilliant. can you show us how to implement something like this with microsoft identity and roles
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Will do
@VishalYadav-oq9if
@VishalYadav-oq9if 4 ай бұрын
Awesome 👍
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Thank you! Cheers!
@omidkianifar5144
@omidkianifar5144 4 ай бұрын
Continue Keycloak series plz
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Next week (schedueld for Friday)
@omidkianifar5144
@omidkianifar5144 4 ай бұрын
@@MilanJovanovicTech 😍
@АлексейАнтонов-ф5ш
@АлексейАнтонов-ф5ш 4 ай бұрын
Do something about external signin, like facebook, google, etc.
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Good suggestions
@СтасСеверин-н9й
@СтасСеверин-н9й 4 ай бұрын
Where can i download this code?
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
This code on www.patreon.com/milanjovanovic But also try this :) www.milanjovanovic.tech/templates/clean-architecture
@esdegan7176
@esdegan7176 2 ай бұрын
how if it got stolen?
@MilanJovanovicTech
@MilanJovanovicTech 2 ай бұрын
You change the signing secret
@esdegan7176
@esdegan7176 2 ай бұрын
@@MilanJovanovicTech with that solution, so if one user got stolen, all user signed outed. which not expected by other user. right?
@RicusNortje
@RicusNortje 4 ай бұрын
Now you don't even need to pass in the user ID on the get user endpoint as you can get it from the JWT subject
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Yes!
@MahmoudSaed98
@MahmoudSaed98 2 ай бұрын
Milan please we want a video about Refresh Token
@MilanJovanovicTech
@MilanJovanovicTech 2 ай бұрын
Recorded, releasing soon
@MahmoudSaed98
@MahmoudSaed98 2 ай бұрын
@@MilanJovanovicTech Thank you very much
@tumers.1595
@tumers.1595 4 ай бұрын
Good tutorial. But it seems to write all the codes into memory. It seems unrealistic and insincere to me.
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
Which part?
@jonchicoine
@jonchicoine Ай бұрын
This doesn't' work that well as a standalone tutorial. imo For anyone familiar with project solution its probably a 10/10.
@MilanJovanovicTech
@MilanJovanovicTech Ай бұрын
That may be the case
Secure Your .NET Application With Keycloak: Step-by-Step Guide
17:05
Milan Jovanović
Рет қаралды 26 М.
Make Your HttpClient Resilient - Circuit Breaker, Retry, Timeout
19:23
Milan Jovanović
Рет қаралды 11 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН
«Жат бауыр» телехикаясы І 26-бөлім
52:18
Qazaqstan TV / Қазақстан Ұлттық Арнасы
Рет қаралды 434 М.
Exceptions Are Extremely Expensive… Do This Instead
17:15
Milan Jovanović
Рет қаралды 50 М.
.NET Project Setup From Scratch Using These 6 Best Practices
16:07
Milan Jovanović
Рет қаралды 15 М.
Session Vs JWT: The Differences You May Not Know!
7:00
ByteByteGo
Рет қаралды 316 М.
Implementing JWT Authentication in ASP.NET Core
23:51
Nick Chapsas
Рет қаралды 48 М.
Coding Was HARD Until I Learned These 5 Things...
8:34
Elsa Scola
Рет қаралды 864 М.
API Authentication: JWT, OAuth2, and More
6:12
ByteMonk
Рет қаралды 24 М.
Your REST API Errors Are Wrong. Problem Details Will Fix This
16:14
Milan Jovanović
Рет қаралды 12 М.
Easy Email Verification in .NET: FluentEmail + Papercut
19:29
Milan Jovanović
Рет қаралды 11 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН