What Is New in Spring Security 7.0
| Category | Highlights |
|---|---|
| New Features | Multi-Factor Authentication support, Password4j password encoders, OAuth2 client-side support, Dynamic Registration protocol, PKCE enabled by default, AuthorizationManagerFactory, Authentication.Builder, AllAuthoritiesAuthorizationManager, JWT JwkSource builder, Spring Security Kerberos and Authorization Server modules merged. |
| Improvements | Modular servlet/WebFlux configuration, SPA-friendly CSRF DSL, binding of missing authorities, authorized-object support for Spring Data, LDAP now uses UnboundID, simplified expression migration, default login page shows MFA factors. |
| Breaking Changes | Removed AuthorizationManager#check, removed HttpSecurity.and(), authorizeRequests renamed to authorizeHttpRequests, ApacheDsContainer dropped, password grant removed, OpenSAML 4 removed, MvcRequestMatcher and AntPathRequestMatcher replaced by PathPatternRequestMatcher, LoginUrlAuthenticationEntryPoint now prefers relative redirects. |
| Deprecations | All APIs previously marked @Deprecated have been eliminated, including AuthorizationManager#check, HttpSecurity.and(), authorizeRequests, ApacheDsContainer, password grant, OpenSAML 4 support, MvcRequestMatcher, AntPathRequestMatcher. |
How does Spring Security 7.0 enable Multi-Factor Authentication out of the box?
Spring Security 7.0 introduces first-class Multi-Factor Authentication (MFA) support through new authorization managers and a builder for mutating Authentication objects.
- AllAuthoritiesAuthorizationManager lets you require a set of authorities that represent MFA factors.
- Authentication.Builder enables merging of existing Authentication with additional MFA details without recreating the token.
In practice you can protect an endpoint like this:
http.authorizeHttpRequests(auth -> auth
.requestMatchers("/admin/**").hasAuthority("ROLE_ADMIN")
.anyRequest().access(new AllAuthoritiesAuthorizationManager("MFA_SMS", "MFA_TOTP"))
The default login page now renders factor information based on factor.type and factor.reason query parameters, making it easier for UI teams to display the correct challenge.
What are the major configuration API changes developers need to adopt?
Spring Security 7.0 replaces several long-standing DSL methods with more expressive lambda-based alternatives.
- Removed:
HttpSecurity.and()- chain calls now end with a lambda. - Removed:
authorizeRequests()- useauthorizeHttpRequests()instead. - Added: Modular configuration for both Servlet and WebFlux stacks, allowing separate
HttpSecurityorServerHttpSecuritybeans per module. - Added: SPA-friendly CSRF DSL:
http.csrf(csrf -> csrf.spa());
Example of the new style:
http
.csrf(csrf -> csrf.spa())
.authorizeHttpRequests(auth -> auth
.requestMatchers("/public/**").permitAll()
.anyRequest().authenticated())
.formLogin(form -> form.loginPage("/login"));
This matters if you have existing security configuration files; the migration is straightforward but requires updating method names and removing the now-redundant and() calls.
How has OAuth 2.0 support been expanded in Spring Security 7.0?
Spring Security 7.0 adds several OAuth 2.0 enhancements that simplify client and server development.
- Password grant removed - encourages use of more secure flows.
- OAuth2 support for HTTP service clients via
WebClientandRestTemplatebuilders. - Custom
JwkSourcecan now be supplied toNimbusJwtDecoderusing Nimbus's builder API. - Builder for
NimbusJwtEncodersupports EC, RSA, or secret keys directly. @ClientRegistrationIdcan be placed on a class, reducing repetitive annotations on each method.- Dynamic Registration protocol and PKCE are enabled by default in the Authorization Server.
Typical client configuration now looks like:
NimbusJwtDecoder decoder = NimbusJwtDecoder.withJwkSource(myJwkSource).build();
These changes reduce boilerplate and improve security posture for modern OAuth deployments.
What are the key changes for SAML 2.0 and Kerberos integrations?
Spring Security 7.0 modernizes SAML 2.0 and Kerberos support while removing legacy dependencies.
- SAML: API methods based on
AssertingPartyDetailsreplaced byAssertingPartyMetadata; GET support removed fromSaml2AuthenticationTokenConverter; JDBC-basedAssertingPartyMetadataRepositoryadded; OpenSAML 4 dropped - migrate to OpenSAML 5. - Kerberos: The Kerberos extension is now part of the core Spring Security distribution, simplifying dependency management.
- Single Logout (SLO) now returns an empty response body even when validation fails, making client handling more predictable.
When upgrading, ensure your SAML metadata handling switches to the new AssertingPartyMetadata interface and update any GET-based token conversion logic.
Frequently Asked Questions
What is the recommended way to replace authorizeRequests in Spring Security 7.0?
Use authorizeHttpRequests with a lambda expression, for example http.authorizeHttpRequests(auth -> auth.anyRequest().authenticated()).
Is the password grant still supported in Spring Security 7.0?
No, the password grant has been removed to encourage more secure authorization flows.
How can I enable SPA-friendly CSRF protection?
Call http.csrf(csrf -> csrf.spa()) in your HttpSecurity configuration.
Can I still use ApacheDsContainer for LDAP testing?
No, ApacheDsContainer was removed; switch to the UnboundID LDAP SDK.
How do I configure a custom JWK source for JWT decoding?
Instantiate NimbusJwtDecoder with NimbusJwtDecoder.withJwkSource(myJwkSource).build().
Do I need to change my SAML metadata handling after upgrading?
Yes, replace AssertingPartyDetails usage with the new AssertingPartyMetadata interface.