r/SpringBoot • • 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

26 comments sorted by

View all comments

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.

5

u/Sheldor5 Mar 02 '23

no wonder if uneducated people ask questions about topics which they don't even know their basics ...

you lear most of those things/principles in university (at least in my country) but most people who ask on SO or Reddit simply have never studied ... they go from "Java Hello World" straight to "Spring Security" which is the main issue here

9

u/[deleted] Mar 02 '23

Yep no argument. It's very common to see people with sod all experience asking how to build something vastly complex that usually takes a large team of experienced engineers to build.

But it could also be that a junior dev has been told "Oh, add Spring Security to this app" by someone senior who should know better than to drop someone in the deep end like that. Happens all the time.

0

u/Sheldor5 Mar 02 '23

most of the time I read those questions like "please do my job for free" while it's clear that they never googled JUST ONCE ... this is the main reason why SO is so hated by juniors, SO is "professionals for professionals" and was never intended to be a Q&A for juniors

4

u/[deleted] Mar 02 '23

I always thought it was a stupid name for the website anyway. Good luck finding any info about actual stack overflows any more.