Key Concepts
| Topic | Sub-Topics | Basic | Intermediate | Advanced | Expert |
|---|---|---|---|---|---|
| Authentication Basics | UsernamePasswordAuthenticationToken, AuthenticationManager | ✅ | ✅ | ||
| Authorization Basics | Role-based access, Authority checks | ✅ | ✅ | ||
| Security Filters | FilterChainProxy, DelegatingFilterProxy | ✅ | ✅ | ||
| CSRF Protection | CSRF token, CsrfFilter | ✅ | ✅ | ||
| Password Encoding | BCryptPasswordEncoder, DelegatingPasswordEncoder | ✅ | ✅ | ||
| UserDetailsService | Custom user details, InMemoryUserDetailsManager | ✅ | ✅ | ||
| Method Security | @PreAuthorize, @PostAuthorize, @Secured | ✅ | ✅ | ||
| SecurityContext | SecurityContextHolder, ThreadLocal | ✅ | ✅ | ||
| Session Management | Session fixation, Concurrent sessions | ✅ | ✅ | ||
| Remember-Me Authentication | Persistent tokens, Cookies | ✅ | ✅ | ||
| Exception Handling | AccessDeniedHandler, AuthenticationEntryPoint | ✅ | ✅ | ||
| JWT Authentication | Token generation, Token validation | ✅ | ✅ | ✅ | |
| OAuth2 Login | Authorization Code flow, PKCE | ✅ | ✅ | ✅ | |
| Resource Server | JWT validation, Introspection endpoint | ✅ | ✅ | ✅ | |
| OpenID Connect | ID Token, UserInfo endpoint | ✅ | ✅ | ||
| Multi-Factor Authentication | OTP, TOTP, SMS/Email | ✅ | ✅ | ||
| Custom Authentication | Custom AuthenticationProvider, AuthenticationToken | ✅ | ✅ | ✅ | |
| Custom Filters | OncePerRequestFilter, AbstractAuthenticationProcessingFilter | ✅ | ✅ | ✅ | |
| Access Control Expressions | SpEL, custom permission evaluators | ✅ | ✅ | ✅ | |
| Security Testing | WithMockUser, Spring Security Test | ✅ | ✅ | ✅ | |
| Reactive Security | Spring WebFlux Security, ServerHttpSecurity | ✅ | ✅ | ✅ | |
| Microservices Security | Service-to-service auth, Gateway filters | ✅ | ✅ | ||
| Integration with LDAP | LDAPAuthenticationProvider, Active Directory | ✅ | ✅ | ✅ | |
| Security Hardening | Headers, XSS, Clickjacking protection | ✅ | ✅ | ✅ | ✅ |
| Distributed Security | SSO, Federated identity, Keycloak/Okta integration | ✅ | ✅ |
Spring Security Annotations
🔑 Authentication & Authorization
@EnableWebSecurity- Enables Spring Security configuration.@AuthenticationPrincipal- Access the currently authenticated user in a controller.@WithMockUser- Used in tests to mock an authenticated user.@WithUserDetails- Used in tests with aUserDetailsService-based user.
🛡️ Method-Level Security
@EnableMethodSecurity(Spring Security 6+) - Enables method-level security annotations.@EnableGlobalMethodSecurity(Legacy) - Enables method-level security (pre Spring 6).@Secured- Restricts access to methods by roles.@PreAuthorize- Defines access before a method is invoked (using SpEL).@PostAuthorize- Defines access after a method is invoked (using SpEL).@PreFilter- Filters input collection/array before method execution.@PostFilter- Filters return values after method execution.
🧩 OAuth2 & OpenID Connect
@EnableOAuth2Sso- Enables OAuth2 Single Sign-On.@EnableAuthorizationServer- Marks a configuration as an OAuth2 Authorization Server.@EnableResourceServer- Marks a configuration as a Resource Server.@RegisteredOAuth2AuthorizedClient- Injects an authorized OAuth2 client.@CurrentSecurityContext- Access the currentSecurityContext.
🔍 Testing & Mocking
@WithAnonymousUser- Simulates an anonymous (unauthenticated) user in tests.@WithSecurityContext- Customizes security context for tests.
⚙️ Miscellaneous
@Order- Defines filter chain execution order in Spring Security filters.@EnableReactiveMethodSecurity- Enables method-level security for WebFlux.