Skip to content

Commit 4787efb

Browse files
committed
Update What's New
1 parent b712c24 commit 4787efb

File tree

2 files changed

+121
-9
lines changed

2 files changed

+121
-9
lines changed

docs/modules/ROOT/pages/servlet/authorization/method-security.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,7 @@ We expose `MethodSecurityExpressionHandler` using a `static` method to ensure th
15281528

15291529
You can also <<subclass-defaultmethodsecurityexpressionhandler,subclass `DefaultMessageSecurityExpressionHandler`>> to add your own custom authorization expressions beyond the defaults.
15301530

1531+
[[pre-post-authorize-aot]]
15311532
=== Working with AOT
15321533

15331534
Spring Security will scan all beans in the application context for methods that use `@PreAuthorize` or `@PostAuthorize`.
@@ -2462,6 +2463,7 @@ And if they do have that authority, they'll see:
24622463
You can also add the Spring Boot property `spring.jackson.default-property-inclusion=non_null` to exclude the null value from serialization, if you also don't want to reveal the JSON key to an unauthorized user.
24632464
====
24642465

2466+
[[authorize-return-object-aot]]
24652467
=== Working with AOT
24662468

24672469
Spring Security will scan all beans in the application context for methods that use `@AuthorizeReturnObject`.

docs/modules/ROOT/pages/whats-new.adoc

+119-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,89 @@
44
Spring Security 6.4 provides a number of new features.
55
Below are the highlights of the release, or you can view https://github.com/spring-projects/spring-security/releases[the release notes] for a detailed listing of each feature and bug fix.
66

7+
== Deprecation Notices
8+
9+
As we get closer to Spring Security 7, it's important to stay up to date on deprecations.
10+
As such, this section points out deprecations in the 6.4 release.
11+
12+
* *Method Security* - `AuthorizationManager#check` is deprecated in favor of `AuthorizationManager#authorize`.
13+
This is primarily to allow the return type to be an interface instead of a concrete class.
14+
If you are invoking `AuthorizationManager#check`, please invoke `AuthorizationManager#authorize` instead.
15+
+
16+
Relatedly, `AuthorizationEventPublisher#publishEvent` that takes an `AuthorizationDecision` is deprecated in favor of a method of the same name that takes an `AuthorizationResult` interface instead.
17+
* *Method Security* - `PrePostTemplateDefaults` is deprecated in favor of the more generic `AnnotationTemplateExpressionDefaults` as there is now meta-annotation property support for `@AuthenticationPrincipal` and `@CurrentSecurityContext` as well.
18+
If you are constructing a `PrePostTemplateDefaults`, change this out for an `AnnotationTemplateExpressionDefaults`.
19+
* *OAuth 2.0* - `NimbusOpaqueTokenIntrospector` has been deprecated in favor of `SpringOpaqueTokenIntrospector` in order to remove Spring Security OAuth 2.0 Resource Server's reliance on the `oidc-oauth2-sdk` package.
20+
If you are constructing a `NimbusOpaqueTokenIntrospector`, replace it with ``SpringOpaqueTokenIntrospector``'s constructor
21+
* *OAuth 2.0* - `DefaultAuthorizationCodeTokenResponseClient`, `DefaultClientCredentialsTokenResponseClient`, `DefaultJwtBearerTokenResponseClient`, `DefaultPasswordTokenResponseClient`, `DefaultRefreshTokenTokenResponseClient`, and `DefaultTokenExchangeTokenResponseClient` are deprecated in favor of their `RestClient` equivalents.
22+
+
23+
Relatedly,`JwtBearerGrantRequestEntityConverter`, `OAuth2AuthorizationCodeGrantRequestEntityConverter`, `OAuth2ClientCredentialsGrantRequestEntityConverter`, `OAuth2PasswordGrantRequestEntityConverter`, `OAuth2RefreshTokenGrantRequestEntityConverter` are deprecated in favor of providing an instance of `DefaultOAuth2TokenRequestParametersConverter` to one of the above token response clients
24+
+
25+
For example, if you have the following arrangement:
26+
+
27+
[source,java]
28+
----
29+
private static class MyCustomConverter
30+
extends AbstractOAuth2AuthorizationGrantRequestEntityConverter<OAuth2AuthorizationCodeGrantRequest> {
31+
@Override
32+
protected MultiValueMap<String, String> createParameters
33+
(OAuth2AuthorizationCodeGrantRequest request) {
34+
MultiValueMap<String, String> parameters = super.createParameters(request);
35+
parameters.add("custom", "value");
36+
return parameters;
37+
}
38+
}
39+
40+
@Bean
41+
OAuth2AccessTokenResponseClient authorizationCode() {
42+
DefaultAuthorizationCodeTokenResponseClient client =
43+
new DefaultAuthorizationCodeTokenResponseClient();
44+
Converter<AuthorizationCodeGrantRequest, RequestEntity<?>> entityConverter =
45+
new OAuth2AuthorizationCodeGrantRequestEntityConverter();
46+
entityConverter.setParametersConverter(new MyCustomConverter());
47+
client.setRequestEntityConverter(entityConverter);
48+
return client;
49+
}
50+
----
51+
+
52+
This configuration is deprecated since it uses `DefaultAuthorizationCodeTokenResponseClient` and `OAuth2AuthorizationCodeGrantRequestEntityConverter`.
53+
The recommended configuration is now:
54+
+
55+
[source,java]
56+
----
57+
private static class MyCustomConverter implements Converter<OAuth2AuthorizationCodeGrantRequest, Map<String, String>> {
58+
@Override
59+
public MultiValueMap<String, String> convert(OAuth2AuthorizeCodeGrantRequest request) {
60+
MultiValueMap<String, String> parameters = OAuth2AuthorizationCodeGrantRequest.defaultParameters(request);
61+
parameters.add("custom", "value");
62+
return parameters;
63+
}
64+
}
65+
66+
@Bean
67+
OAuth2AccessTokenResponseClient authorizationCode() {
68+
RestClientAuthorizationCodeTokenResponseClient client =
69+
new RestClientAuthorizationCodeTokenResponseClient();
70+
client.setParametersConverter(new MyCustomConverter());
71+
return client;
72+
}
73+
----
74+
75+
76+
* *SAML 2.0* - Unversioned OpenSAML implementations of Spring Security SAML 2.0 Service Provider's interfaces have been deprecated in favor of versioned ones.
77+
For example, `OpenSamlAuthenticationTokenConverter` is now replaced by `OpenSaml4AuthenticationTokenConverter` and `OpenSaml5AuthenticationTokenConverter`.
78+
If you are constructing one of these deprecated versions, please replace it with the one that corresponds to the OpenSAML version you are using.
79+
* *SAML 2.0* - Methods surrounding `AssertingPartyDetails` are deprecated in favor of equivalent methods that use the `AssertingPartyMetadata` interface.
80+
* *LDAP* - Usages of `DistinguishedName` are now deprecated in order to align with Spring LDAP's deprecations
81+
82+
== One-Time Token Login
83+
84+
* Spring Security now xref:servlet/authentication/onetimetoken.adoc[supports One-Time Token Login] via the `oneTimeTokenLogin()` DSL, including xref:servlet/authentication/onetimetoken.adoc#customize-generate-consume-token[JDBC support].
85+
86+
== Passkeys
87+
88+
Spring Security now has xref:servlet/authentication/passkeys.adoc[Passkeys] support.
89+
790
== Method Security
891

992
* All xref:servlet/authorization/method-security.adoc#meta-annotations[method security annotations] now support {spring-framework-api-url}org/springframework/core/annotation/AliasFor.html[Framework's `@AliasFor`]
@@ -48,10 +131,14 @@ fun method(@CurrentUsername("username") val username: String): String {
48131
======
49132
* https://github.com/spring-projects/spring-security/issues/13490[Several] https://github.com/spring-projects/spring-security/issues/13234[improvements] https://github.com/spring-projects/spring-security/issues/15097[were made] to align Security's annotation search with ``AbstractFallbackMethodSecurityMetadataSource``'s algorithm.
50133
This aids in migration from earlier versions of Spring Security.
134+
* Native applications can now xref:servlet/authorization/method-security.adoc#authorize-return-object-aot[use `@AuthorizeReturnObject`]
135+
* Native applications can now xref:servlet/authorization/method-security.adoc#pre-post-authorize-aot[reference beans in `@PreAuthorize` and `@PostAuthorize`]
136+
* `SecurityAnnotationScanners` offers https://github.com/spring-projects/spring-security/issues/15700[a convenient API] for scanning for Security annotations and for adding Security's selection and templating features to custom annotations
51137

52138
== OAuth 2.0
53139

54140
* `oauth2Login()` now accepts https://github.com/spring-projects/spring-security/pull/15237[`OAuth2AuthorizationRequestResolver` as a `@Bean`]
141+
* `ClientRegistrations` now supports externally obtained configuration
55142
* Added `loginPage()` to DSL in reactive `oauth2Login()`
56143
* OIDC Back-Channel support now accepts https://github.com/spring-projects/spring-security/issues/15003[logout tokens of type `logout+jwt`]
57144
* `RestClient` can now be xref:servlet/oauth2/index.adoc#oauth2-client-access-protected-resources[configured] with `OAuth2ClientHttpRequestInterceptor` to xref:servlet/oauth2/index.adoc#oauth2-client-accessing-protected-resources-example[make protected resources requests]
@@ -131,7 +218,7 @@ class SecurityConfig {
131218
}
132219
----
133220
======
134-
* Deprecated `Default*` implementations of `OAuth2AccessTokenResponseClient`
221+
* Token Exchange now https://github.com/spring-projects/spring-security/issues/15534[supports refresh tokens]
135222

136223
== SAML 2.0
137224

@@ -197,15 +284,15 @@ This implementation also supports the validation of a metadata's signature.
197284
* You can now sign https://github.com/spring-projects/spring-security/pull/14916[relying party metadata]
198285
* `RelyingPartyRegistrationRepository` results can now be javadoc:org.springframework.security.saml2.provider.service.registration.CachingRelyingPartyRegistrationRepository[cached].
199286
This is helpful if you want to defer the loading of the registration values til after application startup.
200-
It is also helpful if you want to control when metadata gets refreshed.
287+
It is also helpful if you want to control when metadata gets refreshed via Spring Cache.
201288
* To align with the SAML 2.0 standard, the metadata endpoint now https://github.com/spring-projects/spring-security/issues/15147[uses the `application/samlmetadata+xml` MIME type]
202289

203290
== Web
204291

205292
* CSRF BREACH tokens are now https://github.com/spring-projects/spring-security/issues/15187[more consistent]
206293
* The Remember Me cookie now is https://github.com/spring-projects/spring-security/pull/15203[more customizable]
207-
* Security Filter Chain is now improved.
208-
Specifically, the following arrangement is invalid since an any request filter chain comes before all other filter chains:
294+
* Security Filter Chain finds more invalid configurations.
295+
For example, a filter chain declared after an any-request filter chain is invalid since it will never be invoked:
209296
+
210297
[tabs]
211298
======
@@ -217,6 +304,7 @@ Java::
217304
@Order(0)
218305
SecurityFilterChain api(HttpSecurity http) throws Exception {
219306
http
307+
// implicit securityMatcher("/**")
220308
.authorizeHttpRequests(...)
221309
.httpBasic(...)
222310
@@ -264,14 +352,36 @@ fun app(val http: HttpSecurity): SecurityFilterChain {
264352
----
265353
======
266354
You can read more https://github.com/spring-projects/spring-security/issues/15220[in the related ticket].
355+
* `ServerHttpSecurity` now https://github.com/spring-projects/spring-security/issues/15974[picks up `ServerWebExchangeFirewall` as a `@Bean`]
267356

268-
== One-Time Token Login
269-
270-
Spring Security now xref:servlet/authentication/onetimetoken.adoc[supports One-Time Token Login] via the `oneTimeTokenLogin()` DSL.
357+
== Observability
271358

272-
== Passkeys
359+
Observability now supports xref:servlet/integrations/observability.adoc#observability-tracing-disable[toggling authorization, authentication, and request observations separately]
360+
For example, to turn off filter chain observations, you can publish a `@Bean` like this one:
361+
[tabs]
362+
======
363+
Java::
364+
+
365+
[source,java,role="primary"]
366+
----
367+
@Bean
368+
SecurityObservationSettings allSpringSecurityObservations() {
369+
return SecurityObservationSettings.withDefaults()
370+
.shouldObserveFilterChains(false).build();
371+
}
372+
----
273373
274-
Spring Security now has xref:servlet/authentication/passkeys.adoc[Passkeys] support.
374+
Kotlin::
375+
+
376+
[source,kotlin,role="secondary"]
377+
----
378+
@Bean
379+
fun allSpringSecurityObservations(): SecurityObservationSettings {
380+
return SecurityObservationSettings.builder()
381+
.shouldObserveFilterChains(false).build()
382+
}
383+
----
384+
======
275385

276386
== Kotlin
277387

0 commit comments

Comments
 (0)