Spring Boot and Spring Security with JWT including Access and Refresh Tokens 🔑

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

КОМЕНТАРІ • 821

  • @saywuat
    @saywuat 3 роки тому +48

    I'm impressed - you provided a full example of a JWT implementation. I can follow each step and you explain every step very well. Trying to look all of this stuff up by myself would have cost me months. THANK YOU, SIR!

  • @avm0101
    @avm0101 2 роки тому +8

    This is a fantastic tutorial. Even-though some of the concepts like "WebSecurityConfigurerAdapter" are deprecated, it was good to know. This is the first time I have actually understood the flow of authentication and authorization. Thank you.

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

    His voice is so calm and soothing, it didn't stress me at all. Good job!

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

    after searching for clean and understandable explanation for 3 months
    i finally found the best one . nice & clean

  • @nunoaparicio4426
    @nunoaparicio4426 3 роки тому +14

    Yesterday I was looking for this exact tutorial on your channel and today you upload this! Just perfect! Thanks 😁

  • @OldManRog
    @OldManRog 3 роки тому +101

    This was a fun project, I learned how to secure my API routes, how to authenticate & authorize as well as sending a refresh token. It would be awesome if you do this project again but with the best practices. Maybe like a follow up or more advanced video. Thank you both of you guys for providing such an informative tutorial.

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

      I know I'm a bit late but did you also name your main entity class "User". I named my Employee and then used the User class from the security package. And I'm struggling to figure out which one to use for the refresh token part.

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

      @@brandonalfaro42 you have to use your personal class User, beacause he use the repository on it.

  • @gficeis
    @gficeis 2 роки тому +7

    Simple, direct and efficient. You have the gift of explaining!
    Nothing more to say. Thank you sir!

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

    Man, you saved me. This is exactly I was looking for, with examples and the explanation of each line you're into.

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

    Amazing tutorial, the best one about Spring Security and JWT I've seen so far, thank you very much for posting this for free!

  • @Kevinppaulo
    @Kevinppaulo 3 роки тому +3

    I just got back at studying Spring, and this video came in PERFRECT timing. Love your content, thank you!

  • @programmer4226
    @programmer4226 3 роки тому +8

    Man you explain everything so well and in detail. Very few people on the internet do this. Thank you ! :)

  • @HouariZegai
    @HouariZegai 3 роки тому +25

    Amazing like always Nelson!
    Thanks for the richest content you provide to the community.

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

    I'm already working as developer using Spring (at a major global company) but the code is so unstructured. What you're teaching is really clean and best practice.so good

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

    That was one of the best tutorial I have seen in youtube. As always you deserve like and comment bro. Good job.

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

    hello Amigoscode i'm from VietNam. First of all, thank you very much for the knowledge shared in this video. It helped me a lot in my final major assignment in college. Wishing you good health and good luck.

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

    Your video contains a lot of best practices, that's among things that distinguish it from other tutorials.
    Thank you and keep going.

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

    Gotta love how the video quality increases each time! Well done Nelson

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

      IF FBI watch this security video . We also must watch this video ))

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

    Best security course hands-on I have seen so far , take my hat off

  • @preto115
    @preto115 3 роки тому +4

    Thanks so much for spreading out your wonderfull knowlegde on this subject. It simply blows my mind how you master the subject and how you are able to explained every single point in the code and how is your profound knowledgement to resolve error when they show up! Congratulations for your expertise on teaching also... I am a true begginner in this area and the way you master this subject is really wonderful.

  • @MuhammadAnas-g8f
    @MuhammadAnas-g8f Рік тому

    Best Video on UA-cam about JWT Token in Spring Boot

  • @WaclawShuminski
    @WaclawShuminski 3 роки тому +3

    OMG It's really great tutorial! Thank you man a lot!
    Also, we can place constant URLs such as "/login" or "/token/refresh" as static final fields in SecurityConfig and just use them wherever we want - in Filters, Resource Controllers, anywhere. And we just have to edit them once only at that point.

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

      Good tip Constants are quite useful here.

  • @anonymous-cb2bi
    @anonymous-cb2bi 3 роки тому

    Amazing work, i got few questions from your precedent video about spring security but this one helped me to comprehend better, not even asked that you provided for us, thanks a lot pal :)

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

    Your videos are amazing I rarely saw such a good content with good explanations when it is needed. Great job and thank you!

  • @azizmavlyanov3145
    @azizmavlyanov3145 3 роки тому +4

    As usual, your tutorial/course is awesome. Thank you so much!

  • @gt-uj6fz
    @gt-uj6fz 2 роки тому +5

    hello, i realized that websecurityconfigureadapter is deprecated since springboot 2.7.0. Are you going to make video of how to use it , mean without using websecurityconfigureadapter, i tried to apply it, it did not work for me? thanks

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

    At 1:20:08 your screen cuts out on the far right side when dealing with setting up the roles as claims. What is the last part of that statement? .collect(Collect.......

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

    Really a best explanation and great video in UA-cam for JWT implementation 👌🏻 keep rocking bro

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

    Salaam Brother - Eid Mubarak. Long waited for video. MANY THANKS

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

    That's perfectly matched what I need! Thanks for the high-quality tutorial.

  • @alexanderkolosov1371
    @alexanderkolosov1371 2 роки тому +7

    That's awesome as always! It would be also really helpful if you could show us how to configure security without WebSecurityConfigurerAdapter, cause it's deprecated since Spring Security 5.7.0-M2. Thanks!!!

    • @JamesSmith-us3ne
      @JamesSmith-us3ne 2 роки тому

      I had the same issue, I decided to change my Spring Boot version to

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

      @@JamesSmith-us3ne See my comment above

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

    Very good tutorial!
    In my opinion, it is currently the best on youtube for that topic

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

    Thank You bro for this wonderful lesson!i finished this lession , simple, efficient, nothing more to say ! Thank you !:)

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

    Honestly just want to say thank you so much for taking the time and effort it took to make this
    really guys, this is legendary.
    I am super grateful.
    Thank you.

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

    I love you for this. You are the only one that knew how to explain. Thank you so much! Liked and Subscribed!

  • @andreasaltwegg576
    @andreasaltwegg576 3 роки тому +4

    cool video .. only thing .. when sending a refreshToken to get a new accessToken, it is good practice to create a new refreshToken as well. small thing but it helps, that the refreshToken always has longer expire date-time then the accessToken.

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

    Nelson. thank you for your dedication... i started spring couple of months ago and you have been a blessing to me.. kindly do tutorial on sign up/ register, login and log out in spring boot api using JWT

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

    WebSecurityConfigurerAdapter depreciated. Need help introducing SecurityFilterChain please.

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

    Walaikum assalam brother... I m very happy to see you here...
    Doing great work brother...

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

    Perfect. it was really useful . Ur content is always rich and I learned so much from U.
    Thank U amigoscode.

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

    You helped me out a lot Amigo! I'm looking forward to an Angular masterclass.

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

    I'm really impressed this tutorial.
    Thank you very much for sharing this amazing tutorial 😊

  • @ar-ul5kj
    @ar-ul5kj 2 роки тому

    Excellent video mate! Thank you for sharing knowledge in such clear manner :)

  • @KishoreKumar-sl6fk
    @KishoreKumar-sl6fk 2 роки тому +2

    Wonderful course !!! Thanks a ton for taking time and coming up with something this good. its very helpful.!!!
    Unable to find the GITHub link for this tutorial, pls share github link 😞

  • @serdaratadurdyyew1333
    @serdaratadurdyyew1333 3 роки тому +37

    It would be nice to add front-end to this project, to see how the front side of the application deals with the tokens

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

      am stuck here like i have to post the data through front end tried everything

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

      ​@@AKIvarma you can use postman/curl/any other tool that does requests or write some tests to simulate the requests and etc to do what you want.

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

    can we get updated version? This method was deprecated in 5.7.0

  • @Adam-qn9uq
    @Adam-qn9uq 2 роки тому

    🙏 Much much appreciated !!
    You're becoming my reliable resource for my study 👍
    As-salamu alaykum ☺

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

    Thanks for the great explanation and tutorial. It really really helps me.بَارَكَ اللهُ لَكَ

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

    Beautiful course on Spring Security! Congratulations.

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

    1:48:30 Hey, I didn't see this error but just 403 status code. There shouldn't be a JSON response body because missing "Bearer" results in going to the last else block which doens't handle JSON response.

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

      This helped me tremendously

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

      @@brando3179 Please how did you resolved the issue because I'm facing the same thing here

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

      I can’t exactly remember but you might have to put runtime exception in the last else block. Tbh if you want to actually learn spring security I would watch laur spilicas videos

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

      @@brando3179 I'm facing the same, I'd really appreciate it if you could double check?

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

    Hello 👋
    Please can you make an updated version of this video since the webSecurityConfigurerAdapter is deprecated and spring recommend using the Filter chain concept
    Thank you 😊

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

    Really amazing content, Amigo! You're awesome at explaining things.

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

    Salam Amigos - A react course would go viral and would be appreciated by the internet world

  • @shoeb.joarder
    @shoeb.joarder 5 місяців тому +1

    @2:01:29 you can replace *.equals()* with *.startsWith()* to allow the endpoints starting with a prefix. Therefore, a possible solution is _request.getServletPath().startsWith("/api/token")_

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

    Thanks for posting these videos . It's very helpful. Keep post such great content

  • @dnlnfr
    @dnlnfr 3 роки тому +30

    Hi Nelson, I follow your channel and I started programming in Java thanks to your really well done videos. The passion you transmit in teaching is incredible. I am still very inexperienced and I am approaching software applications with microservices architectures. I'm struggling a bit to understand how to start a microservice and how to get them to communicate with them. I can't quite understand how to integrate Docker and Kubernetes. When you get the chance will you be able to make a small example of how to create multiple microservices in spring boot and integrate Docker with Kubernetes? Thanks Nelson. Support from Italy!

    • @amigoscode
      @amigoscode  3 роки тому +14

      Hi 👋🏿 thanks for the comment. Coming soon what you are asking

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

      @@amigoscode Thank you so much Nelson!

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

      I would love to see this examples of microservices talking to each other! Thanks Nelson!

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

    Im very excited to see your video course about jwt with refresh token, thanks:)

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

    Hello, i can login with x-www-form-urlencoded, but when i using json username and password is null, how can i fix it?

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

    Thanks for the vid, woah that is a heck of a lot of info to take in for someone who is new. Guess I'm gonna have to use this project I made alongside the video as a "cheat" when working on this in the future

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

    Jazaka Allaho Khayr Bro Neslon! Just on time.

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

    Wow! your video is really awesome and information you have depicted is precise. Love you and following your channel. Thank you so much for your video and love to see more videos in youtube.

  • @gamer-jg7rj
    @gamer-jg7rj 3 роки тому

    Wow!This is a reaaaaaaaally good course. Thanks my friend.

  • @Renardbardhi1
    @Renardbardhi1 2 роки тому +6

    I just wanted to ask about the end point "/login" I did not see it somewhere. Please can you explain when you sue /login end point the flow on the code works? Thank you very much

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

    1:20:24 The code after "Collector" can't be seen clearly

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

    You are such a talented explanator. Thank you

  • @bartdiako1
    @bartdiako1 3 роки тому +3

    Is there a git repo that we can chek out?

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

    thank you very much for creating this video...cleared my concepts on spring security

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

    This tutorial is amazing! Since the WebSecurityConfigurerAdapter has been deprecated in the latest version of Spring Boot/Security, is there a new video planned to update the content of this portion of the tutorial? It would be nice to see how set the SecurityConfiguration class using the @EnableGlobalMethodSecurity annotation, use the SecurityFilterChain class. Meanwhile, I'll try to convert that portion of the tutorial and figure it out. Again, thank you! Very informative!

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

    Very nice, thanks for sharing your knowledge.

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

    1:44:00 at line number 55, in the else statement you are allowing all requests with no authorization header. They should he blocked right?

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

    thank you, i love well-rounded tutorials like this. very useful.

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

    Thank you for share your knowledge, this would be very helpful for my personal projects :D

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

    Hello! Thank you very much!! Now WebSecurityConfigurerAdapter seems to be deprecated, any suggestions?

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

    at 1:33:02 wouldn't it be more correct to put swap line 41 and 42? Or how does the order work?

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

    Outdated tutorial but all required information are given ! Thanks :)

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

    Good job guys! Thank you for sharing your knowledge! 👌🌄

  • @astartes-gym
    @astartes-gym 2 роки тому

    1:53:35 , I get an exception: " .filter.CustomAuthorizationFilter : Error logging in: Cannot read the array length because "array" is null "

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

    Hey Nelson, first of all I wanted to thank you for your videos and the work you put into them. I wanted to ask you, if you could make a updated version of this video, with the new Bean based Security configuration stuff. I just don't get it to work. It always breaks and I have tried pretty much everything that came in my mind or what I found on google. I am not using spring for that long so I am still kinda new to the whole topic. I would really appreciate it! Keep it up man!

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

    I benefited a lot from this course thank you very much brother Nelson

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

    This video can't get any better. I've been searching for a video that explains the working of these security classes. All that regular courses included were spring auto security configuration, usage of jsp pages and not really getting into the core and playing around.

  • @baismail-daily
    @baismail-daily 3 роки тому

    Wa Aleykoum Salam brother
    Good to see you again

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

    Amazing course!! Very well done, thankyou!

  • @DatGunitKilla
    @DatGunitKilla 2 роки тому +6

    Following this tutorial, it's cool so far, good lookin' out! Just a little comment: you mentioned calling the class "User" is a bad idea, but actually, it's a terrible idea. I picked PostgreSQL instead of MySQL, and apparently, User's a restricted keyword there, so it was crashing, until I changed User into something else ("Member" in my case)

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

      I encountered the same problem, luckily I decided to check the comments pretty quickly. Thank you, you saved me hours of debugging and research!

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

      %100, thank you.

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

      Thanks buddy.

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

      You also can specify table name like @Table(value="users") on entity and postgres accepts it

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

      also you can add new property in applicatiom.properties file:
      spring.jpa.properties.hibernate.auto_quote_keyword=true
      This will be add quote to keywords

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

    this tutorial is pure gold! Awesome!

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

    what theme you use for intellij idea?

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

    I'm not sure I understand why at 1:44:05 you let a request continue even though the request doesn't have an authorisation header and is not an authentication request. What scenario could there be for this?

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

    Asslam o Alaikum Sir first of all great effort great course thank you soooooo much for that
    May grant you best reward for this

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

    Thanks a lot for your video lessons! They are great and easy to understand and implement!

  • @lurby89
    @lurby89 3 роки тому +3

    Is possible to implements this configuration to an angular frontend login and registration forms?? Thank you

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

    Aleykum Selam brother, you and getarrays are awesome. May Allah bless you thanks to these free courses which helping people a lot. Greetings from Turkey 🇹🇷

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

    Awesome, please make more videos junior with authentication...oauth....
    Loved it!!!!!

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

    Thank you so much again,
    Nice Video, I hope you make a new video that talking about best practices of using Spring Security with other microservices and with API gateway existence.

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

    Thanks a lot!
    However, where can I find the example source code for this? At 32:38, you say it is in the description, but it isn't.

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

    Great tutorial brother! JazakAllah Khayr

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

    I have been waiting for something like this for a while

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

    thanks brrrooooo!!,but where can i download you color theme for java ? it is so fancy!

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

    what color theme are you useing in IntelliJ ?

  • @ДанилаКононихин
    @ДанилаКононихин 3 роки тому +2

    If I see 404 error when I'm trying to access to localhost:8080/login, what should I do?

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

    Damn! this tutorial is everything! Thanks Amiscode

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

    good job Nelson, excelent explanation as usual!

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

    Great video. One word of warning though. Be careful catching all exceptions as is done in doFilterInternal method as is done at 1:43:50. Any exceptions coming from later in the filter will be caught here and you may end up with a red herring "401 unauthorized error" which is nothing to do with authorization.
    I hope this saves someone the frustration of trying to debug an authorization problem which isn't even there.