🔐

Spring Security

Authentication, filters, JWT, OAuth2 & production hardening

Practice interview questions on this topic →
1

Foundations: What Is Security, and Why Should You Care?

beginner

Every later chapter assumes you already know what a Filter is and why authentication and authorization are two different questions. This chapter is that foundation, built from zero prior security knowledge.

2

Spring Security Architecture: The Filter Chain & Internal Flow

beginner

Spring Security is implemented entirely as a chain of servlet filters. This chapter is that chain — what gets added the moment you include the starter, and the exact order requests flow through it.

3

Managing Users: UserDetailsService & UserDetailsManager

intermediatePro

Every authentication flow eventually needs to answer one question: who is this user, really? This chapter is UserDetailsService and UserDetailsManager — the mechanism Spring Security uses to look that up.

4

Password Security: Encoding, Encryption & Hashing

intermediatePro

"Just hash the password" hides three genuinely different techniques with very different security properties. This chapter is why only one of the three (hashing) is ever correct for passwords.

5

Custom AuthenticationProvider & Exception Handling

intermediatePro

The default DaoAuthenticationProvider covers the common case. This chapter is what to do when authentication needs custom logic — and how to handle it cleanly when authentication fails.

6

Session Management: Timeout, Concurrency & Fixation

intermediatePro

Session-based auth has its own failure modes that token-based auth simply doesn't share. This chapter is timeout, concurrent-session limits, and fixation attacks — and why REST APIs usually skip sessions entirely.

7

CORS: Cross-Origin Resource Sharing

intermediatePro

A frontend on one origin calling a backend on another is normal in modern architectures, and browsers block it by default. This chapter is what "origin" actually means and how to correctly unblock it.

8

CSRF: Cross-Site Request Forgery

advancedPro

CSRF protection is on by default in Spring Security for a specific reason tied to cookies — and disabling it globally to "fix" a 403 is one of the most common security regressions teams introduce.

9

Authorization: Roles, Authorities (RBAC) & Custom Filters

advancedPro

Authentication answers who you are. This chapter is authorization — roles, authorities, and how Spring Security actually decides what an authenticated user is allowed to do.

10

JWT: Token-Based Authentication

advancedPro

Session cookies don't scale cleanly across load-balanced servers or mobile clients. This chapter is JWT — a self-contained, signed token that carries identity without server-side session state.

11

Method-Level Security

advancedPro

URL-level authorization stops at the controller. This chapter is @PreAuthorize, @PostAuthorize, and filtering collections — enforcing rules at the exact method (or even list-of-results) level.

12

OAuth2 & OpenID Connect Deep Dive

advancedPro

"Login with Google" looks like one button but hides a specific, standardized protocol with four distinct actors. This chapter is OAuth2 and OpenID Connect, precisely.

13

Keycloak, Spring Authorization Server & Microservices Security

expertPro

A single microservice validating its own users doesn't scale to ten microservices. This chapter is centralizing authentication with Keycloak (or your own Spring Authorization Server) across a whole system.

14

Production Hardening, OWASP Top 10 & Best Practices

expertPro

Every prior chapter built one mechanism correctly in isolation. This closing chapter maps those mechanisms onto the OWASP API Security Top 10 and the real mistakes teams actually ship to production.