Skip to content

Commit e869bcd

Browse files
committed
Remove deprecated implementations of OAuth2AccessTokenResponseClient
Closes gh-16909
1 parent cfe3895 commit e869bcd

File tree

38 files changed

+118
-4424
lines changed

38 files changed

+118
-4424
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
2525
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
2626
import org.springframework.security.oauth2.client.authentication.OAuth2AuthorizationCodeAuthenticationProvider;
27-
import org.springframework.security.oauth2.client.endpoint.DefaultAuthorizationCodeTokenResponseClient;
2827
import org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient;
2928
import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest;
29+
import org.springframework.security.oauth2.client.endpoint.RestClientAuthorizationCodeTokenResponseClient;
3030
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
3131
import org.springframework.security.oauth2.client.web.AuthenticatedPrincipalOAuth2AuthorizedClientRepository;
3232
import org.springframework.security.oauth2.client.web.AuthorizationRequestRepository;
@@ -297,7 +297,7 @@ private OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> get
297297
ResolvableType resolvableType = ResolvableType.forClassWithGenerics(OAuth2AccessTokenResponseClient.class,
298298
OAuth2AuthorizationCodeGrantRequest.class);
299299
OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> bean = getBeanOrNull(resolvableType);
300-
return (bean != null) ? bean : new DefaultAuthorizationCodeTokenResponseClient();
300+
return (bean != null) ? bean : new RestClientAuthorizationCodeTokenResponseClient();
301301
}
302302

303303
private ClientRegistrationRepository getClientRegistrationRepository(B builder) {

config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2LoginConfigurer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
5454
import org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationProvider;
5555
import org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationToken;
56-
import org.springframework.security.oauth2.client.endpoint.DefaultAuthorizationCodeTokenResponseClient;
5756
import org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient;
5857
import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest;
58+
import org.springframework.security.oauth2.client.endpoint.RestClientAuthorizationCodeTokenResponseClient;
5959
import org.springframework.security.oauth2.client.oidc.authentication.OidcAuthorizationCodeAuthenticationProvider;
6060
import org.springframework.security.oauth2.client.oidc.authentication.OidcAuthorizedClientRefreshedEventListener;
6161
import org.springframework.security.oauth2.client.oidc.session.InMemoryOidcSessionRegistry;
@@ -462,7 +462,7 @@ private OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> get
462462
ResolvableType resolvableType = ResolvableType.forClassWithGenerics(OAuth2AccessTokenResponseClient.class,
463463
OAuth2AuthorizationCodeGrantRequest.class);
464464
OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> bean = getBeanOrNull(resolvableType);
465-
return (bean != null) ? bean : new DefaultAuthorizationCodeTokenResponseClient();
465+
return (bean != null) ? bean : new RestClientAuthorizationCodeTokenResponseClient();
466466
}
467467

468468
private OAuth2UserService<OidcUserRequest, OidcUser> getOidcUserService() {

config/src/main/java/org/springframework/security/config/http/OAuth2ClientBeanDefinitionParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -150,9 +150,8 @@ private BeanMetadataElement getAccessTokenResponseClient(Element element) {
150150
if (StringUtils.hasLength(accessTokenResponseClientRef)) {
151151
return new RuntimeBeanReference(accessTokenResponseClientRef);
152152
}
153-
return BeanDefinitionBuilder
154-
.rootBeanDefinition(
155-
"org.springframework.security.oauth2.client.endpoint.DefaultAuthorizationCodeTokenResponseClient")
153+
return BeanDefinitionBuilder.rootBeanDefinition(
154+
"org.springframework.security.oauth2.client.endpoint.RestClientAuthorizationCodeTokenResponseClient")
156155
.getBeanDefinition();
157156
}
158157

config/src/main/java/org/springframework/security/config/http/OAuth2LoginBeanDefinitionParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -334,9 +334,8 @@ private BeanMetadataElement getAccessTokenResponseClient(Element element) {
334334
if (StringUtils.hasLength(accessTokenResponseClientRef)) {
335335
return new RuntimeBeanReference(accessTokenResponseClientRef);
336336
}
337-
return BeanDefinitionBuilder
338-
.rootBeanDefinition(
339-
"org.springframework.security.oauth2.client.endpoint.DefaultAuthorizationCodeTokenResponseClient")
337+
return BeanDefinitionBuilder.rootBeanDefinition(
338+
"org.springframework.security.oauth2.client.endpoint.RestClientAuthorizationCodeTokenResponseClient")
340339
.getBeanDefinition();
341340
}
342341

docs/modules/ROOT/pages/servlet/oauth2/client/authorization-grants.adoc

Lines changed: 5 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -370,19 +370,7 @@ Xml::
370370
See the https://tools.ietf.org/html/rfc6749#section-4.1.3[Access Token Request/Response] protocol flow for the Authorization Code grant.
371371
====
372372

373-
There are two implementations of `OAuth2AccessTokenResponseClient` that can be used to make HTTP requests to the Token Endpoint in order to obtain an access token for the Authorization Code grant:
374-
375-
* `DefaultAuthorizationCodeTokenResponseClient` (_default_)
376-
* `RestClientAuthorizationCodeTokenResponseClient`
377-
378-
The default implementation uses a `RestOperations` instance to exchange an authorization code for an access token at the Authorization Server’s Token Endpoint.
379-
Spring Security 6.4 introduces a new implementation based on `RestClient`, which provides similar functionality but is better aligned with the Reactive version of the component (based on `WebClient`) in order to provide consistent configuration for applications on either stack.
380-
381-
[NOTE]
382-
====
383-
This section focuses on `RestClientAuthorizationCodeTokenResponseClient`.
384-
You can read about {spring-security-reference-base-url}/6.3/servlet/oauth2/client/authorization-grants.html#_requesting_an_access_token[`DefaultAuthorizationCodeTokenResponseClient`] in the Spring Security 6.3 documentation.
385-
====
373+
The default implementation of `OAuth2AccessTokenResponseClient` for the Authorization Code grant is `RestClientAuthorizationCodeTokenResponseClient`, which uses a `RestClient` instance to exchange an authorization code for an access token at the Authorization Server’s Token Endpoint.
386374

387375
:section-id: authorization-code
388376
:grant-type: Authorization Code
@@ -473,19 +461,7 @@ See the OAuth 2.0 Authorization Framework for further details on the https://too
473461
See the https://tools.ietf.org/html/rfc6749#section-6[Access Token Request/Response] protocol flow for the Refresh Token grant.
474462
====
475463

476-
There are two implementations of `OAuth2AccessTokenResponseClient` that can be used to make HTTP requests to the Token Endpoint in order to obtain an access token for the Refresh Token grant:
477-
478-
* `DefaultRefreshTokenTokenResponseClient` (_default_)
479-
* `RestClientRefreshTokenTokenResponseClient`
480-
481-
The default implementation uses a `RestOperations` instance to exchange an authorization code for an access token at the Authorization Server’s Token Endpoint.
482-
Spring Security 6.4 introduces a new implementation based on `RestClient`, which provides similar functionality but is better aligned with the Reactive version of the component (based on `WebClient`) in order to provide consistent configuration for applications on either stack.
483-
484-
[NOTE]
485-
====
486-
This section focuses on `RestClientRefreshTokenTokenResponseClient`.
487-
You can read about {spring-security-reference-base-url}/6.3/servlet/oauth2/client/authorization-grants.html#_refreshing_an_access_token[`DefaultRefreshTokenTokenResponseClient`] in the Spring Security 6.3 documentation.
488-
====
464+
The default implementation of `OAuth2AccessTokenResponseClient` for the Refresh Token grant is `RestClientRefreshTokenTokenResponseClient`, which uses a `RestClient` instance to obtain an access token at the Authorization Server’s Token Endpoint.
489465

490466
:section-id: refresh-token
491467
:grant-type: Refresh Token
@@ -565,19 +541,7 @@ Please refer to the OAuth 2.0 Authorization Framework for further details on the
565541
See the https://tools.ietf.org/html/rfc6749#section-4.4.2[Access Token Request/Response] protocol flow for the Client Credentials grant.
566542
====
567543

568-
There are two implementations of `OAuth2AccessTokenResponseClient` that can be used to make HTTP requests to the Token Endpoint in order to obtain an access token for the Client Credentials grant:
569-
570-
* `DefaultClientCredentialsTokenResponseClient` (_default_)
571-
* `RestClientClientCredentialsTokenResponseClient`
572-
573-
The default implementation uses a `RestOperations` instance to exchange an authorization code for an access token at the Authorization Server’s Token Endpoint.
574-
Spring Security 6.4 introduces a new implementation based on `RestClient`, which provides similar functionality but is better aligned with the Reactive version of the component (based on `WebClient`) in order to provide consistent configuration for applications on either stack.
575-
576-
[NOTE]
577-
====
578-
This section focuses on `RestClientClientCredentialsTokenResponseClient`.
579-
You can read about {spring-security-reference-base-url}/6.3/servlet/oauth2/client/authorization-grants.html#_requesting_an_access_token_2[`DefaultClientCredentialsTokenResponseClient`] in the Spring Security 6.3 documentation.
580-
====
544+
The default implementation of `OAuth2AccessTokenResponseClient` for the Client Credentials grant is `RestClientClientCredentialsTokenResponseClient`, which uses a `RestClient` instance to obtain an access token at the Authorization Server’s Token Endpoint.
581545

582546
:section-id: client-credentials
583547
:grant-type: Client Credentials
@@ -794,19 +758,7 @@ Please refer to JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication
794758
Please refer to the https://datatracker.ietf.org/doc/html/rfc7523#section-2.1[Access Token Request/Response] protocol flow for the JWT Bearer grant.
795759
====
796760

797-
There are two implementations of `OAuth2AccessTokenResponseClient` that can be used to make HTTP requests to the Token Endpoint in order to obtain an access token for the JWT Bearer grant:
798-
799-
* `DefaultJwtBearerTokenResponseClient` (_default_)
800-
* `RestClientJwtBearerTokenResponseClient`
801-
802-
The default implementation uses a `RestOperations` instance to exchange an authorization code for an access token at the Authorization Server’s Token Endpoint.
803-
Spring Security 6.4 introduces a new implementation based on `RestClient`, which provides similar functionality but is better aligned with the Reactive version of the component (based on `WebClient`) in order to provide consistent configuration for applications on either stack.
804-
805-
[NOTE]
806-
====
807-
This section focuses on `RestClientJwtBearerTokenResponseClient`.
808-
You can read about {spring-security-reference-base-url}/6.3/servlet/oauth2/client/authorization-grants.html#_requesting_an_access_token_4[`DefaultClientCredentialsTokenResponseClient`] in the Spring Security 6.3 documentation.
809-
====
761+
The default implementation of `OAuth2AccessTokenResponseClient` for the JWT Bearer grant is `RestClientJwtBearerTokenResponseClient`, which uses a `RestClient` instance to obtain an access token at the Authorization Server’s Token Endpoint.
810762

811763
:section-id: jwt-bearer
812764
:grant-type: JWT Bearer
@@ -1015,19 +967,7 @@ Please refer to OAuth 2.0 Token Exchange for further details on the https://data
1015967
Please refer to the https://datatracker.ietf.org/doc/html/rfc8693#section-2[Token Exchange Request and Response] protocol flow for the Token Exchange grant.
1016968
====
1017969

1018-
There are two implementations of `OAuth2AccessTokenResponseClient` that can be used to make HTTP requests to the Token Endpoint in order to obtain an access token for the Token Exchange grant:
1019-
1020-
* `DefaultTokenExchangeTokenResponseClient` (_default_)
1021-
* `RestClientTokenExchangeTokenResponseClient`
1022-
1023-
The default implementation uses a `RestOperations` instance to exchange an authorization code for an access token at the Authorization Server’s Token Endpoint.
1024-
Spring Security 6.4 introduces a new implementation based on `RestClient`, which provides similar functionality but is better aligned with the Reactive version of the component (based on `WebClient`) in order to provide consistent configuration for applications on either stack.
1025-
1026-
[NOTE]
1027-
====
1028-
This section focuses on `RestClientTokenExchangeTokenResponseClient`.
1029-
You can read about {spring-security-reference-base-url}/6.3/servlet/oauth2/client/authorization-grants.html#_requesting_an_access_token_5[`DefaultTokenExchangeTokenResponseClient`] in the Spring Security 6.3 documentation.
1030-
====
970+
The default implementation of `OAuth2AccessTokenResponseClient` for the Token Exchange grant is `RestClientTokenExchangeTokenResponseClient`, which uses a `RestClient` instance to obtain an access token at the Authorization Server’s Token Endpoint.
1031971

1032972
:section-id: token-exchange
1033973
:grant-type: Token Exchange

0 commit comments

Comments
 (0)