r/SpringBoot • u/Substantial-Habit-94 • Mar 02 '23
How to learn Spring Security.
I have to learn Spring Security for my job. I have implemented Rest Apis using spring boot till now. i know Java and Spring Boot. But Spring Security is too confusing for me to understand. I feel like i am missing something. Are there any prerequisites of learning spring boot. Any resources or any recommendations from experienced devs? Guide me please.
37
Upvotes
28
u/[deleted] Mar 02 '23
It's no surprise that so many people find Spring Security confusing, to be honest. It encapsulates a number of different disciplines under the one banner of "security".
protecting your API resources with OAuth2 or SAML
Providing form login for your web app
providing oauth2 login from third party providers
providing OIDC or SAML federation for your application
protecting your webapp against CSRF and similar exploits
providing authorisation services to others
These really aren't all the same thing, but they all fall under the same project. No wonder people get confused.
The way to approach it is not to just google "Spring security tutorial" but to decide first what it is that you want to do, exactly, and research that. The official docs are actually quite useful once you do that, but trying to digest the entire project is pointless and wasteful.
I think what you're missing is the insight that Spring Security addresses a bunch of disparate concerns which are at best loosely related, all using similar mechanisms: a chain of filters. Once that clicks, and once you realise that all the security DSL config et al are doing is building up a chain of filters which will act upon your requests, it starts making more sense. Once it clicks that you can have more than one of these filter chains, it makes even more sense.