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

4

u/wanjalize Mar 03 '23

Spring or spring security is built on servlets and jsps. So maybe look at servlets and jsp before diving into spring security. The two technologies mentioned talk deeply about filters. Again, if you are going to learn about something don't jump directly into something that has been implemented. What I mean is look for a tutorial whereby the tutor explains aspects of spring security from the ground up (only indians do this). Once you have the basics you can easily move into anything advanced like oauth2, keycloak etc. What I am proposing could take maybe a week to fulfil but since you work I doubt you have that much time so maybe look for short articles that explain about the topic.

2

u/Substantial-Habit-94 Mar 03 '23

Yah i don't have enough time and i have to do Jwt authentication can't wrap my head around filters.

1

u/smokemonstr Mar 05 '23

Check out https://docs.spring.io/spring-security/reference/servlet/oauth2/resource-server/index.html

protecting endpoints by using two forms of OAuth 2.0 Bearer Tokens:

  • JWT

  • Opaque Tokens

2

u/[deleted] Jan 31 '24

wdym by "only Indians do this"? I know there are a lot of indian tutorials online about a bunch of stuff but majority of them are superficial. They talk about the surface level stuff without diving deep and explaining the inner working of things.

3

u/wanjalize Feb 02 '24

Those are not the Indians that I've been exposed to because the ones that I know always teach from the ground up. Americans and other popular YouTubers like to teach the hot stuff or the stuff that'll get them followers.

4

u/[deleted] Feb 02 '24

That is completely the opposite of what's out there on the internet. Take a look at 3Blue1Brown for example and compare it to the indian mathematics channels on youtube. What Indian channels do is directly jump onto how you'd solve a particular type of question with a method. It's basically rote learning. Also I am an Indian and I know what kinda stuff people refer to.

1

u/LowStatistician11 Oct 30 '25

you could also look at udemy courses (or yt videos that cover less stuff) from abdul bari. he 100% put me through dsa at college when i was sick and couldn't attend. idk if he's indian but definitely south asian. also telusko is solid.

1

u/[deleted] Oct 31 '25

Of course there's exceptions but the general trend is as clear as day. Most indians want nothing more than surface level knowledge. I have met very few Indians who were willing to go past the rote learning and dive into the actual meat of the subject matter. Hence, now we have most of indians teaching surface level stuff on online platforms. And of course the indian education system encourages this idiot behavior

1

u/LowStatistician11 Oct 31 '25

i was gonna type an actual response but then i looked at your profile and realized you’re just an indian guy who hates indians. lol get some help all hope is not lost yet.

1

u/[deleted] Nov 01 '25

Woahh make sure to stretch before reaching that far. I don't hate anyone(except muslims), I just like to speak my mind. I'll call out whites, blacks, asians, etc whoever I damn well please. I'm not big on concepts of tribalism like yourself which makes me a lot more impartial in my judgement compared to you

1

u/LowStatistician11 Nov 01 '25

lol whatever you wanna believe man

1

u/[deleted] Nov 02 '25

Aka I don't have any valid rebuttal

3

u/rieckpil Mar 08 '23

This two and a half hours talk/workshop gave me a lot of great insights and practical advice on Spring Security https://www.youtube.com/watch?v=iJ2muJniikY

3

u/Substantial-Habit-94 Mar 10 '23

Thanks man. Great resource

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.

6

u/Pedantic_Phoenix Mar 02 '23

To be guided you need to ask specific questions. Watch videos, everyone will recommend you the ones from Amigoscode.

3

u/Ruin-Capable Mar 02 '23

The documentation talking about the overall architecture of Spring Security was very helpful for me.

3

u/[deleted] Mar 03 '23

I have found it very helpful to use Chat GPT when I want to learn more about a certain part of Spring Security. It is pretty good at explaining certain concepts and provide me with example code to demonstrate. Of course this is to be done with caution, but it has helped me to understand Spring Security bit for bit

8

u/[deleted] Mar 03 '23

But how do you know when it's wrong?