Spring Security JWT: How to secure your Spring Boot REST APIs with JSON Web Tokens

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • In this tutorial, you are going to learn how to secure your Spring Boot REST APIs using JSON Web Tokens (JWT) with Spring Security.
    🔗Resources & Links mentioned in this video:
    Blog Post: www.danvega.de...
    WebSercurityConfigurerAdapter: • Spring Security withou...
    👋🏻Connect with me:
    Website: www.danvega.dev
    Twitter: / therealdanvega
    Github: github.com/dan...
    LinkedIn: / danvega
    Newsletter: www.danvega/de...
    SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️

КОМЕНТАРІ • 285

  • @ParnianAndIlian
    @ParnianAndIlian Рік тому +14

    Hi Dan, This is the tutorial that was missing in 2022. Thanks a lot. I was struggling with those outdated tutorials and dependencies to make a working solution. this saved me lots of time. Looking forward to your next videos.

    • @Scorpion2321-o9o
      @Scorpion2321-o9o Рік тому +2

      Same, Docs mentioned some stuff that are new but honestly Spring Boot Docs is not for Beginner.

  • @voiceofeverything
    @voiceofeverything Рік тому +3

    Great video. This is like the only one guide about this topic that is quite easy to follow and does not break your spirit (I have tried to follow like 2 different videos just to realize half way into 3 hour videos that implementation was changed/got deprecated and I wasted my time).

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

    thank you Dan, this video help me a lot to understand how to generate JWT in Spring. the only one site where I found the explanation with the new version of spring security and works. regards from Colombia

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

      Thank you! I'm glad my videos are helping.

  • @GiftNestah
    @GiftNestah Місяць тому +1

    Just what I needed after struggling with an issue whereby a single user's token expiry invalidates all other users' valid tokens leading to error 403 even for authenticated users. Thanks a lot for this 💯💯

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

    Thank you for making this tutorial. As you mentioned in the beginning there are so many more complicated ways of doing out there because the are not using what is built in to Spring Security. I unfortunately had used one of those more complicated ways so now I'm going to use what I learned in your tutorial to simplify my project code!

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

      Thank you Bob. Glad I could help out.

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

    I am a nodejs and Golang API. I found this tutorial very help for my current work using Spring-boot.
    One thing about Spring-boot is that, when you use Spring-Boot with higher version some errors like this shows up:
    This error occurs in the NimbusJwtDecoder.validateJwt method of the org.springframework.security.oauth2.jwt.NimbusJwtDecoder class. The NimbusJwtDecoder class is used to decode JSON Web Tokens (JWTs) and is part of the Spring Security OAuth 2.0 framework.

  • @AleksandarT10
    @AleksandarT10 2 роки тому +27

    Great video! Really helpful to get people started with latest Spring Security stuff and JWT! Few questions/comments though:
    1. It would be good if you can extend the github repo and add a branch which shows the symmetric key approach - i guess it would be easy for the Decoder as u mentioned, but would like to see how to change the Encoder
    2. Maybe to make it more realistic instead of HttpBasic - it would be good to have a UserNamePassword Authentication where the user calls an endpoint with username/password as body and the token generation happens based on that
    3. Building on top of 2), it would be great if this gets connected to a database where hashing + salting is used as this can be used as a starter for real projects
    4. Having roles in the example/video would be great
    Looking forward to your next video Dan!

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

      Great suggestions. Thank you Aleksander

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

      Is there any tutorial that would build on top of this I need the DB connection for users...

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

      @@lukamaletic9557 You could inject UserDetailsService in SecurityConfig rather than InMemoryUserDetails @Bean
      public UserDetailsService userDetailsService() {
      return username ->
      userRepository
      .findByUsername(username)
      .orElseThrow(() -> new UsernameNotFoundException("user not found"));
      }

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

    finally, an informative tutorial that ACTUALLY uses BUILTIN jwt tools, and not some filters and JwtUtility classes to secure an app

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

    I really appreciated this video. Wishes your channel get bigger n bigger.

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

    Thanks Dan, really educative content that's very well and clearly presented. Exactly what I was looking for!

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

      Thank you, glad I could help out.

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

    Thank you very much! Greetings from Greece!!!

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

    Awesome Dan! Thanks for the rich tutorial

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

    Very good video, if anybody haven't mentioned yet, it would be good to replace inMemory user with UserDetailsService on data base. Additionally securing rest api with roles. Video would be a bit longer than 1hours, but woud cover topic from A to Z

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

    Thank you Dan. I meant A LOT!
    Would you consider to create a video for those like me with a title "How to read Spring documentation and connect things together"? Lol. Thanks again!

  • @sharifyy
    @sharifyy 7 місяців тому

    I really enjoyed this video. Thank you for providing such great content.

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

    Great information. I think a simple video will also be helpful which explains how to protect API using Okta or Keycloak since in most situations you don’t write authorization server yourself.

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

    Wonderful. Very helpful. Thanks for sharing!!

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

      Glad it was helpful!

  • @temptrue3322
    @temptrue3322 Місяць тому

    top quality content. very infomative

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

    Thanks for asymmetric rsakeys knowledge you've shared.

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

    For me as a complete beginner it was so easy to follow. Thanks for this tutorial, it was really helpful.

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

      You're very welcome!

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

    Thank you for the tutorial

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

      You’re welcome 😊

  • @alx1024
    @alx1024 Рік тому +5

    Hi! Great video, like all your videos! Especially now that Spring Security 6 is mixed in with older tutorials on the web this is very helpful. A suggestion: this is now already deprecated: ".oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt)" and has to be replaced with ".oauth2ResourceServer((oauth2) -> oauth2.jwt(Customizer.withDefaults())". Also a question, how do you get this snippet-functionality at 30:00?

  • @samahmahdi5511
    @samahmahdi5511 4 місяці тому +2

    Thanks a lot, can you create new video for spring boot 3

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

    wonderful tutorial, thank toy very much 😊

  • @x2TruNation
    @x2TruNation Рік тому +4

    Hey Dan,
    New question, obviously us as viewers are following along and just basically copying the code that you write down - but you seem to know exactly what we need and why we need it.
    Are there any resources you can point me to that could potentially help me understand the architecture of spring security in more detail but also how you learned this to a point where you just know what you need to use?
    Bit of a loaded question, but i’m keen to learn as much as possible. Right now all it feels like is that i’m copying code from you without truly understanding why we’re doing certain things.
    Cheers

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

    Thanks for the video ❤

  • @fabricio.entringer
    @fabricio.entringer 2 роки тому +7

    Hello @Dan, it's amazing! Great video. Please keep producing videos regarding Spring Security, I think it's a black hole in the Spring modules. A lot of specific concepts and it deserves good videos with good explanations like yours. Congratulation and thanks for sharing the content.

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

    hey, this is one great :) ... but for some reason, this error showed up after trying to run the app (26:36) :(
    Any ideas?:/ We are forced to use Java 8 which does not include records yet.. so I created RsaKeyProperties class instead..
    Parameter 0 of constructor in com.greenfoxacademy.springwebapp.config.RsaKeyProperties required a bean of type 'java.security.interfaces.RSAPublicKey' that could not be found.
    Action:
    Consider defining a bean of type 'java.security.interfaces.RSAPublicKey' in your configuration.

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

      I have the same problem. What we can use instead of record in java8?

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

      Try this one
      @Configuration
      @ConfigurationProperties(prefix = "rsa")
      public class RsaKeyProperties {
      private RSAPublicKey publicKey;
      private RSAPrivateKey privateKey;
      public RSAPublicKey getPublicKey() {
      return publicKey;
      }
      public void setPublicKey(RSAPublicKey publicKey) {
      this.publicKey = publicKey;
      }
      public RSAPrivateKey getPrivateKey() {
      return privateKey;
      }
      public void setPrivateKey(RSAPrivateKey privateKey) {
      this.privateKey = privateKey;
      }
      }

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

    a video on keycloak and SSo auth? thank you! good video

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

      Thank you for the suggestions.

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

    awesome video! subscribed!

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

      Thanks for the sub!

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

    Great Video, keep up the good work

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

    Also to use the authorization as a micro service and export it, import it in multiple application across the company portfolio for a aligned one platform!

  • @TheGuroguro12
    @TheGuroguro12 10 місяців тому +2

    thank you very much !!! this is bread and butter even honey.
    if anybody wondering how to configure http basic to be used only for /token and all other endpoints with bearer check Den Vega -> how to create multiple spring security multiple configuration

    • @DanVega
      @DanVega  10 місяців тому

      You are welcome!

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

    Thank you teacher

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

    great video very useful

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

    Hi Dan, can you also please talk about how spring mvc works internally, like dispatcher servlet, how by default exceptions are handled in rest apis etc.

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

    hello great video btw can you do a video on opaque token that are stock in database

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

    Thanks for this video, it is like a revelation for me. But I think it would be better if we used HTTPS instead of HTTP for our endpoint URLs because of the BASIC type login.

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

    That was great! What about video about OAuth2 with Auth/Resource/Client?

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

    Fantastic content! A couple of suggestions request is to extend this video (or create a new one) where you actually secure a couple of REST endpoints using JWTs. Perhaps use the Spring Cloud Config Server to store the keys and the username and password or even better the Hashicorp Vault?

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

      Thank you for the suggestion. I have added it to my content suggestion list.
      github.com/danvega/office-hours/discussions/30

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

      Seconded Spring Cloud Config Server!

  • @rajibahmed-i2x
    @rajibahmed-i2x Рік тому

    First off awesome video Dan. I have seen no code/logic on the resource server side to validate token. Is this optional on resource server end or its a must.

  • @rajmohanparayil
    @rajmohanparayil 6 місяців тому +3

    Wow. Learned a lot of very relevant security implementation in a very smooth and clean fashion and in such a short time.

    • @DanVega
      @DanVega  6 місяців тому +1

      Glad you liked it!

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

    Thanks you.
    Can please explain also keycloak with spring.

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

    Very good your video!!!
    I have a question for you: since you said that this is the beginning with jwt and not the goal, what other functions can I do with jwt?

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

    awesome

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

    I'm guilty of rolling up my custom solution, pulling in a third party library. Thanks for this video, Dan! Gotta refactor a bit!

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

      Thanks Alex. Hope the refactor goes smooth.

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

      For some reason 99% of tutorials and guides on the internet use that approach instead of resource server.

  • @Justin-xy2ko
    @Justin-xy2ko Рік тому

    I love you dan vega. Minus points for not being Indian though

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

    Great video! Thanks a lot! I just have one question though: In Postman, you use bearer token as authorization type. The dropdown also offers "JWT token". Why did you not choose this option and took "bearer token" instead?

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

      I just don't think I realized there was a JWT option. At the end of the day it should be sent via bearer token so that option might just be a shortcut to do the same thing.

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

      @@DanVega Thanks for the quick response and for clearing things up!

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

    Amazing, how simple it is when explained by experts. Thanks for the great content. Well explained, with the right level of details to understand without getting overwhelmed.
    I still have to review the blog post if I am not missing any details.
    Looking forward for the next video :)

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

    I can't see jwt-home-controller-test in my Intellij IDEa. Is this a plugin or something?

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

      That is an IntelliJ Live Template... You can basically create snippets of code and I use them for demos or for repeating common tasks like setting up a logger.

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

    Thank You very much. Can you next guide us how to secure JWT in frontend app ? (ex: Vuejs or Nuxt) - that gonna be awesome.

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

      Thank you for the suggestion. I will get it added to the backlog.

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

    Thank you for this, Dan. I would love to see a follow up video for implementing "Refresh Token" on top of this :) I know people will love it.

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

      Thank you for the suggestion, it's already on the backlog.
      github.com/danvega/office-hours/discussions/27

  • @Hamzul.
    @Hamzul. Рік тому +1

    19:40 private key

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

    These videos are so concise and easy to follow, appreciate you.

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

      That makes me so happy. Thank you ☺️

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

    thank you so much ❤

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

    Great video as always! I got two questions though:
    Why does it needs to be annotated with @EnableWebSecurity. Is it like automatic once you added SecurityFilterChain in the app context?
    Can I create public and private key using keytool instead of openssl?

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

      It isn't automatic. Spring Boot will actually add it for you if you forgot it but I like to be explicit with it.
      If you don't want to use OpenSSL and you're just using self-signed certs you can generate them with code. I have an example of that in the following repository.
      github.com/danvega/jwt-username-password

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

    Thank you Dan! It is a great video. I wood like if you can provide a video showing how to consume these API from an other Spring boot Web application using Feign client how with JWT (aut he ti cation for the web app is throw the same api
    )

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

      Thank you for the suggestion. I have added it to my content idea list
      github.com/danvega/office-hours/discussions/29

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

      @@DanVega thank you

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

    Add Role & Permissions with RoleHeirarchy with spring security 6, Spring Boot 3

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

    I love your videos! I had a question on how you would approach deploying this application. I am trying to deploy to AWS beanstalk, but I'm having difficulties with the RSA .pem files. I have been trying to add the public and private keys as an environment property in elastic beanstalk, but am having difficulties because it is a string value and not a file. I also tried to add a key converter with @Component and @ConfigurationPropertiesBinding, but I still get a failed convert from string to RSAPublicKey. What do you think should be the approach/best practice to remedy this?

    • @우아한비비안
      @우아한비비안 Рік тому

      저도 이에대한 같은 오류가 발생했습니다 어떻게 해결할 수 있는지 궁금합니다

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

    No one has taught this way in youtube yet

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

    Hi, please can you do a tutorial on combining JWT authentication with google's Oauth2 SSO?

  • @rafijlouis2432
    @rafijlouis2432 Місяць тому

    Hi Dan, I love the way you explain and it’s much better than a lot of tutorials i have gone through. I have searched in udemy for a springboot course by you but i see it’s outdated. It would be wonderful if you could create a new course or atleast a series of videos of spring topics. Thank you.

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

    Hey Dan, it's amazing, but is there any mechanism in order the user logged out of the system, how we can invalidate the user token?

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

    Hello Dan, do you always need to encrypt ? If you care only on integrity and not on confidentiality of the token wouldn't be enough with signing the token (JWS vs JWE) ? Thanks!

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

      A JWT would just be a base64 encoded string without the encryption. You absolutely need to protect it.

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

    Hey! Great video! But how did you do to autogenerate code just by typing jwt? Thanks a lot!

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

    When the jar is run manually, there is a filenotfound exception. How do we handle this?

  • @НикитаПосмак
    @НикитаПосмак Рік тому +1

    Thank you Dan, it's a greate tutorial for beginners. Can you please make a guide about refreshing jwt please.

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

      Noted! I have this suggestion here github.com/danvega/office-hours/discussions/27

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

    I get 401 when trying to reach any endpoint. What should I do?

  • @kensaitakeso
    @kensaitakeso Рік тому +8

    Dan, why do you use @EnableWebCecurity and @Configutation together? as I see @EnableWebSecurity includes @Configutation within itself. Or am I missing something?

    • @DanVega
      @DanVega  Рік тому +4

      Nice catch, Serhii. You're correct, @EnableWebSecurity is all you need for that configuration class.

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

      @@DanVega Dan! plz share your magic jwt-test template! plz plz!! it is a really great thing. for all of us, it would be a great thing to study how to compose templates(i know you have such video but your template has a few tricks which were not included in that tutorial)

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

      @@kensaitakeso I have a video on my channel on how to create live templates. Other than that you can just copy the code from the repo and create your own.

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

    Thanks a lot for this tutorial. I have been stuck in other tutorials for hours.

  • @jy241
    @jy241 19 днів тому

    Thanks for the great video!! It helped me a lot!!!!

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

    dan what is the alternative to csrf should be used as it is deprecated in later spring security version 6.+?

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

    can u explain how to do this but with session cookies instead?

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

    Great video! Is there a way to user roles with the currente JWT configuration in this video?

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

      You can set the roles as part of the claim. I do have something on the backlog to create some content around this. If you want to add more to this you can.
      github.com/danvega/office-hours/discussions/8

  • @mondemlanshmi
    @mondemlanshmi 10 місяців тому

    Hi mam ,is it any simple way to generate ans filter the token on spring boot??

  • @roberthevesi
    @roberthevesi 10 місяців тому

    How do you have those shortcuts, such as at 39:16? Thanks.

  • @kozi-corner
    @kozi-corner 2 роки тому +1

    Thank you so much..I was just working on a project and had a lot of difficulties understanding JWT, I opened youtube and I found your video. How lucky I am!

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

      Thank you Abdelhamid. I hope this clears it up for you.

  • @coding619
    @coding619 3 місяці тому

    Hi Dan, Quick Question, This seems one sided, the configurations on the server side, but when client makes the request after the token is expired (i.e. 1 hour), how would the client get new access token without relogin.. Would I have to implement refresh token mechanism for that?
    My scenario, is to enable communication with jwt token between service 1 and service 2 both are REST based, so how can I achieve that?
    Should I make the JWT token as never expire?
    Please let me know. Thanks

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

    Hey Dan, quick question. I notice your .pem files are not pushed on the GitHub repository but you also did not gitignore them. How did you prevent pushing them to GitHub? And how do you deploy an app that relies on these files but does not have them on the repo.

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

    Great tutorial and topic. Really clears things out. Would be great to show next how to update JWT to include user's roles and permissions. And of course looking forward for Spring Authorization server!

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

      I actually set the authority and I believe in the repo there is an example of checking for it at the method level. If there isn’t let me know (I’m away from my computer at the moment)

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

    How on earth do I allow for Java 16+ Langauge Level? My Intellij only allows up to 15. Tried many JDKs (of Java 17 and 19) but it didn't fix it, it's still stuck on max version of 15.

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

    Sir, I was working on a project and while surfing the web for JWT, I came to know that JWTs are not safe when used on frontend applications on browser. They are open to XSS attacks. Also, disabling csrf() is not recommended when used with browsers (like ReactJS+Spring Boot). I don't fully understand what's wrong and what we should do. Please help!

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

    Great video! Thanks!
    Could you explain: you have showed the project creation with the spring starter io source. But, after project was created, you show 2 pom files - problem in that the spring.starter actually created only one single pom. How to I have to understand and follow your solution? And the main issue - I have implemented all steps and this solution doesn't work: yes, I received token, but this token doesn't work for other requests - I have receiving 401 error for all following requests. Now I try to understand the difference - and the difference only in the pom files between your and my code. But you are not explained them

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

    Hey Dan, great work, I have just one question that this oAuth2ResourceServer() takes one Customizer but the jwt() referened by method reference is not having void return type as of thr customize() of Customizer..and we are not getting compile time error...how it is possible?

  • @MatheusAlencar-n9u
    @MatheusAlencar-n9u 8 місяців тому

    Hi Dan. I managed to adapt it to work with UserDetailsService and it worked correctly. However, in my controller the Principal comes as an instance of org.springframework.security.oauth2.jwt.Jwt. I expected it to come as a User (which implements UserDetails), as I want to associate with other entities through JPA. What do you suggest?

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

    Nice video you just earn a subscriber I actually love the fact you don't define another class just to write another method like other youtubers do

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

      Thanks for the sub!

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

    Great vedio and i am on java 11 so i creating a record is not gona happen, so i tried to create a class equivalent to record but it require the bean of these kind
    java.security.interfaces.RSAPublicKey
    and when i create it saying cycling depency injection.
    Can i ask where does the RSAPublicKey and RSAPrivateKey instances comes from???

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

    Hi Dan, thanks for the great tutorial! I am facing a slight issue, not able to auto-generate the test class code, the way you do at 39:15, by writing "jwt-home-controller-test", is some plugin required for this? Thanks!

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

      Yes this is an IntelliJ live template. It’s not generating it it’s just pasting it in there. I use it to save time in demos.

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

      You can grab source from the repo

  • @FilipRafael-k5l
    @FilipRafael-k5l Рік тому

    Is anyone else getting a "There is no PasswordEncoder mapped for the id 'null'" Exception early in the video? Right after creating the SecurityConfig class and its first two methods.

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

    This is a great tutorial. You have a way of explaining complex topics in simple terms.
    I have subbed to your channel.

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

    Hi Dan.
    Since we're already on Spring Boot 3.2+ would you mind an update video on this matter?
    Keep up the good work!

  • @SanketShah-zs9dp
    @SanketShah-zs9dp 5 місяців тому

    Thanks for the video.
    When I put the following line in my SpringFilterChain, it shows the message "'jwt()' is deprecated since version 6.1 and marked for removal "
    .oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt)

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

    That is for access token.
    How about refresh token?

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

    How does it work with the private/public key, because now you are creating one on your pc, but if someone else is pulling the project to work on, how are they going to use the public/private key, what would you suggest fixing that problem?

  • @DeepakSharma-wi4wu
    @DeepakSharma-wi4wu Рік тому

    this works perfectly in locla but when I deploy it to external tomcat gives me 404 error. Any idea why ?

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

    Hi Sir, I'm novice in spring security, can you please tell me where is the logic behind to refresh token if it's expired?

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

    Hii Dan,
    I love ur tutorials.. my question is how can i create a seperate authentication servuce using jwt. And then use that is a seperate client service to secure endpoint? Thanks..

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

    Great video! You make it so easy to grasp the concept.
    A quick question. How would you secure the APIs using JWT if the application is using (username & password)
    in some cases and also biometrics authentication in other cases.

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

    Hi Dan, I did the constructor injection of RSA properties still getting the getting error parameter 0 of construtor and bean not found

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

    The only missing part of this is to deal with access useing: antMatchers("/admin").hasAnyAuthority("admin") in the Security Filter Chain