Spring Boot security starters integrate Spring Security and its ecosystem into your application. The base security starter configures authentication and authorization for servlet or reactive applications. Dedicated starters add OAuth 2.0 client flows, JWT-protected resource servers, a full Authorization Server, and enterprise SAML 2.0 federation — each one building on the previous layer.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/spring-projects/spring-boot/llms.txt
Use this file to discover all available pages before exploring further.
All security starters depend on
spring-boot-starter-security. You do not need to declare the base security starter separately when using any of the OAuth 2.0 or SAML starters.spring-boot-starter-security
spring-boot-starter-security
The foundational security starter. Auto-configures Spring Security with form login and HTTP Basic authentication, protects all endpoints by default, and generates a random password printed to the console on startup.Includes: Override the generated credentials in Customize the security configuration by providing a When to use: Any application that needs authentication and authorization. This is the starting point for all Spring Security configurations.
spring-boot-starter · spring-boot-security · spring-aopapplication.properties for development:application.properties
SecurityFilterChain bean:spring-boot-starter-security-oauth2-client
spring-boot-starter-security-oauth2-client
OAuth 2.0 and OpenID Connect (OIDC) client support. Enables Register a provider in When to use: Web applications where users log in through a third-party identity provider (social login, corporate SSO). Handles the authorization code flow, token storage, and token refresh automatically.
@EnableOAuth2Client, auto-configures OAuth2AuthorizedClientManager, and provides login via external identity providers (Google, GitHub, Okta, Keycloak, etc.).Includes: spring-boot-starter · spring-boot-starter-security · spring-boot-security-oauth2-client · spring-security-oauth2-joseapplication.properties:application.properties
The older
spring-boot-starter-oauth2-client artifact is deprecated. Use spring-boot-starter-security-oauth2-client for new projects.spring-boot-starter-security-oauth2-resource-server
spring-boot-starter-security-oauth2-resource-server
Protects REST API endpoints by validating Bearer tokens (JWT or opaque). Auto-configures JWT decoding and Minimal JWT resource server configuration:Extract custom claims from the JWT:When to use: Any REST API that accepts tokens issued by a separate authorization server. This is the most common security configuration for microservices behind an API gateway.
BearerTokenAuthenticationFilter.Includes: spring-boot-starter · spring-boot-starter-security · spring-boot-security-oauth2-resource-serverapplication.properties
The older
spring-boot-starter-oauth2-resource-server artifact is deprecated. Use spring-boot-starter-security-oauth2-resource-server for new projects.spring-boot-starter-security-oauth2-authorization-server
spring-boot-starter-security-oauth2-authorization-server
spring-boot-starter-security-saml2
spring-boot-starter-security-saml2
SAML 2.0 authentication support, enabling your application to act as a SAML Service Provider (SP) and authenticate users through enterprise Identity Providers (IdPs) like Okta, ADFS, or Shibboleth.Includes: Configure your SAML IdP via metadata URL:When to use: Enterprise SSO integrations where the identity provider speaks SAML 2.0 — common in regulated industries and corporate environments.
spring-boot-starter · spring-boot-starter-security · spring-boot-security-saml2application.properties
Testing security
spring-boot-starter-security-test
Test utilities from Spring Security:@WithMockUser, @WithUserDetails, SecurityMockMvcRequestPostProcessors, and WebTestClientSecurityConfigurer.
Includes: spring-boot-starter-security · spring-boot-starter-test · spring-boot-security-test
@WithMockUser
Inject a mock authenticated user into the security context without hitting an actual identity provider:SecurityMockMvcRequestPostProcessors
Apply security context to individual requests without a class-level annotation:Testing JWT resource servers
UseSecurityMockMvcRequestPostProcessors.jwt() to pass a synthetic JWT without a real token issuer: