Spring Boot + Spring Security with JPA authentication and MySQL from scratch - Java Brains

Поделиться
HTML-код
  • Опубликовано: 2 июн 2024
  • Let’s setup a brand new Spring Boot project from scratch with Spring Security that works with database authentication using JPA and connects to a MySQL database. I’ll walk you step-by-step through how to get Spring Security to connect to the MySQL instance using JPA and authenticate users against the user information stored in the database.
    Code: github.com/koushikkothagal/sp...
    Java Brains website: javabrains.io
    #JavaBrains #BrainBytes #HowTo #SpringSecurity #Spring #SpringBoot #Java #Tutorial

Комментарии • 456

  • @Sausty
    @Sausty 3 года назад +37

    Fantastic tutorial, probably the clearest tutorial I've ever watched on a pretty complicated subject. Thank you very much!

  • @damianw345
    @damianw345 4 года назад +23

    wow, these are the best tutorials on Spring Security I have ever found on the Internet. Please keep up the good job :)

  • @tsegaighebremedhin5536
    @tsegaighebremedhin5536 4 года назад +19

    Great Job Koushik!!! I like your teaching style and JavaBrains has been my main source of learning SpringBoot and java related stuff lately!!

  • @haimmichalashvili8251
    @haimmichalashvili8251 3 года назад +43

    Highly important guys.. at @01:14
    be aware, the role field must be save with "ROLE_" prefix in the DB, (dont know the reason). I wasted alot of time because I entered the authorization role mapping value which is without the "ROLE_" prefix.
    thank for the tutorial sir, BIG LIKE!

    • @hemantjain8777
      @hemantjain8777 3 года назад +2

      @Haim you are a life-saver. Spent like 1 hour to find out what was wrong.

    • @alessandrosantana9606
      @alessandrosantana9606 Год назад +1

      BIG THANKS MY MAN!

    • @swathikota
      @swathikota Год назад +2

      The hasRole and hasAnyRole methods used for authorizing requests accept parameters starting with "ROLE_". If you look at the java description for these methods, the parameters that are passed will be automatically appended with ROLE_ in the beginning. So definitely your database needs to have data starting with ROLE_ corresponding to role field or wherever you hard-code the authority value. This is my understanding.

  • @HanilKathuria
    @HanilKathuria 4 года назад +14

    Sir, you have made Spring Security so easy to understand. Thank you so much for your efforts😀

  • @sarthakgupta290
    @sarthakgupta290 Год назад +11

    Your way of explaining complicated concepts in a simple manner is outstanding! Thank you so much!

  • @kuljeetkumar4657
    @kuljeetkumar4657 4 года назад +30

    This is what is required on RUclips. Kudos sir
    Bring full stack courses also. I bet 1 million is not far away then.🙌

  • @Sebriniel
    @Sebriniel 3 года назад +3

    I've been struggling with Spring Security for days. Your tutorial made me able to install an authentication system on my app in two hours. THANKS!

  • @manojkanna222
    @manojkanna222 2 года назад +4

    I saw the whole spring security basic videos, everything till now was explained well. anyone can easily understand these spring security topics. Thank you for your time and effect

  • @sheelstera
    @sheelstera 4 года назад +11

    Great start to the weekend.. God bless.. Please cover JWT, OAuth and SAML

  • @bibekdas3592
    @bibekdas3592 3 года назад +2

    You are doing a great service by sharing all these...no praise will ever be enough..👍👍👍

  • @TomosLeggett
    @TomosLeggett Год назад

    I've watched almost every single video I could find on this subject and this was the clearest and most helpful and actually worked.
    Thank you for your help!

  • @brhaneweldeslase1289
    @brhaneweldeslase1289 4 года назад +4

    I am big fun of your teaching. I don't even want to go for other resources unless I don't find in Java Brains.
    I really appreciate your contribution to my life. You are such important to me."live long and God bless you."

  • @RDSRao
    @RDSRao 4 года назад

    Thank you once again, Kaushik for your time and teaching!

  • @mohitpatidar8880
    @mohitpatidar8880 3 года назад +2

    You are doing fabulous work Sir...( Y) Hats off to you for giving so much content to the community for free.

  • @divtosz
    @divtosz 4 года назад +2

    Thank you so much! You explain so clearly, much better than all the paid courses online! 😄

  • @Mohamed-uf5jh
    @Mohamed-uf5jh 4 года назад +1

    Thanks sir, these are the best tutorials on Spring Security I have seen
    on the Internet

  • @liferayasif9382
    @liferayasif9382 4 года назад

    Thank you so much, its always pleasant to watch your videos, crystal clear, in details and precise to point. Thank you so much for your tutorial.

  • @orhanyarar7552
    @orhanyarar7552 3 года назад

    thank you very much for putting this together. Your explanations are very clear, concise and to the point!

  • @midhunma8875
    @midhunma8875 17 дней назад

    Thanks, this is the clearest from scratch video i found so far..so difficult to explain yet you made it look easy

  • @Torayasu
    @Torayasu 2 года назад

    Clear and simple, managed to implement my own JPA authorization provider thanks to this video. Great Job !

  • @DrunkenEngineer
    @DrunkenEngineer 4 года назад +1

    Thank you for uploading such video's.
    Really helps a lot in Interviews.

  • @monishad7040
    @monishad7040 3 месяца назад

    Clearest tutorial with minimum time. Easy to understand. Thank you for wonderful lectures sir.

  • @igorgvozdic2769
    @igorgvozdic2769 3 года назад

    I have watched a ton of similar videos, but your videos are best by far!

  • @GreatAnubis
    @GreatAnubis Год назад

    I've been looking for such tutorial. Great video. Thank you!

  • @johngalarza-calderon4801
    @johngalarza-calderon4801 3 года назад +3

    This was amazing. So well planned and executed and explained wonderfully. You helped me grasp this which I was struggling with based on online text based tutorials that I had found. I will definitely be sending anyone I know trying to learn this as well here!

  • @AnantaAkash.Podder
    @AnantaAkash.Podder 5 месяцев назад

    By Far the Best Explanation of Spring Data JPA with Spring Security...got many concept cleared out of this Tutorial

  • @dinunclv
    @dinunclv 3 месяца назад

    really good series of tutorials. Great Job! Since spring 6 some things have slightly changed, but you explain the core principles very well. Thanks!

  • @akhilsamineni4628
    @akhilsamineni4628 4 года назад +1

    Really AWESOME!! One of the best videos I watched.

  • @deeptiadmile9986
    @deeptiadmile9986 4 года назад +5

    This security series is absolutely amazing !! All aspects for each type covered.. 😀👍

  • @bendego2800
    @bendego2800 3 года назад

    Thanks for coming back !!

  • @francogb
    @francogb 4 года назад +76

    Epic! Thank you!
    Please talk about integration with JWT

    • @SushilKumarBhaskar
      @SushilKumarBhaskar 4 года назад +1

      yes, eager to watch that integration with JWT,

    • @sujithg5873
      @sujithg5873 4 года назад

      Yess JWT 🙄🙄🙄🙄🙄

    • @reluscarlat7140
      @reluscarlat7140 4 года назад +5

      You can find well explained implementations of spring security with JWT in Laurentiu Spilca's spring security playlist:
      ruclips.net/video/zA3uxv8RMF0/видео.html
      There is pure gold information that really helped me to understand the basics of security for monolith applications and microservices applications.
      Hope it will help you! :)

  • @shivaakrish
    @shivaakrish 2 года назад

    This is one of the best tutorial i have seen in my entire life :D Thank you so much.

  • @thornton
    @thornton 3 года назад +6

    Thank you so much! This unblocked me on a problem I was having with my Repository.

  • @Runa_Nura
    @Runa_Nura 4 года назад

    The best video for Security. easy to understand and all codes works fine.
    Plz Mr make more videos for spring.

  • @yazidelhachimi1628
    @yazidelhachimi1628 2 года назад

    The best tutorial i've seen on youtube !! Thanks man !

  • @priyankjoshi3018
    @priyankjoshi3018 2 года назад +2

    Nice One Koushik, keep the good work up. With addition to all the information, would like to add, spring by default adds "ROLE_" to whatever the role we are trying to check for the user. Thats why Kaushik has inserted ROLE_USER in the roles column of the user table. Now why we are trying to access different urls, spring check the role using the class ExpressionUrlAuthorizationConfigurer which get called from the overriden method configured having HttpSecurity as parameter. Check the implementation for the method hasRole in the method chaining.

  • @vurihur4533
    @vurihur4533 2 года назад

    SIR the whole day I've been trying to get this to work... then 10 minutes in this video and it works now. I really thank you a lot!!!

  • @dhananitejendra3151
    @dhananitejendra3151 6 месяцев назад

    By far the best tutorials on spring security. Thanks a lot

  • @abhisheksengupta4159
    @abhisheksengupta4159 4 года назад

    Best video on spring security !! Thanks Kaushik :)

  • @SrivatsaLakshmi
    @SrivatsaLakshmi 3 года назад

    Fantastic tutorial. Well explained and easy to follow along.

  • @backtoGodhead0
    @backtoGodhead0 3 года назад

    Excellent, Thank you Kaushik, May God bless you!

  • @drawlzlolwlz5953
    @drawlzlolwlz5953 3 года назад +1

    Finished the tutorial! great job and explanation

  • @abukasozi295
    @abukasozi295 4 года назад +2

    This is pure awesomeness thankyou very much. Amazing!!!!

  • @dimimurik3970
    @dimimurik3970 3 года назад

    Very good tutorial, nice and clear explanations. Thanx a LOT!!

  • @rupeshsharma2453
    @rupeshsharma2453 3 года назад

    A very informative video on spring security. Thanks a lot. Cheers

  • @AdrianVrabie
    @AdrianVrabie 4 года назад +1

    Indeed, very well explained! I loved it! Subscribed + Shared!

  • @ivanetinajero
    @ivanetinajero 4 года назад +1

    Great Video. God bless you. Regards from Mexico!

  • @nitiKT
    @nitiKT Год назад

    Sir, hatsoff to you.. you made learning spring security enjoyable for me.. being dyslexic I hated spring security..

  • @AshenafiMaru-ul3rg
    @AshenafiMaru-ul3rg Год назад

    I never knew . . . Spring Boot Security is this easy . . . thanks to you brother!

  • @selvakumarm8948
    @selvakumarm8948 4 года назад

    Sir, Thanks for you effort to provide us great quality content. I really like your video style. :)

  • @ankitank1990
    @ankitank1990 3 года назад

    Thanks for your hard effort to make the things done. Awesome

  • @Chanakya0000
    @Chanakya0000 2 года назад

    You made it look so easy. Thank you.

  • @awadijohan
    @awadijohan Месяц назад

    really I'm so lucky to find your video that helped me well to understand and learn with simple method the authentication with spring security, really I appreciate your qualified explanation.
    big thanks from bottom of my heart ♥

  • @sugoi5240
    @sugoi5240 5 месяцев назад

    your explanation is so good i wanna cry

  • @samedsakhri5117
    @samedsakhri5117 4 года назад +1

    Best I've ever seen on youtube .. thks man 😀👍

  • @SushilKumarBhaskar
    @SushilKumarBhaskar 4 года назад +3

    Yes Correct, read query many times for authentication/authorization, we might consider using LDAP. LDAP has fast read query.

    • @Java.Brains
      @Java.Brains  4 года назад +2

      Well, authentication happens only once per session. Also, JPA could be supported by a caching mechanism so that an entity is not looked up more than once.

  • @ashokmandadi
    @ashokmandadi 4 года назад

    very good video bout spring security, usage of lamda expression also very nice

  • @ChathushkaPeiris
    @ChathushkaPeiris 2 года назад

    this is exactly i was looking for! thanks!

  • @anaghavarhade7375
    @anaghavarhade7375 3 года назад

    Thank you so much for these videos. They are very helpful ❤❤❤

  • @mlprasad79
    @mlprasad79 4 года назад +3

    This is good stuff ! Now my weekend is productive as I learned something new from this ! Long live KK !

  • @vasileiosstamos5940
    @vasileiosstamos5940 4 года назад

    Spring Security + JWT Authentication would be superb!

  • @firozgg7524
    @firozgg7524 4 года назад +2

    Tjank you so much brother... It was the best spring security tutorial i've ever watched so far...💜

  • @francescodigiuseppe73
    @francescodigiuseppe73 3 года назад

    Thanks a lot Prof, you're my best teacher

  • @muditshukla
    @muditshukla 4 года назад

    Great tutorial Sir. Hats Off.

  • @beginner-techies6793
    @beginner-techies6793 4 года назад

    wow , amazing explanation, waiting your video on spring boot with keycloak

  • @ilyesdjerroud7003
    @ilyesdjerroud7003 4 года назад

    Hello , thank you so much for your work ! We ARE waiting for LDAP lessons please :) !

  • @badripaudel77
    @badripaudel77 3 года назад +3

    Did anyone try , this project no longer works ? I cloned it and it doesn't work. Says forbidden (403).

  • @priscillavannyamelia8736
    @priscillavannyamelia8736 Год назад

    Amazing tutorial, thank you for creating this video

  • @ArvindYadav-cn4md
    @ArvindYadav-cn4md 4 года назад

    Great job Sir. This is what required.. thank you v much.

  • @goonerritz93
    @goonerritz93 3 года назад

    Great tutorial! Thank you!

  • @nageshmath9376
    @nageshmath9376 4 года назад

    Art of coding ,simple and quick

  • @macmuffin1865
    @macmuffin1865 3 года назад

    Great tutorial. very clear!

  • @sandeepmreddy2788
    @sandeepmreddy2788 3 года назад

    Great effort, great explanation.. Thank you...!

  • @deepakkakkar7698
    @deepakkakkar7698 2 месяца назад

    Awesome explanation man,

  • @nithinvarghese7765
    @nithinvarghese7765 4 года назад

    great tutorial..and happy Onam🙂

  • @hyperborean72
    @hyperborean72 2 года назад

    thank you so much for the amazing tutorial

  • @KalizVids
    @KalizVids 2 года назад

    Perfect tutorial, thanks so much

  • @himanshusinghcoolboy
    @himanshusinghcoolboy 4 года назад

    very good and useful stuff, Please make some series about reactive programming with spring.

  • @prageethjayasinghe709
    @prageethjayasinghe709 3 года назад

    Perfect teaching skills.

  • @buckg2129
    @buckg2129 4 года назад

    Incredibly helpful!

  • @pratik037
    @pratik037 4 года назад +1

    Hello, first of all, great tutorial.
    Just needed help with a small doubt. Can you show how did you make the active column in the table empty(valueless) and still not displaying null in the CLI? Thanks.

  • @arungore6578
    @arungore6578 4 года назад +2

    Early morning .. good start

  • @ayaagourram7363
    @ayaagourram7363 3 года назад

    Great job ! Thank you Sir !

  • @user-rh7fg5gn4b
    @user-rh7fg5gn4b 4 года назад +1

    very good tutorial Dear MAN!

  • @thilinad.gunasekara7281
    @thilinad.gunasekara7281 3 года назад

    It's helped me so much. Thanks.

  • @arashaadd
    @arashaadd 2 года назад

    this man is the greatest of all time!!!

  • @krishnakishore3258
    @krishnakishore3258 4 года назад

    Thanks a lot for this excellent content.

  • @jeeperscreepers7
    @jeeperscreepers7 3 года назад

    Love the video! thank you!

  • @SushilKumarBhaskar
    @SushilKumarBhaskar 4 года назад +29

    Please🙏 upload LDAP supported Spring security ... Eager to watch

    • @s3649
      @s3649 3 года назад

      ruclips.net/video/-wDUChgvYgU/видео.html

  • @daniellaerachannel
    @daniellaerachannel 4 года назад

    more and more and more and more spring please!!!!! thanks a lot

  • @codegeek8256
    @codegeek8256 4 года назад

    Thank You so much Koushik

  • @krishmetalhead
    @krishmetalhead 4 года назад

    Such a good video. Very Nice .

  • @souvikdasgupta8960
    @souvikdasgupta8960 4 года назад +2

    Very nicely explained.
    Can you make a tutorial on Spring security + oauth2

  • @saivamsikrishnakataru4583
    @saivamsikrishnakataru4583 3 года назад

    Thank you very much sir
    It worked very well

  • @tedodjukic4789
    @tedodjukic4789 3 года назад

    very good explained!

  • @ayzaz_m6289
    @ayzaz_m6289 4 года назад +1

    Thank you so much Sir !!!

  • @umairkhan4085
    @umairkhan4085 3 года назад +15

    if @Autowired UserDetailsServices in SecurityCnfiguration is showing error it is due to multiple implementations of that interface spring is confused which one to choose.
    solutiion :add @Primary annotation above MyUserDataService class that will give preference to your implementation

    • @hrvooje
      @hrvooje 2 года назад

      Or use @Qualifier("myUserDetailsService")
      @Autowired
      UserDetailsService userDetailsService;

  • @rudraniroy2718
    @rudraniroy2718 4 года назад

    Hey , Thak you for this great video. Could you please start a segment on Spring batch as well.

  • @wildanekaputra912
    @wildanekaputra912 9 месяцев назад

    Sir, you deserve a noble.