How To Build Your Own JWT Authentication With Spring WebFlux And Spring Security

Поділитися
Вставка
  • Опубліковано 10 січ 2025

КОМЕНТАРІ • 36

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

    Grab the code here axgr.dev/posts/spring-security-jwt/?

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

    Like somebody would said: "Work like a charm" -Thank you a lot Alex!

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

      Thanks Felipe, happy to hear that!

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

    Your /login implementation is great♥👍. Whats your opinion about handle /login in different way??. It goes to Manager (to validate username & password) and then going to Provider (to forming jwt). So no need to define /login in controller. That is how I am doing right now but not sure it is good or bad implementation. Because AFAIK in non-webflux security, there is no controller /login needed. So I think it should have same flow with non-webflux.

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

      Hey there, good question! If I were to do it again, I probably would do as you suggested: route all authentication matters to the AuthenticationManager and have a specific AuthenticationProvider since this is the correct way of doing it. In this video you can also see this flow ua-cam.com/video/I72lTb2O8ls/v-deo.html

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

    Thanks Alex, really educative and well presented content, helped me a lot

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

      Thanks Jiří, appreciate the feedback!

  • @ismaild.7766
    @ismaild.7766 2 роки тому

    Thank you for the amazing job. I also want to see you coding spring webflux security using graphql and explaining how to react when the jwt token expires. Thank you.

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

      Thanks İsmail, noted! I have tutorials on GraphQL coming up and will also certainly record a follow-up to JWT authentication!

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

    Hi Alex.
    Thank you so much for such a clear example.
    I have some trouble with your code example. When an exception happens while a token is analyzed I receive a 401 HTTP error with the header "WWW-Authorization=Basic realm ...". How can I cause to it to send me the www-autorization=bearer?

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

      Thank you for watching and sharing your feedback, Boris!

  • @guruprashanth_k
    @guruprashanth_k 3 роки тому

    @Alex - This is useful to get started. It would be helpful you had covered Oauth2 - Authorization Server, Oauth2 - Resource Server and Oauth2 protected REST resources seperately. If this is too much of asking then ignore :)

    • @alexgutjahr
      @alexgutjahr  3 роки тому

      Thanks mate, I'll definitely cover it in a dedicated video!

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

    are you using record or something new from java 17? Coz the syntax was throwing me off

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

      Yeah, I am not using Java at all - this tutorial makes use of Kotlin for the programming language.

  • @Trigoter
    @Trigoter 3 роки тому

    Hello, when I add firebase auth, the library does not appear. When I add storage, the library appears. Am auth does not appear. Help

    • @alexgutjahr
      @alexgutjahr  3 роки тому

      Thanks for your comment! Please note that Firebase is a different matter to what I have done in this video since Firebase is providing and validating the tokens. It goes beyond of this tutorial, but I will record a dedicated video showing how to make use of Firebase in Spring Boot.

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

    how can we throw
    custom exception
    when we get token-expired or invalid-signature

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

      Hey Muhammad, you can define your own exception like I have done here github.com/alexgutjahr/yt/blob/4308e482193e6f26573937a5474224b5459e440f/spring-jwt-auth/src/main/kotlin/com/alexgutjahr/Authentication.kt#L54

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

    hello alex, can you please do it for java

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

      Hey man, sorry, but I stopped writing Java code a long time ago and will only focus on Kotlin whenever I do Spring tutorials.

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

    Thanks a lot

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

    Thx you Alex

  • @АлександрБугримов-о1е

    Super

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

    Hi Alex
    I tested, the parser of jjwt can automatically throw "io.jsonwebtoken.ExpiredJwtException" when token is expired, so it's unnecessary to check it by user.

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

      Awesome, didn't know that - thanks for sharing!

  • @massiveblackwood
    @massiveblackwood 3 роки тому

    this wont work if i using oauth2.resourceserverspec.jwt

    • @alexgutjahr
      @alexgutjahr  3 роки тому

      Thanks for the comment and yes, there may be issues when you use this or other packages since I did not use them in my example so the code must be most likely changed for those packages.

    • @massiveblackwood
      @massiveblackwood 3 роки тому

      I think its the reactiveauthenticationmanager thing, i tried by force them to authenticate with onerrorrrsume the continuing jwt authentication i dont feel if its right.. have u tried to combine it? Using custom jwt along with resourceserverspec? it would be great tortorial videos since i havent found one yet

    • @alexgutjahr
      @alexgutjahr  3 роки тому +1

      @@massiveblackwood thanks for the feedback! No, I have not yet tried to combine the approaches, but added it to my backlog as a follow-up video.