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

Поділитися
Вставка
  • Опубліковано 30 вер 2024

КОМЕНТАРІ • 317

  • @mtranchi
    @mtranchi 2 роки тому +4

    I noticed when I create a new Blazor WebAssembly app with "Individual Accounts", the AspNetUser entity doesn't have a "Password Salt" field. I know it used to, I'm just wondering why it no longer does?

  • @carltongannett
    @carltongannett 2 роки тому +11

    It is easy to miss because Patrick goes by it so quick @23:00
    Visual Studio tries to get you to do System.IdentityModel.Tokens but you need Microsoft.IdentityModel.Tokens as he says but its so quick blink and you miss it and might get stuck. Just thought I would leave this comment for anyone else who is confused why their code isn't working. Thanks Patrick for such a great tutorial!

  • @maryanshapkaroski3282
    @maryanshapkaroski3282 2 роки тому +17

    Hi Patrick, your tutorials are great. Can you make a tutorial for CustomAuthorization(ApiKey and JWT)? :)

  • @muhammadridwan9433
    @muhammadridwan9433 Рік тому +1

    man i thought it's only me having "refresh trouble" after compiling using visual studio 2022 😂, it's better get rest immediately right after encountering this "refresh trouble"

  • @lexxluey
    @lexxluey 2 роки тому +3

    "I would never use the Lord's name in vain. Why would you think that?" 😂😂😂😂
    Subbed!!!!

  • @mynameisshadywhat
    @mynameisshadywhat 2 роки тому +1

    Great tutorial. Bonus that this probably annoyed a bible basher lmfao.
    0:04 -> 29:20 😂😂

  • @appsdev299
    @appsdev299 2 роки тому +5

    Thanks Patrick, you tutorial helped me a lot. Much appreciated.

    • @PatrickGod
      @PatrickGod  Рік тому

      You're most welcome! Thank YOU so much!! Really appreciate it! 😊

  • @uhsimuhleyt8229
    @uhsimuhleyt8229 2 роки тому +2

    This guy's a gamer. Tries to type "user" but left hand goes to wasd and types "uawe" instead.

  • @andrewfraser2760
    @andrewfraser2760 2 роки тому +14

    Bit pedantic but in a production system I would not return "Bad Username" and "Bad Password" as a bad actor can use that information for their gain. Great tutorial as always 🙂

    • @ryandooley4819
      @ryandooley4819 2 роки тому +2

      I agree, keep them guessing

    • @PatrickGod
      @PatrickGod  2 роки тому +2

      You are absolutely right, Andrew! Thanks for sharing. 😊

  • @Mo-ef9yt
    @Mo-ef9yt 2 роки тому +5

    Nice tutorial
    In order for jwt token to be practical, you will need to provide a refresh token. Otherwise you will have to login every time you refresh a page.

    • @gigachad8260
      @gigachad8260 5 місяців тому

      Hi, may I ask the logic of a logout API in respect of JWT authentication and authorization. It seems like ur quite knowledgeable in this topic!

  • @ОксанаМиколаївна-и4ч

    Patrick, who is your boy? Are you LGBT?

  • @forwork7967
    @forwork7967 9 місяців тому +1

    I dont understand why your key is "top secret key" and everything works fine while mine key must be long af, otherwise i receive errors about key

    • @Warrax777
      @Warrax777 5 місяців тому

      Yeah same here, I received error if my key gets less than 512 bits so my secret key is long af

  • @IlIamo
    @IlIamo 2 роки тому +5

    Hello Patrick, love your videos! Im completely new to this and would like to learn how to store registered users in a sql database.
    You dont happen to have any videos that demonstrates the entire process?

    • @PatrickGod
      @PatrickGod  2 роки тому

      Hey there! We do that in the .NET 6 Jump Start Course. You can check it out here: ua-cam.com/video/K23uJdMiEpk/v-deo.html

  • @malikbrahimi7504
    @malikbrahimi7504 Рік тому +1

    Thanks Patrick, just had a couple different questions:
    1. Is this how it's really done in production? I've seen a lot of tutorials almost all of which refer to the Identity package and external IdP but if your app (i.e. your DB) is the IdP in and of itself is this how it's done?
    2. I can't help but strain my eyes seeing that static User instance in your controller, not sure how this would even work as concurrent users would more than likely mutate the same instance ... how would you go about getting a user in the method body i.e. via transient service or http context?
    3. What's a good way to deal with 3rd party integrations? I still want to use this methodology to sign in users to my application but I want them to be able to add other social integrations in app to query remote resources. Would I have a table with FK to user, token, and refresh token allowing me to refresh as needed?

    • @MankS01
      @MankS01 11 місяців тому

      Anyone's answer on this will be appreciated

  • @cjt9150
    @cjt9150 2 роки тому +2

    Superb! Continue this video with authentication and refresh token. And use it in some tasks. Greate

  • @sangtan6430
    @sangtan6430 2 роки тому +1

    Thank you for making perfect video. I have a question how about logout. Can you make a video or suggest me some solutions. Thanks

  • @swamnhtet786
    @swamnhtet786 5 місяців тому +1

    Thanks God. This video is really helpful for me.

    • @PatrickGod
      @PatrickGod  5 місяців тому

      Glad it was helpful!

  • @bernardodomeneghetti9673
    @bernardodomeneghetti9673 Рік тому +1

    Bro, you just deserve this last name hahahah, thank you so much !

  • @Sarah-lw4rd
    @Sarah-lw4rd 2 роки тому +1

    Hi Patrick, love your tutorials. Can you do a tutorial on OAuth2 + OpenID Connect authorization server on the .NET core 6 Web API using OpenIddict.

    • @Andy-qb9kh
      @Andy-qb9kh 2 роки тому

      I need the exact same tutorial. Have you found something about that?

  • @tanoryjakaperdana1419
    @tanoryjakaperdana1419 Рік тому +1

    thank you sir.. but how can i implement this JWT token on the client side? have you made a video about it?

    • @PatrickGod
      @PatrickGod  Рік тому +1

      This one is for you: ua-cam.com/video/Yh16E2u2pio/v-deo.htmlsi=GHlDOTnINjLHTnwa

    • @tanoryjakaperdana1419
      @tanoryjakaperdana1419 Рік тому

      @@PatrickGod thank you again sir.. is it the same for web App empty? Or should i use blazor?

  • @NirSimkin
    @NirSimkin 2 роки тому +1

    Hey Patrick, Thanks for awesome video .
    do you have any video about how to save the user in Db and not on a static like now ? (User user = new User right now) ...

  • @sefakpsz
    @sefakpsz 2 роки тому +3

    I stucked with JWT for one month but thanks to you I solved it finally. THANK YOU SO MUCH

    • @PatrickGod
      @PatrickGod  2 роки тому +1

      Great to hear! Thanks for your feedback!

    • @iamfazill
      @iamfazill 2 роки тому

      same here

  • @macram4042
    @macram4042 2 роки тому +1

    Hi Patrick, Thank you for this tutorials very useful., My concern now is how to Post to the database if you register and to Get the user from the database? Thank you in advance...

  • @tech-savant
    @tech-savant 2 роки тому +1

    How would you connect this entire series of jwt authentication and oauth2 with angular on the frontend?

  • @jaynishchauhan730
    @jaynishchauhan730 Рік тому

    sir this "System.Text.Encoding.Utf8.getbytes()" function are not avalable in this package

  • @8294685725
    @8294685725 Рік тому +1

    Initially thank you

  • @AveN7ers
    @AveN7ers 2 роки тому

    Wait does the out keyword create variables? In the register method you didn't initialize passwordHash and passwordSalt???

  • @michaelshepherdmunemo4414
    @michaelshepherdmunemo4414 Рік тому +1

    I like and subscribed. Thank you

  • @vnansen
    @vnansen Рік тому

    Very helpful video. I have a queation. During the ligin method testing. after you giving string as user name it says " CRAZY TOKEN" so where is it validating the user name i mean there i no database right?

  • @luisc1794
    @luisc1794 2 роки тому +2

    Hi Patrick, great videos. It is possible to show how to refresh the token and how to implement it on a Blazor Server without using an API? I really appreciate it see how you implement it. Thanks

  • @devloopers8380
    @devloopers8380 Рік тому +1

    Great video...really helpful. Thanks man

  • @PatrickGod
    @PatrickGod  2 роки тому +13

    ▶ [Part 2/4] .NET 6 Web API 🔒 Role-Based Authorization with JSON Web Tokens (JWT): ua-cam.com/video/TDY_DtTEkes/v-deo.html
    ▶ [Part 3/4] .NET 6 Web API 🔒 Read JWT Authorization Claims of a User (from a JSON Web Token): ua-cam.com/video/fhWIkbF18lM/v-deo.html
    ▶ [Part 4/4] Refresh Tokens with a .NET 6 Web API 🚀: ua-cam.com/video/HGIdAn2h8BA/v-deo.html

  • @Don-ii4vm
    @Don-ii4vm 2 роки тому +1

    Thank you for the tutorials. I hope you dont have to deal with to many people who harass Gods.

  • @srkbhayo
    @srkbhayo 8 місяців тому

    It is a good tutorial, but UserDto and Password hashing and salting is a bit overkill for basic understanding here

  • @souravsingha3340
    @souravsingha3340 2 роки тому +2

    Role base authorized need to added video

    • @PatrickGod
      @PatrickGod  2 роки тому +3

      Got it. 😉

    • @PatrickGod
      @PatrickGod  2 роки тому +1

      If you haven't seen it already, here you are: ua-cam.com/video/TDY_DtTEkes/v-deo.html 😉

    • @souravsingha3340
      @souravsingha3340 2 роки тому

      @@PatrickGod Lots of thanks💝💝

  • @periandavarg7558
    @periandavarg7558 2 роки тому

    some people feel,better relief when other person guides, or may induce epiphany in the process of learning. You helped me and on your side, someone would be. That's all I hope for that.
    Regarding God comment that you have got. What's up with name matters, ignorant ones,
    If someone gives idea or solves your thing so that you progress of using it, what would you assume him/her.

  • @unkn0wnrge189
    @unkn0wnrge189 Рік тому

    lmao people are mad at your name lol!!!!! Have saw some people with biblical names because their parents were proud christians and got accused of heresy lol.

  • @colombuzz8550
    @colombuzz8550 Рік тому +1

    How do you persist the registered user data for later login?

  • @newbreaker0403
    @newbreaker0403 2 місяці тому

    This video is pretty old, but still very helpful. Thank you sir!

  • @youbaimakhlaf7382
    @youbaimakhlaf7382 2 роки тому

    Great Video ur great!
    idk why but VerifyPasswordHash doesnt not work i have always a wrong password :/

  • @malathip4043
    @malathip4043 2 роки тому

    i want to use auth plugin , vue frontend, .net core , mssql for backend, Can you suggest please.

  • @AbdulAziz-xi1lo
    @AbdulAziz-xi1lo 2 роки тому

    Hi problem in saving Hashed PW and Salt into sql server using dapper can you help in this please !!!

  • @beenicepleese9687
    @beenicepleese9687 Рік тому

    So I'm using just hash password without salt password.how to verify the password

  • @PedalsizBerkay
    @PedalsizBerkay Рік тому +1

    thanks GOD

  • @cuzsleepisthecousinofdeath
    @cuzsleepisthecousinofdeath 2 роки тому

    Tried it in .net 5 and upon checking jwt on the checking site it says that signature's invalid
    Is this normal?

  • @PalbornozN
    @PalbornozN 2 роки тому

    thanks, you save my final exam! with createToken function xD!

  • @CHOSFe
    @CHOSFe 2 роки тому +1

    its perfect to watch the video.The video timeline can see your implementation funtion.

  • @ahmidosenadoro3642
    @ahmidosenadoro3642 2 роки тому

    Could make a video about Userlogin with azure active directory?

  • @ViralityG
    @ViralityG Рік тому

    Does anyone know how we would then reference the user from the server side? Trying to make an account (like a bank account) and I want it to have a reference to the user who creates it.

  • @drakZes
    @drakZes 2 роки тому +1

    IM so glad someone is making JWT with .NET 6. Other people make videos with .NET 2 in 2022 which doesn't make any sense.

    • @PatrickGod
      @PatrickGod  2 роки тому

      Glad I could help! Thanks for your feedback!

  • @maestrowilliam
    @maestrowilliam Рік тому

    and now. How i use it in a API?
    I want only authorized users get the list of products

  • @sameershahbaz1707
    @sameershahbaz1707 2 роки тому

    hi sir, hope you doing good, sir can you please make this tutorial with sql database

  • @ArthunMorgan747
    @ArthunMorgan747 Рік тому

    how do we use expire time in token to logout application automatically after certain time in angular?

  • @ashutoshsingh5568
    @ashutoshsingh5568 Рік тому

    if we can decode the JWT by visiting the official site then how it is safe? i mean anyone can copy our JWT and see what it contains.

  • @nicolahu1692
    @nicolahu1692 Рік тому

    Thank you, but how to validate a JWT given your secret?

  • @markmendoza7290
    @markmendoza7290 2 роки тому +1

    Are you going to update your .Net 5 Web Api course to use .Net 6?

    • @PatrickGod
      @PatrickGod  2 роки тому

      Absolutely. Takes some time, though. Sorry about that. But I'm on it!

    • @markmendoza7290
      @markmendoza7290 2 роки тому

      @Patrick God lol I couldn't wait so I bought your .net 5 course.
      I am following on Mac so i had a bit of a learning curve. The tools i needed to get all of this working was Docker, Azure Studio, VS for Mac, and Postman (for testing).
      Following .Net 5 while I write my project in .Net 6 is not to bad.

  • @thesandboxgamingvideos
    @thesandboxgamingvideos 4 місяці тому

    how about using this webapi and consume in a core application with admin panel ?

  • @lcppb
    @lcppb Рік тому

    Hi you said this example was rude do you have a professional ????

  • @Lactorioga
    @Lactorioga 9 місяців тому

    Something useful starts at 20:06 Man, so much timewaste on setting up...

  • @talhaaftab4565
    @talhaaftab4565 2 роки тому +1

    Hi @Patrick, such a nice explanation. I really appreciated. Do you pls give me an favor can you upload video on how I refreshing JWT with refresh token.

    • @PatrickGod
      @PatrickGod  2 роки тому

      Thank you! Refresh tokens are on my roadmap. Stay tuned! 😊

  • @saqibamin4266
    @saqibamin4266 Рік тому

    Thanks for this valuable tutorial, learning alot fro this channel

  • @benechem897
    @benechem897 Рік тому

    hey Patrick, can you make a video about the use of Interface?

  • @ruslan_yefimov
    @ruslan_yefimov Рік тому

    If you don't believe in god, then who the hell you think you're looking at🤣

  • @filbertnicholas8037
    @filbertnicholas8037 2 роки тому +1

    Hi Patrick, thanks for this.
    Can you also help with tutorial for .net 6 web api + identity framework and data seeding? Cheers!

    • @PatrickGod
      @PatrickGod  2 роки тому

      Thanks for your feedback. Identity is on my roadmap. Stay tuned! 😊

  • @RaimundPopp
    @RaimundPopp Рік тому

    hi patrick, if you leave the passwortSalt in the userdto as property, a hacker gets the salt to test from the api at 13:16.
    and if you have the user as static in line 16, then it will interact with other logins at the same time.
    right?
    but i love your tutorial

  • @vano4ok
    @vano4ok 2 роки тому

    Maybe video about access token with refresh token?)

  • @wzarok
    @wzarok 2 роки тому

    i love u mr Patrick. Thanks for everything

  • @НикитаНовиков-ф2ш

    Thank you very much. It was interesting.

  • @jairajsahgal7101
    @jairajsahgal7101 2 роки тому

    Are you retrieving data from database also in login method?

  • @kamajo7518
    @kamajo7518 2 роки тому +1

    It was a great video Patrick, but really very demanding. Still thanks again for the preview, I like your videos! I sent link to your videos to my friends

  • @danielpelissari7539
    @danielpelissari7539 2 роки тому

    Thanks for the video, greetings from Brazil.

  • @gonzalosierra1145
    @gonzalosierra1145 2 роки тому +2

    Hello from Argentina Patrick!! Only i want you to know that you are a very good teacher, with very clearly explanations. I wish you a lot of success!

    • @PatrickGod
      @PatrickGod  2 роки тому +1

      Thank you so much! Means a lot to me! 😊

  • @abobonickname5696
    @abobonickname5696 2 роки тому

    why is your access modifier for username set public?

  • @KoopaGamingX
    @KoopaGamingX 2 роки тому +1

    Thank you for the tutorials

  • @bswill5077
    @bswill5077 2 роки тому +2

    What a godly content. Thank you

  • @tysonfury3168
    @tysonfury3168 2 роки тому

    Why does the repo suddenly has userservices and Iuserservices?

  • @genasis8049
    @genasis8049 Рік тому

    is there a video about configuring this with a database?

  • @MrLgbk
    @MrLgbk 2 роки тому +2

    It's art to able to share knowledge as easy as you doing.

  • @GianluigiConti
    @GianluigiConti 2 роки тому +1

    Another useful video👍 I also have a 1yo son and, god (no pun intended), I hear you on the sleeping time

    • @PatrickGod
      @PatrickGod  2 роки тому

      Thank you for your support. The sleep deprivation is the worst.. But it will get better, right? 😅🤔

  • @anthonym.l4308
    @anthonym.l4308 2 роки тому

    This is Authorize not authenticacion but is a goog video

  • @oguzhan2393
    @oguzhan2393 Рік тому

    login and register there is something wrong. cant login.

  • @dayne-kora2415
    @dayne-kora2415 Рік тому

    Can anyone please explain the necessity of UserDto?

  • @binaryid6126
    @binaryid6126 2 роки тому

    Thx u Patrick, nice, amazing tutorial

  • @nicolass8941
    @nicolass8941 2 роки тому +1

    Hi Patrick, great course !!! Thx

  • @conchita-ud8jc
    @conchita-ud8jc Рік тому

    hahaha now I have no doubts about whether it was your last name or not

  • @sallyresch5040
    @sallyresch5040 8 місяців тому +1

    Love your humor man! keep it going with you easy to learn videos

    • @PatrickGod
      @PatrickGod  8 місяців тому

      Thank you so much! Appreciate it.😊

  • @riversound8871
    @riversound8871 Рік тому +2

    Hey, Patrick, you made authentication very easy and teach use in very simpler way.
    Thanks for amazing tutorial.

  • @uctupham4923
    @uctupham4923 2 роки тому

    God speed run coding to match up with his son wake

  • @ranajadry1813
    @ranajadry1813 Рік тому

    in wich table username and password was inserted

  • @samjakrishnan6969
    @samjakrishnan6969 2 роки тому +1

    Thank you so much for the video. Very descriptive and helpful. Good Job 👍👍

    • @PatrickGod
      @PatrickGod  2 роки тому +1

      You are welcome! Thank you so much for your feedback! 😊

  • @JohanDG7
    @JohanDG7 2 роки тому +1

    Hi! Nice video :) I don't fully understand the use of passwordSalt. Feel free to explain to me like im 5 ;). Is it not enough to store the hashed password?

    • @PatrickGod
      @PatrickGod  2 роки тому

      Hey, thanks! 😊
      Don't know if that's the right explanation for a 5 year old, but without a salt, the hash value would always be the same for a particular password. Let's say your password is "remember". Running this through a cryptography algorithm results ins "123456". Another user also has the password "remember", hence the hashed value is "123456". Now, if someone (don't know who would ever do that...) is able to revert the algorithm (see MD5, for instance), then you would be able to decrypt "123456" into "remember". Always.
      Now comes the salt. With a salt, the hashed value is different, even if the password is the same. The algorithm takes "remember" and a random salt "wasd". The hashed value is now "456123". Another user has the same password but a different salt, hence the hashed value is different as well, although the password is the same.
      In essence, it's a way to make your account more secure.
      Hope this helps!
      Take care,
      Patrick

    • @JohanDG7
      @JohanDG7 2 роки тому +1

      @@PatrickGod Excellent explanation! Thanks for responding so quick :)

  • @yogeshpandey9813
    @yogeshpandey9813 2 роки тому +1

    Hi Patrick nice to see your video
    I just want to ask you the perfect way to create the database for that also how we can store the user entries on database?

    • @Daynn_
      @Daynn_ 2 роки тому

      did you find an answer? I am doing a website with .net backend and I did what he did but when I try the route with swagger the user I register doesn't appear in my database and it s been like an hour since I try everything I can with _context.SaveChanges but nothing look to work. Sorry if I am late hahah XD

  • @distinguishedmoments2277
    @distinguishedmoments2277 2 роки тому +1

    Wow i was looking for exactly this, and presented by no other than the cozyest guy out there. cheers

    • @PatrickGod
      @PatrickGod  2 роки тому

      This is great. Thank you so much for your kind feedback. 😀

  • @-02dmytrokotenko49
    @-02dmytrokotenko49 Рік тому +2

    I have been putting off working on my term paper for about a month because I could not even understand the topic, but thanks to you everything became clear. Thanks dude and greetings from Ukraine :3

    • @PatrickGod
      @PatrickGod  Рік тому

      Glad I could help! 😊Thanks a lot for your feedback!

  • @eng.wandeson
    @eng.wandeson 2 роки тому

    Thanks for it, dude! I’m need it

  • @broadshare
    @broadshare 2 роки тому +1

    Finally, the last name, been so afraid to say it. Very helpful tutorial, keep up the good job

    • @PatrickGod
      @PatrickGod  2 роки тому

      😊 Glad it helped! Thanks for your feedback!

  • @ayodejiadesuyi2248
    @ayodejiadesuyi2248 2 роки тому +1

    I love you man. Thanks so much for this tutorial and the pagination one.

    • @PatrickGod
      @PatrickGod  2 роки тому +1

      Happy to help! Thank you very much for your feedback! 😊

  • @REDULE26
    @REDULE26 2 роки тому +3

    Great tutorial! I was exactly looking for that and it’s very well explained :)

    • @PatrickGod
      @PatrickGod  2 роки тому

      Thank you very much for your feedback! 😊

  • @rileyhowley7113
    @rileyhowley7113 2 роки тому +1

    Hey there, I implemented what you showed us in the video into my web api. However, when I authorize my controller, and send a request with my token it doesnt unlock the controller. Any advice or guides. Cheers

    • @PatrickGod
      @PatrickGod  2 роки тому +1

      Hey Riley, I think this video is for you: ua-cam.com/video/TDY_DtTEkes/v-deo.html Enjoy! 😊

    • @rileyhowley7113
      @rileyhowley7113 2 роки тому

      @@PatrickGod I figured it out I hacked away at it and got it. Thankyou though. Love the vids

  • @michaelmel4420
    @michaelmel4420 2 роки тому +2

    I don't have any requests but just wanted to pass along another thank you as your videos are very instructive, concise and helpful.

    • @PatrickGod
      @PatrickGod  2 роки тому

      Thank you so much!! Means a lot. 😊