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!
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.
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."
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
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!
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.
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.
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 ♥
You can find well explained implementations of spring security with JWT in Laurentiu Spilca's spring security playlist: th-cam.com/video/zA3uxv8RMF0/w-d-xo.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! :)
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
Congratulations #JavaBrains. It's the best tutorial I've read about Spring Security + JPA. It's almost complete. Thanks you very much! Pd: I think you should endcoder your password with other tecnique, because it inserts plain-text password.
This tutorial is really helping me alot. Explained so perfectly. here we have created our MyUserDetailsService, but autowired instance of UserDetailsService. Still worked !! Should we MyUserDetailsService ?
17:20 Spring boot verison 2.3.1.RELEASE When creating a dummy UserDetailsService, you also need to comment out the spring-boot-starter-data-jpa in the pom.xml else the server application will fail to start.
I thought there was a problem in SQL server and I was going to remove the mysql driver dependency from the pom.xml Thanks for your help @Dinesh Shekhawat
I changed the Naming Strategy in properties as the one used in this tutorial is deprecated in Hibernate 5 spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
We are just passing the username for fetching the user details, how does the password is verified during authentication. As in all cases till now we are not verifying the password.
some DBs (like postgresql) does not allow to create database with name 'springsecurity' and table with name 'user' .. probably because they are reserved words .. try using different names in such cases
I tried the Exact same as you explained. But when I login with "/admin" {There was an unexpected error (type=Forbidden, status=403).} this error is comming. Please help
Got an Error? Please check if your security dependency is the same as OP. I had three different security dependency that does not produce error until running.
Quick question: I have understood and implemented all of this. I have a user that exists inside the DB, and when I try to log him in, all is fine, I get a jwt back and all of that stuff. But when I try to access the /login rest point with invalid credentials, I get a 403 forbidden instead of "username not found". What am I doing wrong? Note: I also set my requests to permitAll(), so that's not to blame.
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!
@Haim you are a life-saver. Spent like 1 hour to find out what was wrong.
BIG THANKS MY MAN!
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.
Your way of explaining complicated concepts in a simple manner is outstanding! Thank you so much!
This is what is required on TH-cam. Kudos sir
Bring full stack courses also. I bet 1 million is not far away then.🙌
Clearest tutorial with minimum time. Easy to understand. Thank you for wonderful lectures sir.
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."
Fantastic tutorial, probably the clearest tutorial I've ever watched on a pretty complicated subject. Thank you very much!
By Far the Best Explanation of Spring Data JPA with Spring Security...got many concept cleared out of this Tutorial
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
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!
Sir, you have made Spring Security so easy to understand. Thank you so much for your efforts😀
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!!!
Sir, hatsoff to you.. you made learning spring security enjoyable for me.. being dyslexic I hated spring security..
Thanks, this is the clearest from scratch video i found so far..so difficult to explain yet you made it look easy
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!
wow, these are the best tutorials on Spring Security I have ever found on the Internet. Please keep up the good job :)
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.
Yes Correct, read query many times for authentication/authorization, we might consider using LDAP. LDAP has fast read query.
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.
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 ♥
Clear and simple, managed to implement my own JPA authorization provider thanks to this video. Great Job !
Epic! Thank you!
Please talk about integration with JWT
yes, eager to watch that integration with JWT,
Yess JWT 🙄🙄🙄🙄🙄
You can find well explained implementations of spring security with JWT in Laurentiu Spilca's spring security playlist:
th-cam.com/video/zA3uxv8RMF0/w-d-xo.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! :)
really good series of tutorials. Great Job! Since spring 6 some things have slightly changed, but you explain the core principles very well. Thanks!
You are doing a great service by sharing all these...no praise will ever be enough..👍👍👍
Great Job Koushik!!! I like your teaching style and JavaBrains has been my main source of learning SpringBoot and java related stuff lately!!
You are doing fabulous work Sir...( Y) Hats off to you for giving so much content to the community for free.
By far the best tutorials on spring security. Thanks a lot
I never knew . . . Spring Boot Security is this easy . . . thanks to you brother!
The best video for Security. easy to understand and all codes works fine.
Plz Mr make more videos for spring.
Best tutorial ever! It is definitely worth your time
I have watched a ton of similar videos, but your videos are best by far!
Thank you so much! You explain so clearly, much better than all the paid courses online! 😄
This is one of the best tutorial i have seen in my entire life :D Thank you so much.
Thanks for coming back !!
Thanks sir, these are the best tutorials on Spring Security I have seen
on the Internet
your explanation is so good i wanna cry
The best tutorial i've seen on youtube !! Thanks man !
Thank you so much! This unblocked me on a problem I was having with my Repository.
It's importante to note that you must add the prefix ROLE_ in MyUserDetails class otherwise it could return a 403 when trying to log in.
Thanks for this.. i have been facing this issue.. But , how can we get rid of this explicitly.
Great start to the weekend.. God bless.. Please cover JWT, OAuth and SAML
this man is the greatest of all time!!!
Art of coding ,simple and quick
This security series is absolutely amazing !! All aspects for each type covered.. 😀👍
I've been looking for such tutorial. Great video. Thank you!
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
Or use @Qualifier("myUserDetailsService")
@Autowired
UserDetailsService userDetailsService;
Thank you for uploading such video's.
Really helps a lot in Interviews.
Thank you once again, Kaushik for your time and teaching!
Excellent, Thank you Kaushik, May God bless you!
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.
Finished the tutorial! great job and explanation
Sir, you deserve a noble.
A very informative video on spring security. Thanks a lot. Cheers
This is good stuff ! Now my weekend is productive as I learned something new from this ! Long live KK !
Really AWESOME!! One of the best videos I watched.
Spring Security + JWT Authentication would be superb!
thank you very much for putting this together. Your explanations are very clear, concise and to the point!
Before I watched I just click like button 👍
Perfect teaching skills.
Best video on spring security !! Thanks Kaushik :)
very good video bout spring security, usage of lamda expression also very nice
Best I've ever seen on youtube .. thks man 😀👍
Congratulations #JavaBrains. It's the best tutorial I've read about Spring Security + JPA. It's almost complete. Thanks you very much!
Pd: I think you should endcoder your password with other tecnique, because it inserts plain-text password.
Yes, I do mention that use no-op encoding for simplicity. check out the password encoding tutorial on my channel to learn about password encoding!
This tutorial is really helping me alot. Explained so perfectly.
here we have created our MyUserDetailsService, but autowired instance of UserDetailsService. Still worked !! Should we MyUserDetailsService ?
This is pure awesomeness thankyou very much. Amazing!!!!
17:20
Spring boot verison 2.3.1.RELEASE
When creating a dummy UserDetailsService, you also need to comment out the spring-boot-starter-data-jpa in the pom.xml else the server application will fail to start.
Thanks bro , i was thinking the problem was in Mysql
I thought there was a problem in SQL server and I was going to remove the mysql driver dependency from the pom.xml
Thanks for your help @Dinesh Shekhawat
It's actually a problem with having 2 UserDetailsService beans.
You have to qualify which to use.
@@zephyrred3366 so which to use?
@@zephyrred3366 @Qualifier doesnt work.It gives the same error
Very good tutorial, nice and clear explanations. Thanx a LOT!!
Fantastic tutorial. Well explained and easy to follow along.
If you are getting a 403 make sure that the role column in USER table = "ROLE_ADMIN"
Awesome explanation man,
Indeed, very well explained! I loved it! Subscribed + Shared!
Did anyone try , this project no longer works ? I cloned it and it doesn't work. Says forbidden (403).
Amazing tutorial, thank you for creating this video
You made it look so easy. Thank you.
wow , amazing explanation, waiting your video on spring boot with keycloak
Could you make few tutorials that talks about handling user session management after login, thread local etc
Thanks a lot Prof, you're my best teacher
Thank you so much for these videos. They are very helpful ❤❤❤
this is exactly i was looking for! thanks!
Thanks for your hard effort to make the things done. Awesome
I changed the Naming Strategy in properties as the one used in this tutorial is deprecated in Hibernate 5
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
This fixes my issue as well.
Great Video. God bless you. Regards from Mexico!
U do best videos for beginners too....I like the way u explain....can u please explain how u created that instance service class in
at 31:52 why did he change the constructor calling which will anyway give the object of the MyUserDetails , so why did he change?
Tjank you so much brother... It was the best spring security tutorial i've ever watched so far...💜
Sir, Thanks for you effort to provide us great quality content. I really like your video style. :)
Early morning .. good start
more and more and more and more spring please!!!!! thanks a lot
We are just passing the username for fetching the user details, how does the password is verified during authentication. As in all cases till now we are not verifying the password.
Hey Koushik, Please use white background for IntelliJ - its difficult to view
Hello , thank you so much for your work ! We ARE waiting for LDAP lessons please :) !
some DBs (like postgresql) does not allow to create database with name 'springsecurity' and table with name 'user' .. probably because they are reserved words .. try using different names in such cases
thank you so much for the amazing tutorial
10/10 tutorial!
Great tutorial. very clear!
Great effort, great explanation.. Thank you...!
Great tutorial Sir. Hats Off.
Please🙏 upload LDAP supported Spring security ... Eager to watch
th-cam.com/video/-wDUChgvYgU/w-d-xo.html
Great job Sir. This is what required.. thank you v much.
I tried the Exact same as you explained. But when I login with "/admin" {There was an unexpected error (type=Forbidden, status=403).} this error is comming. Please help
Thank you very much sir
It worked very well
Got an Error?
Please check if your security dependency is the same as OP.
I had three different security dependency that does not produce error until running.
Quick question: I have understood and implemented all of this. I have a user that exists inside the DB, and when I try to log him in, all is fine, I get a jwt back and all of that stuff. But when I try to access the /login rest point with invalid credentials, I get a 403 forbidden instead of "username not found". What am I doing wrong? Note: I also set my requests to permitAll(), so that's not to blame.