🧩 1. Core Spring Security Architecture
Q1. What are the main components of Spring Security?
Q2. Explain the Spring Security filter chain and how it works internally.
Q3. What is the difference between FilterChainProxy
and DelegatingFilterProxy
?
Q4. How does Spring Security integrate with the Servlet container?
Q5. What is the role of SecurityContext
and SecurityContextHolder
?
🔐 2. Authentication & Authorization
Q6. Explain the authentication flow in Spring Security.
Q7. What is the difference between AuthenticationManager
and AuthenticationProvider
?
Q8. How does Spring Security handle authorization decisions?
Q9. What is the purpose of AccessDecisionManager
and AccessDecisionVoter
?
Q10. How do you customize authentication (e.g., using database, LDAP, JWT, or OAuth)?
💾 3. JWT (JSON Web Token) & Stateless Authentication
Q11. Explain how JWT-based authentication works in Spring Security.
Q12. What are the pros and cons of using JWT vs session-based authentication?
Q13. How do you implement token invalidation (logout) in JWT-based systems?
Q14. How can you refresh JWT tokens securely?
Q15. How would you prevent token replay attacks?
🧰 4. Configuration Approaches
Q16. What’s the difference between WebSecurityConfigurerAdapter
and the new SecurityFilterChain
approach (Spring Security 5.7+)?
Q17. How do you configure multiple HttpSecurity
instances for different API paths?
Q18. How would you disable security for a specific endpoint (e.g., /health
, /actuator
)?
Q19. How to secure REST APIs using Spring Security annotations (@PreAuthorize
, @Secured
)?
Q20. Explain method-level vs URL-level security.
⚙️ 5. Customization & Extensibility
Q21. How do you create a custom authentication filter?
Q22. How do you plug in a custom UserDetailsService
?
Q23. Explain how to add custom claims to JWT during login.
Q24. How do you handle multi-factor authentication (MFA) in Spring Security?
Q25. How can you secure microservices communicating over REST (e.g., internal JWT validation)?
🧠 6. Advanced Concepts
Q26. Explain SecurityContextPersistenceFilter
and its purpose.
Q27. What is AnonymousAuthenticationFilter
and when does it come into play?
Q28. How does Spring Security handle CSRF protection in REST APIs?
Q29. Explain how CORS and Spring Security interact.
Q30. What are stateless sessions, and how are they configured?
🧩 7. OAuth2 / OpenID Connect
Q31. Explain the OAuth2 authorization code flow.
Q32. What are the key differences between OAuth2 and OpenID Connect?
Q33. How would you secure a resource server and client application using Spring Security OAuth2?
Q34. What’s the difference between BearerTokenAuthenticationFilter
and BasicAuthenticationFilter
?
Q35. How do you refresh access tokens securely in OAuth2?
🧱 8. Security Best Practices
Q36. How do you prevent brute-force attacks in Spring Security?
Q37. How do you implement rate-limiting or IP-based blocking?
Q38. How do you store passwords securely in the database?
Q39. What are common security misconfigurations you’ve seen in Spring projects?
Q40. How do you secure WebSockets with Spring Security?
☁️ 9. Real-World & Integration
Q41. How would you design authentication for a microservices architecture (e.g., using JWT + Redis)?
Q42. How can you propagate authentication across multiple services (SSO)?
Q43. How to integrate Spring Security with AWS Cognito or Azure AD?
Q44. How do you secure actuator endpoints in production?
Q45. How do you test secured endpoints using JUnit and Mockito?
🧪 10. Troubleshooting & Debugging
Q46. How do you debug 403 Forbidden issues in Spring Security?
Q47. How do you log authentication and authorization events?
Q48. How do you verify your filter order in the Spring Security chain?
Q49. What’s the difference between @WithMockUser
and @WithUserDetails
in testing?
Q50. How would you profile or optimize security filters for performance?
✅ Bonus: Scenario-Based Questions
-
You need to allow multiple concurrent logins per user, but also support logout from all sessions — how do you implement it?
-
You want to support JWT authentication but also allow API key-based access for internal systems — how would you design it?
-
You want to cache user roles and permissions to avoid frequent DB hits — how would you do that securely?
-
You want to secure communication between two Spring Boot microservices — what’s your approach (TLS, JWT, OAuth2)?
-
How would you audit who accessed which endpoint and when?
Would you like me to create a PDF or a structured study sheet (with answers and diagrams for each topic like JWT, filter chain, etc.)?
It’s perfect for 10+ yrs Spring Security interview prep.