Back to blog Backend Interview

Top 50 Spring Security Interview Questions (Beginners → Advanced)

28 min readBackend Interview

Spring Security Fundamentals

1. What is Spring Security and why is it used?

Spring Security is a powerful security framework used to secure Spring applications.

Spring Security is mainly used for:

  • Authentication (who the user is)
  • Authorization (what the user can access)
  • Protecting APIs, web applications, and microservices
  • Handling security concerns like CSRF, CORS, session management, password encoding

It follows the principle of “secure by default” and integrates seamlessly with Spring Boot.

2. Explain authentication vs authorization in Spring Security.

3. What are the core components of Spring Security?

4. What is the Spring Security Filter Chain?

5. How does Spring Security work in a Spring Boot app?

6. What are GrantedAuthority and Roles?

7. What is SecurityContextHolder?

8. What is UserDetailsService?

9. What is AuthenticationManager?

10. What is PasswordEncoder and why is it important?

Spring Security Configuration

1. How do you configure Spring Security in Spring Boot?

2. What is WebSecurityConfigurerAdapter (previous approach) & its replacement?

3. How to secure specific URLs and endpoints?

4. How do you define public vs secured routes?

5. What annotations are used for enabling method-level security?

6. Explain @PreAuthorize vs @Secured vs @RolesAllowed.

7. How to customize login & logout URLs?

8. How to configure session management (stateless/stateful)?

9. How do you disable CSRF and when is it appropriate?

10. How do you secure a REST API with Spring Security?

Spring Security Mechanisms

1. What is Basic Authentication?

2. How does Form-Based Authentication work?

3. What is JWT (JSON Web Token) and how is it used?

4. How do you implement JWT authentication flow in Spring Security?

5. What is OAuth2 and how does Spring Security support it?

6. Explain OAuth2 Authorization Code Grant.

7. How do you enable OAuth2 login (SSO) in Spring Boot?

8. What is LDAP Authentication?

9. What is SAML integration?

10. What is Remember-Me authentication?

Spring Security Advanced Concepts

1. How do you create a custom authentication filter?

2. What is the role of an AuthenticationProvider?

3. How do you handle exceptions in Spring Security?

4. What is CORS and how do you configure it?

5. What is session fixation protection?

6. How to secure microservices with Spring Security?

7. What are Access Control Lists (ACLs)?

8. How do you test security configurations?

9. Explain stateless vs stateful authentication.

10. What are common web vulnerabilities Spring Security protects against?

Spring Security Real-World / Scenario Based

1. How do you implement rate limiting and throttling?

2. How do you handle role hierarchy in Spring Security?

3. How do you configure HTTPS/SSL in Spring Boot?

4. Explain security in reactive applications (WebFlux).

5. How to integrate Spring Security with LDAP + JWT?

6. How do you refresh JWT tokens securely?

7. How to implement multi-factor authentication (MFA)?

8. What are best practices for Spring Security in production?

9. How do you handle role-based access control (RBAC)?

10. How do you secure GraphQL or non-REST endpoints with Spring Security?

InterviewExpert.org

Writing about interviews, stacks, and getting hired.

Leave a comment