.NET 7 Web API 🔒 Create JSON Web Tokens (JWT) - User Registration / Login / Authentication

  Рет қаралды 78,647

Patrick God

Patrick God

Күн бұрын

🚀 Join the .NET Web Academy: learn.dotnetwebacademy.com
💖 Support me on Patreon: / _patrickgod
🚀 Get the .NET 8 Web Dev Jump-Start Course for FREE: dotnet8.patrickgod.com
🐦 Let's get social on Twitter/X: / _patrickgod
🔗 Let's connect on LinkedIn: / patrickgod
💻 GitHub: github.com/patrickgod/JwtWebA...
💡 Udemy Online Courses:
🔥 Blazor E-Commerce Course: www.udemy.com/course/blazor-e...
🔥 Blazor Bootcamp: www.udemy.com/course/blazor-w...
🚀 .NET Jumpstart Course: www.udemy.com/course/net-core...
Table of Contents:
00:00 .NET 7 Web API 🔒 Create JSON Web Tokens
02:46 Add the AuthController with the Register() Method
03:51 Install the BCrypt.NET NuGet Package
07:35 Test the User Registration
08:11 Implement the Login() Method
10:32 Test the Login() Method
11:18 Create the JSON Web Token
20:22 Final Test
#PatrickGod #DotNet #JWT

Пікірлер: 59
@kenneth6965
@kenneth6965 Жыл бұрын
This is personally my favorite part of your tutorials. All the way to refresh tokens. Thanks for this.
@PatrickGod
@PatrickGod Жыл бұрын
Happy to hear that! Thank you!
@saitoinosaka6445
@saitoinosaka6445 9 ай бұрын
if you are facing an error like Unable to create KeyedHashAlgorithm for algorithm 'HS512', the key size must be greater than: '512' bits, key has '256' bits. Arg_ParamName_Name. Just increase the token size in your settings.json
@AdeyinkaAdegbenro
@AdeyinkaAdegbenro Жыл бұрын
This is my most simpliest favorite authentication tutorial especially using hashPassword. Awesome Job Patrick!
@PatrickGod
@PatrickGod Жыл бұрын
Thank you so much for your feedback! Glad you like it! 😊
@user-xb5ph3fz3o
@user-xb5ph3fz3o 6 ай бұрын
I just Love the way you explain bro , thank you so much and carry on please 🙏🙏🙏
@colllm
@colllm 10 ай бұрын
Superb explanation as usual Patrick. Thank you.
@PatrickGod
@PatrickGod 10 ай бұрын
Many thanks!
@MatthewCuda
@MatthewCuda 11 ай бұрын
I love your style, very much the way I like to code.
@orlandoubilla7055
@orlandoubilla7055 Жыл бұрын
Great video and explanation, thank you very! 😎✌
@RoyZASTEROiD
@RoyZASTEROiD Жыл бұрын
good reference in last test part
@PatrickGod
@PatrickGod Жыл бұрын
Glad it was helpful!
@elishamisoi
@elishamisoi 5 ай бұрын
Thank you so much Patrick.
@d-landjs
@d-landjs Жыл бұрын
Excellent bro, it was interesting!
@PatrickGod
@PatrickGod Жыл бұрын
Glad you enjoyed it!
@josephl
@josephl Жыл бұрын
Hi Patrick. I'm following your videos since the .NET 6 version of this topic. I remember back then you used HMACSHA512 to generate the password Salt. Does this mean HMACSHA512 will always generate the same Salt for the same input even though is in byte[] format?
@alataherzadeh5761
@alataherzadeh5761 4 ай бұрын
nice. من ایرانی هستم. ممنون بابت اموزش عالی.💕💕💕💕💕💕💕💕💕💕
@abdulmussavir4627
@abdulmussavir4627 Жыл бұрын
Hello Patric I like your teaching style and also love your codding style 🥰
@PatrickGod
@PatrickGod Жыл бұрын
Thank you very much, Abdul. I appreciate that. 😊
@slowmowfit
@slowmowfit 10 ай бұрын
@PatrickGod There's no explanation as to how inputing Bear Token in the Swagger, unless I missed it?
@jayantverma4639
@jayantverma4639 Жыл бұрын
Hello patrick How to store the Data in the sql database user login and regsitration ?
@PatrickGod
@PatrickGod Жыл бұрын
🚀 Get 20% off the .NET Web Academy: www.dotnetwebacademy.com/bundles/net-web-academy?coupon=dnwa2024yt
@rezarst5734
@rezarst5734 6 ай бұрын
so useful, thank you
@10Totti
@10Totti Жыл бұрын
Good tutorial!
@PatrickGod
@PatrickGod Жыл бұрын
Thank you so much!
@phoolherreracondezo2841
@phoolherreracondezo2841 7 ай бұрын
i sheesh with that code very simple, thanks bro
@pedrampourhakim3035
@pedrampourhakim3035 Жыл бұрын
Could you please tell us how we can logout the user? thanks
@onedev7316
@onedev7316 Жыл бұрын
Nice one, can you do a video on User impersonation using JWT ? Thanks
@kwstaslalaounis3212
@kwstaslalaounis3212 Жыл бұрын
You are Perfect thank you.
@PatrickGod
@PatrickGod Жыл бұрын
Happy to help! Thank you very much!
@Sizdah_13
@Sizdah_13 6 ай бұрын
thank you , 💖💖
@samiullah0011
@samiullah0011 Жыл бұрын
my jwt is not validating after i create it can you help me?
@samsonmayeem5548
@samsonmayeem5548 11 ай бұрын
Bro, _configuration gives red flag, what's possibly the cause?
@ritickkushwaha2835
@ritickkushwaha2835 5 ай бұрын
Is anyone know how to run this in postman..?
@waqasawan4999
@waqasawan4999 9 ай бұрын
Nice video
@PatrickGod
@PatrickGod 9 ай бұрын
Thanks!
@daniel_klement_photography
@daniel_klement_photography Жыл бұрын
May I have a question about security? JWT is nice but is it a good idea to store there email or some user's data? Is'nt it better to control and check the JWT in the database if the user is logged in or not? Or what's the bet idea in this way how to secure the API?
@md.redwanhossain6288
@md.redwanhossain6288 10 ай бұрын
JWT is used for stateless authentication. If you hit the Database per request, there is no point for using JWT.
@learn.net2202
@learn.net2202 Жыл бұрын
Please make video for logout in JWT token by invalidating token without storing token in database
@iEricoHD
@iEricoHD Жыл бұрын
This. I hope he makes a video on it. Best tutorials on Entity Framework by far.
@user-dw9zz1zr9v
@user-dw9zz1zr9v Жыл бұрын
Hey can you make it with sql connection and some other features like pagination
@hungle-bp5qt
@hungle-bp5qt 11 ай бұрын
why he dont use sql connention ha
@choudharyd4927
@choudharyd4927 Жыл бұрын
Token generated on stagging environment works in production and development too, can someone help how can separate token based on environment
@PatrickGod
@PatrickGod Жыл бұрын
You could use different signing keys for the different environments
@choudharyd4927
@choudharyd4927 Жыл бұрын
@@PatrickGod thankyou Patrick. Regards.
@chezchezchezchez
@chezchezchezchez Жыл бұрын
Please help. How do I make a API that returns a list of records filtered by the personId? I used the scaffolding API wizard. This is killing me. I have it working for getting all the records, but I can’t seem to add a Where clause. Thanks!!
@ydock
@ydock Жыл бұрын
without your code he cant help you but you can do something like this on your service _dataContext.YOUDBCONTEXTTABLE.Where(t => t.Enabled) .AsQueryable(); later you can call the service in your controller.
@chezchezchezchez
@chezchezchezchez Жыл бұрын
@@ydock I would be happy to show you my code, would you take a look?
@user-nm2el1xl5o
@user-nm2el1xl5o Жыл бұрын
I'd like to ask this. What is the advantage of using a custom authentication system rathen than using AD for instance? I know when one creates a project in VS, we have the option to select a auth system and it will be implemented and we can twist it.
@AdeyinkaAdegbenro
@AdeyinkaAdegbenro Жыл бұрын
Hi E243, from experience, especially if you are delivery SaaS, not all client may have AD that you can plug in to, you may want to have a fallback custom authentication system. I hope this helps. Cheers.
@user-nm2el1xl5o
@user-nm2el1xl5o Жыл бұрын
@adeyinkaroyal Make sense, but when a customer sign up, those information aren't going to be saved in Azure? I don't think one has to have credentials in AD. If I am wrong then it does make sense.
@AdeyinkaAdegbenro
@AdeyinkaAdegbenro Жыл бұрын
@@user-nm2el1xl5o Hi, was offline for a while. That's correct, it means on sign up, you manage the customer's data in your repository of choice, hence you can build your own custom authentication on it.
@KSUBlueDragon
@KSUBlueDragon Жыл бұрын
Why in the world would an api need to know more than just the fact it’s an authenticated user and has access? The UI should do the login and then pass the token generated then with a call that passes they are authenticated and maybe a app id to validate that said app has access to it.
@unskeptable
@unskeptable 8 ай бұрын
When you call weather api how does it know to automatically call the auth/login controller to generate the token ? Where is this connection defined exactly ?I don't get it
@unskeptable
@unskeptable 8 ай бұрын
Ah ok I found out its defined in the loginPath variable of Identity options
@ngocanh9250
@ngocanh9250 11 ай бұрын
Not useful
@ClickOkYT
@ClickOkYT Жыл бұрын
Why "SecurityAlgorithms.HmacSha512Signature" but not "SecurityAlgorithms.HmacSha512"?
🤔Какой Орган самый длинный ? #shorts
00:42
Beautiful gymnastics 😍☺️
00:15
Lexa_Merin
Рет қаралды 14 МЛН
Русалка
01:00
История одного вокалиста
Рет қаралды 7 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 69 МЛН
Custom Authentication (JSON Web Tokens)
13:03
FlutterFlow
Рет қаралды 14 М.
Difference between cookies, session and tokens
11:53
Valentin Despa
Рет қаралды 603 М.
What Is JWT and Why Should You Use JWT
14:53
Web Dev Simplified
Рет қаралды 1,1 МЛН
Crowdstruck (Windows Outage) - Computerphile
14:42
Computerphile
Рет қаралды 7 М.
Should I Create A Minimal API Or Full API?
7:40
IAmTimCorey
Рет қаралды 34 М.
Rest API - Best Practices - Design
15:50
High-Performance Programming
Рет қаралды 101 М.
🤔Какой Орган самый длинный ? #shorts
00:42