ASP.NET Core Authentication with JWT (JSON Web Token)

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 281

  • @this-is-bioman
    @this-is-bioman ปีที่แล้ว +3

    That's how a tutorial should look like! Straight to point with a working example. Love it! 😎🤩

  • @darizardTheDargon
    @darizardTheDargon 2 ปีที่แล้ว

    Add my voice to the chorus. Insanely helpful and well-done video, thank you.

  • @Ram-yk7yl
    @Ram-yk7yl 3 ปีที่แล้ว

    This worked like a charm. Exactly what I was looking for..., Confused with various online material, but this was most clear of all of them...

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Ra m, thanks for watching the video, and glad this video helped you!

  • @R2d2ums
    @R2d2ums 3 ปีที่แล้ว +1

    Dude!! Thx for the video! It really helped me out. Right know I'm just reading your blog to understand better the whole code.

  • @avtarsashia4897
    @avtarsashia4897 3 ปีที่แล้ว

    Awsome way of teaching. And working with real scenario.

  • @drakZes
    @drakZes 3 ปีที่แล้ว +1

    Easy and great setup of how to add authorization to a web application. Well done!

  • @junaidm1038
    @junaidm1038 3 ปีที่แล้ว

    This is the most simple way of doing JWT , thanks so much

  • @ProperComment
    @ProperComment 4 ปีที่แล้ว +1

    Why wasn't I able to find this channel earlier 😭 🤣🤣
    I've shared your content with all my colleagues 🙏

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว +1

      @The Red Baron, thanks for watching. I hope everyone you have shared with will find it useful.

  • @naveen.bhardwaj
    @naveen.bhardwaj 2 ปีที่แล้ว

    Awsm Explanation, Easy to understand

  • @RahulKumar-tf3cx
    @RahulKumar-tf3cx 2 ปีที่แล้ว

    Thank you Nirjhar. Great explanation.I have implemented with your example

  • @CAPS_AMERICA
    @CAPS_AMERICA 2 ปีที่แล้ว

    your tutorial is amazing, the IT community needs more people like you!
    however, MICROSOFT SUCKS for implementing a million different classes and ways to implement authentication /authorization classes then those classes get deprecated and then the developer will be scrambling for answers to solutions that new core version/framework is trying to introduce!
    For MS, there is no one universal, non-complex, non-confusing way to create a simple web API with basic authentication, it's like each authentication scheme is created by one developer that is trying to out-do the other developer within their team that has implemented a recent class/code! I hope, I really, really hope, that MS should one day be overtaken by another company or that incoming new developers will instead switch to open source and other tech stacks for web api-related stuff!
    I will be the first to rejoice if MS will file for bankrupcy one day, or get bought by Apple!

  • @vigneashselvaraj3592
    @vigneashselvaraj3592 ปีที่แล้ว

    Excellent content.. very straight forward

  • @davidemmanuel3001
    @davidemmanuel3001 3 ปีที่แล้ว +1

    God bless you my friend for this video

  • @nirbhaysinghverynice5880
    @nirbhaysinghverynice5880 ปีที่แล้ว

    really nice explanation to the point and explained every point thanks alot

  • @evaapperson1760
    @evaapperson1760 2 ปีที่แล้ว +1

    Very quality content. It very helped me to understand this important theme !:)

  • @cheequsharma7391
    @cheequsharma7391 ปีที่แล้ว

    Thanks a lot for such content. I respect and really admire your huge efforts, for such incredible content. God bless mate.

  • @mmsky
    @mmsky 4 ปีที่แล้ว +7

    Thank you so much for taking the time to make this video and share your knowledge! Excellent. Subscribed :)

  • @DevKumar-nh6vk
    @DevKumar-nh6vk ปีที่แล้ว

    Love the video. I urge you to create video on OAuth with JWT implementation. Complete details on OAuth.

  • @amjster
    @amjster 3 ปีที่แล้ว +1

    Excellent video, I have shared with my whole team to watch. Thank you. One question, at 15:56 you add the JwtTokenAuthenticationManager to services with the key, but what if you wanted to pass in the DbContext and also maybe the ILogger so the JwtTokenAuthenticationManager can confirm the credentials against the Db. How do you configure the services for the JwtTokenAuthenticationManager in startup to inject those into the class?

  • @PraveenKumar-ft2kr
    @PraveenKumar-ft2kr 4 ปีที่แล้ว +2

    Excellent video brother.. I have been looking for this.. Thank you so much 🙏🙌👏👏

  • @nileshmore1820
    @nileshmore1820 2 ปีที่แล้ว

    Very good explanation.
    thank you .

  • @iyashasgowda
    @iyashasgowda 4 ปีที่แล้ว

    A heartly thanks to you for teaching the tokenization in simple way.

  • @inmywaythings
    @inmywaythings 2 ปีที่แล้ว

    Simple and clear example, thank you 👍

  • @pritamdeokule
    @pritamdeokule 3 ปีที่แล้ว

    Thanks You. Great... very neat and clean explanation given by you.

  • @kiranbs5057
    @kiranbs5057 3 ปีที่แล้ว +7

    Nice video , But I feel it would have been been great for beginners like me , if you had spent some time explaining the usage of each line while configuring authentication in startup and controller class files .

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว +1

      @Kiran BS, thanks for watching, and thanks for your valuable feedback, I will surely keep this in mind.

  • @usmansiddiqui1854
    @usmansiddiqui1854 2 ปีที่แล้ว

    Guys I am confused here that the implementation of JWT here is working on O Auth 2.0 mechanism or not?

  • @ashutoshmishra2170
    @ashutoshmishra2170 3 ปีที่แล้ว

    i am big fan of your videos .

  • @Imran-mr6fv
    @Imran-mr6fv 3 ปีที่แล้ว

    Excellent... keep up the good work

  • @BhautikDalicha
    @BhautikDalicha 2 ปีที่แล้ว

    How we can achieve same thing in MVC and pass token after authentication?

  • @funnytoddler375
    @funnytoddler375 3 ปีที่แล้ว

    Nice explanation 👌

  • @ch1995
    @ch1995 2 ปีที่แล้ว

    May I know the use of having the AuthenticationManager interface instead of just having a solid Class? thanks

  • @hhcruz1999
    @hhcruz1999 3 ปีที่แล้ว

    I am able to generate the token. I am also getting the data without authorisation. But when I give the Authorize for the get method I get unauthorised. Could you please help me solve this issue.

  • @brettgregory3622
    @brettgregory3622 3 ปีที่แล้ว +1

    Amazing video thank you! So clear and concise!

  • @pankitpatel1987
    @pankitpatel1987 4 ปีที่แล้ว +1

    good help full, if you want to add more things then add authorization with multiple roles, multi-tenant application authentication.

  • @ghkpr
    @ghkpr 3 ปีที่แล้ว +3

    Great tutorial, easy to follow and understand. Thanks a lot!

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @gh057k33p3r, thanks for watching the video!

  • @SohailKhan1981
    @SohailKhan1981 3 ปีที่แล้ว

    Very well explained. Thanks for your effort.

  • @Whisper_Jonas
    @Whisper_Jonas 3 ปีที่แล้ว

    Thank you for all of your tutorial

  • @rdoskoch
    @rdoskoch 3 ปีที่แล้ว

    So satisfying keyboard typing.))))

  • @vigneashselvaraj3592
    @vigneashselvaraj3592 ปีที่แล้ว

    In this JWT is authorized when sent as header in the request. May I know how can the access token be validate as part of query string ?

    • @DotNetCoreCentral
      @DotNetCoreCentral  ปีที่แล้ว

      its a good practice to send token as part of header, but nothing stops you from sending token in query string, there are use cases like websocket where you might need to pass it in query string

  • @vinayakkatti4028
    @vinayakkatti4028 3 ปีที่แล้ว

    Very useful information. Thank you sir...

  • @pedromoura8731
    @pedromoura8731 4 ปีที่แล้ว +10

    Hi, thanks for the tutorial! You keep the content simple and easy wich is great, but for future improvement you could add a real front end, just a login page, 1 or 2 authorized pages and a logout. this way we could see the complete workflow of the jwt and how is stored in page transitions.

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว +2

      Pedro Moura thanks for the suggestions. I’ll definitely work on that. Thanks again for watching the video.

    • @marrelicious6731
      @marrelicious6731 3 ปีที่แล้ว

      @@DotNetCoreCentral Did you ever make this video?

    • @lengoctuan5217
      @lengoctuan5217 2 ปีที่แล้ว

      @@DotNetCoreCentral Did you ever make this video?

    • @DotNetCoreCentral
      @DotNetCoreCentral  2 ปีที่แล้ว +1

      @@lengoctuan5217 no, I never got to it.

    • @lengoctuan5217
      @lengoctuan5217 2 ปีที่แล้ว +1

      ​@@DotNetCoreCentral Thanks brother for the reply. Your video is very helpful.

  • @sps014
    @sps014 3 ปีที่แล้ว

    Great video, nicely explained

  • @deepjyotyroy6676
    @deepjyotyroy6676 3 ปีที่แล้ว

    Thanks for the Awesome Video. But I have a question. If I need to create a Custom Unathorized return message from any POST or GET api, what should I do ?

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Deepjyoty Roy, thanks for watching!
      In your scenario, you can remove the Authorize attribute and inside of each method check for User.Identity.IsAuthenticated, and based on that throw Unauthorised with you custom messages per method.

  • @sri3884
    @sri3884 2 ปีที่แล้ว

    Great content 👏👏 , Thank you

  • @knightmarerip711
    @knightmarerip711 3 ปีที่แล้ว

    Excellent work explaining this!

  • @jashsudip
    @jashsudip 3 ปีที่แล้ว

    really helpful to understand the jwt authentication. please make a video on refresh token also

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Sudip Jash, thanks for watching. I already have a video on refresh token on my channel.

  • @stephenviswaraj7463
    @stephenviswaraj7463 4 ปีที่แล้ว

    Excellent Show, thanks much.

  • @codewithsakti8197
    @codewithsakti8197 10 หลายเดือนก่อน

    Thanks . Perfect video

  • @ravindranaths513
    @ravindranaths513 4 ปีที่แล้ว

    Hi, at timeline of 11:26 in this video, you added 1 hour as expiration. I tried with 1 min.
    But, after 2 min also, I could able to use same token and get the data. Means: token is not expired.
    Could you please help me on this.

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      @Ravindranath S, I will try it out and let you know.

    • @umairghouri1718
      @umairghouri1718 4 ปีที่แล้ว +1

      @@DotNetCoreCentral we have to use UseExpirationValidation in AddJwtBearer configuation

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      @@umairghouri1718 thanks for the suggestion!

  • @Uzair_Anwar2299
    @Uzair_Anwar2299 2 ปีที่แล้ว

    Hi. Good video. But what is the purpose of audience nd issuerence?

  • @jspalding70
    @jspalding70 4 ปีที่แล้ว

    Thank you for the knowledge you shared. What are the headers that I should be using with Postman?

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว +1

      In header you have to put “bearer token”

  • @tertulianeo
    @tertulianeo 3 ปีที่แล้ว

    My Authorization header is missing IDK why but I don't have problems with other headers, is there a way to change the header name?

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว +1

      @tertulianeo, how are you passing the header? can you share the code?

    • @tertulianeo
      @tertulianeo 3 ปีที่แล้ว

      @@DotNetCoreCentral ty, it was a problem with my cloud front

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @@tertulianeo great to hear your issue is resolved!

  • @girijesh-mca
    @girijesh-mca 4 ปีที่แล้ว +1

    Very nice explanation !!! Just one query I have in simple asp.net api we used Owin and OAuth to generate and validate token but I dint see OAuth implementation in Core is there any reason ?

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว +2

      OAuth can be implemented by a middleware. I do not see any reason why it cannot be. I will give it a try. I did not have the need yet, hence I did not try it yet. I will post my video after I try it out. Thanks for the question.

    • @girijesh-mca
      @girijesh-mca 4 ปีที่แล้ว +1

      @@DotNetCoreCentral Thank you so much.

  • @ravindranaths513
    @ravindranaths513 4 ปีที่แล้ว

    Hi, At timeline of 10:23 in this video, I have two questions here.
    1) Why you used SecurityTokenDescriptor (from Microsoft.IdentityModel.Tokens); why not JwtSecurityToken (from System.IdentityModel.Tokens.Jwt)?
    2) What is the difference between Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor and System.IdentityModel.Tokens.Jwt.JwtSecurityToken classes? When to use which?.

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว +1

      @Ravindranath S, JwtSecurityTokenHandler expects SecurityTokenDescriptor from Microsoft.IdentityModel.Tokens, hence. You can use JwtSecurityToken to create token, in that case, you will need to call WriteToken, instead of CreateToken on the JwtSecurityTokenHandler instance.

  • @marcotaliente4785
    @marcotaliente4785 3 ปีที่แล้ว

    Thank you man, that is what i sought for

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว +1

      @Marco Taliente, thanks for watching, and glad this video helped you!

  • @rivaldovola9896
    @rivaldovola9896 2 ปีที่แล้ว

    how to send the authentication header with each call. like what you did in postman?

    • @DotNetCoreCentral
      @DotNetCoreCentral  2 ปีที่แล้ว +1

      you set it in the header section of the Postman with Authorization header

    • @rivaldovola9896
      @rivaldovola9896 2 ปีที่แล้ว

      @@DotNetCoreCentral sorry not what i meant to ask. How do I send the header with each call in my api. After i get my token out of my api login. How to I send that token with another call to get authorized?

    • @DotNetCoreCentral
      @DotNetCoreCentral  2 ปีที่แล้ว

      @@rivaldovola9896 Postman has concept of environment variable which you can use to save the token and pass it along to rest of the calls

  • @shubhamshaw2360
    @shubhamshaw2360 3 ปีที่แล้ว

    Hi, why did you uncheck the "Configure for HTTPS" and check "Docker enabled" option while creating the project? It'll be really helpful info if you tell us.

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Shubham Shaw, there is no particular reason. You can keep both enabled.

    • @johnnybravo8932
      @johnnybravo8932 ปีที่แล้ว

      If you configure https you will need SSL certificate. While running in localhost you can do with http.

  • @vivekgowda1576
    @vivekgowda1576 4 ปีที่แล้ว

    Hi , Have you used ever redis cache in identity server 4 to improve the preformation

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว +1

      @vivek Gowda, no, I have never used it. But it's a good idea I would guess. I might give it a try.

    • @vivekgowda1576
      @vivekgowda1576 4 ปีที่แล้ว

      @@DotNetCoreCentral thank you 😀

  • @shsikzuhair4393
    @shsikzuhair4393 3 ปีที่แล้ว

    Thanks....good explanation

  • @alibux
    @alibux 4 ปีที่แล้ว +1

    Thank you for this very helpful video and sharing your knowledge! Subscribed!

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      @Rehan Alibux, thanks for watching the video and subscribing to my channel!

  • @varmasanjaym
    @varmasanjaym 4 ปีที่แล้ว

    Hi, I see that the AuthenticationHandler class comes under two namespaces.
    - Microsoft.AspNetCore.Authentication
    - Microsoft.Owin.Security.Infrastructure
    could you please explain what factors decide the namespace I need to use.

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      @sanjay varma, Microsoft.Owin.Security.Infrastructure
      is the legacy namespace. If you are using ASP.Net Core 3.1 you should be using Microsoft.AspNetCore.Authentication
      .

  • @hindachokri5463
    @hindachokri5463 3 ปีที่แล้ว

    Thank you for this helpful video. Keep doing the good work.

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Hinda Chokri, thanks for watching and taking the time to provide a comment!

  • @Thegeektoendallgeeks
    @Thegeektoendallgeeks 4 ปีที่แล้ว

    why is making the IJwtAuthenticationManager necessary?

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      @Thegeektoendallgeeks, thanks for watching! The JWTAuthenticationManager class is responsible for validating credentials and generate tokens. In a real-world scenario, this class might be just a proxy to an external authentication service for credentials validation, or it might interact with a data store for credentials. I hope this answers your question.

    • @Thegeektoendallgeeks
      @Thegeektoendallgeeks 4 ปีที่แล้ว

      @@DotNetCoreCentral that helps thank you, on a separate note. I have a asp.net core web app (MVC) with authentication individual user accounts project I want to add JWT authentication similar to this, but I can't seem to figure out where to start regarding getting the user credentials to apply all of this to.

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      @@Thegeektoendallgeeks it should be the same as this demo since ASP.NET MVC also shares the same middleware pipeline as Web API. If you are facing any specific issue, and if you can share the code in GitHub, I can definitely take a look.

  • @georgetuccio6053
    @georgetuccio6053 2 ปีที่แล้ว

    Very nicely done. Thank you.

  • @bhanushkaekanayake9988
    @bhanushkaekanayake9988 3 ปีที่แล้ว

    This is really good. Thanks..

  • @shashivishw803
    @shashivishw803 3 ปีที่แล้ว

    im getting 404 not found in get when im trying to get values1 and values 2

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @shashi vishw, if you can share your code in GitHub I can take a look, thanks.

  • @chandusubhakarareddysatti3569
    @chandusubhakarareddysatti3569 3 ปีที่แล้ว

    Hi Thaks for the video, I have a couple of questions . can you please clarify this?
    1. I got a token from the server. I just passed it to someone to use this token. he could able to access the API with the token until it expires. How can we restrict this?
    2. I got a token from the server with an expiry time of 15 min. before 15 min I hit token controller and got another token with an expiry time of 15 min. Now I have two tokens with valid time. will the two tokens work? or only the latest one?
    if so how can we validate?

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Chandu Subhakara Reddy Satti
      1. If you pass the token to someone else purposefully, there is nothing that can be done here right. Until the token expires that person will have access to your API unless you keep all tokens in storage and check against that, in which case you can flag the token.
      2. It depends if you are keeping the tokens in storage, in that case, you can have an implementation of invalidating older tokens when you send out new tokens. Otherwise, both will be valid.

  • @ToTo-vx2ix
    @ToTo-vx2ix 4 ปีที่แล้ว

    can this jwt auth method used to verify access on controller page not controller api?

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      @ToTo, yes it can be used anywhere since it is implemented in middleware.

    • @ToTo-vx2ix
      @ToTo-vx2ix 4 ปีที่แล้ว

      @@DotNetCoreCentral is it possible to give an example on how to access authorize controller page? im not sure on how to put the token to access it

    • @ToTo-vx2ix
      @ToTo-vx2ix 4 ปีที่แล้ว

      @@DotNetCoreCentral i already try to access api controller with token using postman and its work fine

  • @Ramesh_Kumar_TG
    @Ramesh_Kumar_TG 3 ปีที่แล้ว

    how to validate bearer token - if you put post man bearer token its allow to hit the method i want to how to validate bearer token and the method

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Ramesh Kumar, in the controller you will need to do this:
      if (!User.Identity.IsAuthenticated)
      return Unauthorized();
      Rest will be taken care of by the middleware.

  • @jvvable
    @jvvable 3 ปีที่แล้ว

    Thanks for your video, a Very Good explanation. I have a suggestion. if you can list out all the dependencies that will be great.

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @jvv (vvj), thanks for watching and the suggestion!

  • @kadavilk
    @kadavilk 3 ปีที่แล้ว

    Great video brother. If you could explain why we are using each commend and its benefits would have been really helpful.

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Kishor Kadavil, thanks for watching and great feedback, I will work on this.

  • @AjithChanaka
    @AjithChanaka 4 ปีที่แล้ว

    Thank you for making it easy understanding.

  • @rishukumar7586
    @rishukumar7586 2 ปีที่แล้ว

    which the best place to store that private key?

    • @DotNetCoreCentral
      @DotNetCoreCentral  2 ปีที่แล้ว

      Normally I use the AWS Secret server, most of the cloud providers will have something similar.

  • @gautamsaraswat1541
    @gautamsaraswat1541 4 ปีที่แล้ว +1

    Great video. Keep doing the good work

  • @ajithjacob2054
    @ajithjacob2054 4 ปีที่แล้ว

    Please help me ,i am getting error from postman when i tried to access get after applying [authorize] error : similar to 403 forbidden, but specifically for use when authentication is possible but has falied or not yet provided.The response must inculde a www -authenticate header field conataining a challenge applicable to the requested resource

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว +1

      @Ajith Jacob, I am not sure I completely understand the question, I will definitely look into it tomorrow, and if I have any doubt about your issue I will get back to you. Thanks!

    • @ajithjacob2054
      @ajithjacob2054 4 ปีที่แล้ว

      @@DotNetCoreCentral thanks for your reply. Let me explain the error.i have implemented the jwt token functionality and set attribute as allowanomus . So from postman i am able to generate the token .
      Then I decorated the get action method with authorize attribute and tried to access it from postman using the jwt token generated, that time I am getting the above error from postman

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      @@ajithjacob2054 I tried to reproduce your issue, but since I am not able to see your code its hard to reproduce. This is the location of the demo code, where I am not able to reproduce the issue. Maybe if you compare your code with mine, you will be able to get some clue what is going on. github.com/choudhurynirjhar/auth-demo

  • @rahulmathew8713
    @rahulmathew8713 3 ปีที่แล้ว

    Awesome keep up the good work

  • @furkand275
    @furkand275 3 ปีที่แล้ว

    why do we need to "var tokenKey = Encoding.ASCII.GetBytes(key); "

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Furkan D, thanks for watching! We need to pass byte array for the key, hence we need to get bytes from the string.

  • @ponvels
    @ponvels 3 ปีที่แล้ว

    username and password passed as json to get Token via authenticate may capture in fiddler and other tools. How the security of data is ensured if web api need serve in internet ?

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Ponvel Shanmuganathan, the API should be running on HTTPS to avoid this.

    • @ponvels
      @ponvels 3 ปีที่แล้ว

      @@DotNetCoreCentral Thanks for quick reply. I have deployed the sample code in my UAT server that get exposed on the internet via the public IP over https. I am still able to capture the Authorization : Bearer xxxxx data via fiddler. Let me clear my expectation. All the web api call after getting JWT token should not get exposed in any form. Even if we have 1 or 2 min expiration, until that time attacker can use the the captured token to reuse unauthorized.

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @@ponvels from local PC where the browser is running, the traffic can always be captured, the SSL is for stopping hackers from accessing data in the way. If your scenario when the user is logging in someone else is running Fiddler in the same machine at the time, I am not sure how practical this use case is.
      And if your concern is that the user leaves the website open on a public computer and someone comes in and tries to open the already open session in the web application, in that case, they already have the UI open, so the token is immaterial at this point. They can anyway access anything through UI.
      I am personally not aware of any mechanism to achieve what you want.
      If your use case is later, meaning the user leaves the UI in a public computer, the best solution is to add a log out strategy in the web application based on timeout.

    • @ponvels
      @ponvels 3 ปีที่แล้ว

      @@DotNetCoreCentral Hi - I am facing one more problem. after deploying this code in IIS. i am able to hit and get the result from the name controller via browser. Could you I tried adding another controller having same issue. please comment whether I am missing any thing.

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @@ponvels I am not sure I understood your problem. What happens when you add a new controller? What is the problem you are facing?

  • @nafeeskhan8249
    @nafeeskhan8249 3 ปีที่แล้ว

    Can you please provide the second part of this tutorial. It is very nice video. Awesome.

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Nafees Khan, thanks for watching! What are you expecting in the second part?

  • @sachindeshmukh5532
    @sachindeshmukh5532 3 ปีที่แล้ว

    Thank you so much for this video! it's really helpful..

  • @nrldcm1133
    @nrldcm1133 3 ปีที่แล้ว

    How about updating the token expiration when user tends to log out?. can you help me with that code?

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Norell Mantilla, I have a video on refresh token, you can refer to that and let me know if that works for you.

  • @mrjamiebowman
    @mrjamiebowman 3 ปีที่แล้ว +1

    This is great and I was able to replicate this. However, I'm wondering.. where do refresh tokens come into play?

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว +1

      @Jamie Bowman, refresh token comes to play when as an app you want to extend the token lifetime of the user without asking the user to enter id/pwd again for a new token after the initial token expired. The classic example will be a mobile application.

  • @eryogeshtripathi8888
    @eryogeshtripathi8888 3 ปีที่แล้ว

    Nice and simple video

  • @furkand275
    @furkand275 3 ปีที่แล้ว

    "The name 'Encoding' does not exist in the current context" how to deal with it?

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว +1

      @Furkan D, are you using the code as is? or you made some modifications? If you did, can you share your code in GitHub so I can take a look?

    • @furkand275
      @furkand275 3 ปีที่แล้ว

      @@DotNetCoreCentral i solved it thx anyway

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @@furkand275 glad it worked out!

  • @xinyuhou6535
    @xinyuhou6535 2 ปีที่แล้ว

    Hi thank you for posting this video. I find it very helpful. I have one question regarding the authentication step though. After receiving the token with a valid username + password combination and entering it as Authorization : Bearer[whitespace]token, the Get step still throws a 401 error. Any idea of what may cause this? Thanks!

    • @denespapp1963
      @denespapp1963 2 ปีที่แล้ว +1

      you can raise the logging level in the config and you can see the exact issue resulting in 401

  • @ajbotha7232
    @ajbotha7232 3 ปีที่แล้ว

    Thank you this is an awesome video

  • @rakshitkumar4838
    @rakshitkumar4838 3 ปีที่แล้ว

    How can i consume it in my mvc application??

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว +1

      @Rakshit Kumar, if you are using ASP.NET Core AMV it should be exactly the same as Web API

  • @abdullahhafeez7798
    @abdullahhafeez7798 3 ปีที่แล้ว +1

    where is the code link??

  • @NadirFirfire
    @NadirFirfire 2 ปีที่แล้ว

    v good video really helped me

  • @priyanshu4016
    @priyanshu4016 3 ปีที่แล้ว

    Great video, i request you to explain the token validation parameter , and token descriptor class properties significance and what situation what value we should set may help great if you do some short video on that portion

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว +1

      @Web Samurai, thanks for watching, I will try to do a video for that.

  • @namburinaveen5492
    @namburinaveen5492 3 ปีที่แล้ว

    Hi bro can you make a video on how to renew the expired token when user is in actively using webapi and web application

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว +1

      @namburi naveen, thanks for watching. I can do that.

  • @aditisen20
    @aditisen20 2 ปีที่แล้ว

    very well explained

  • @iamsidthebest007
    @iamsidthebest007 3 ปีที่แล้ว +1

    Thanks for the video. I followed exactly like you said. The token expiry I set as :
    Expires = DateTime.UtcNow.AddMinutes(Convert.ToDouble("20"));
    So, as you see I have set 20 minutes.
    I submit Authenticate request -> I get access_token, thats great!
    Now, I submit other API request with this access_token as bearer, I get the response as expected.
    Now, after 20 minutes, I try hitting the same endpoint, I still get response, even though 20 minutes have passed already. What am I missing? Please help.

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @Sid N, thanks for watching. I will take a look and let you know.

  • @jeffbreuninger7036
    @jeffbreuninger7036 4 ปีที่แล้ว

    Thank you! Very helpful tutorial.

  • @mahipala1952
    @mahipala1952 3 ปีที่แล้ว

    How to make jwt taken invalid on logout time??

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว

      @mahipal a, you can create a block list, and the tokens that are part of the block list will not be allowed.

  • @alihaydar3021
    @alihaydar3021 3 ปีที่แล้ว

    Good job 👍 .. what about refresh token?

    • @DotNetCoreCentral
      @DotNetCoreCentral  3 ปีที่แล้ว +1

      @
      Ali Haydar, thanks for watching! th-cam.com/video/7JP7V59X1sk/w-d-xo.html

  • @gabriel99999-r
    @gabriel99999-r 4 ปีที่แล้ว

    Can you do a playlist of these series please ?

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      Gabriel Luca I will surely do. Thanks for watching.

    • @gabriel99999-r
      @gabriel99999-r 4 ปีที่แล้ว

      @@DotNetCoreCentral great. Will you also add api versioning ?

    • @DotNetCoreCentral
      @DotNetCoreCentral  4 ปีที่แล้ว

      Gabriel Luca I’m sorry for late response. For some reason I did not get any notification. I’ll definitely do a video on API versioning.

  • @nileshmonde4879
    @nileshmonde4879 3 ปีที่แล้ว

    Nice one ... can we apply same for MVC 5

  • @SoftwareMahima2024
    @SoftwareMahima2024 3 ปีที่แล้ว

    Very good video

  • @Engineer_With_A_Life
    @Engineer_With_A_Life 3 ปีที่แล้ว

    this is awesome.. thanks a lot!