Skip to content

Commit 95155dd

Browse files
committed
Deprecate Resource Owner Password Credentials grant
Closes gh-11590
1 parent 1be9be9 commit 95155dd

8 files changed

+62
-5
lines changed

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/OAuth2AuthorizedClientProviderBuilder.java

+12
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ public OAuth2AuthorizedClientProviderBuilder clientCredentials(
137137
/**
138138
* Configures support for the {@code password} grant.
139139
* @return the {@link OAuth2AuthorizedClientProviderBuilder}
140+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use
141+
* of the Resource Owner Password Credentials grant. See reference
142+
* <a target="_blank" href=
143+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
144+
* 2.0 Security Best Current Practice.</a>
140145
*/
146+
@Deprecated
141147
public OAuth2AuthorizedClientProviderBuilder password() {
142148
this.builders.computeIfAbsent(PasswordOAuth2AuthorizedClientProvider.class, (k) -> new PasswordGrantBuilder());
143149
return OAuth2AuthorizedClientProviderBuilder.this;
@@ -148,7 +154,13 @@ public OAuth2AuthorizedClientProviderBuilder password() {
148154
* @param builderConsumer a {@code Consumer} of {@link PasswordGrantBuilder} used for
149155
* further configuration
150156
* @return the {@link OAuth2AuthorizedClientProviderBuilder}
157+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use
158+
* of the Resource Owner Password Credentials grant. See reference
159+
* <a target="_blank" href=
160+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
161+
* 2.0 Security Best Current Practice.</a>
151162
*/
163+
@Deprecated
152164
public OAuth2AuthorizedClientProviderBuilder password(Consumer<PasswordGrantBuilder> builderConsumer) {
153165
PasswordGrantBuilder builder = (PasswordGrantBuilder) this.builders
154166
.computeIfAbsent(PasswordOAuth2AuthorizedClientProvider.class, (k) -> new PasswordGrantBuilder());

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/PasswordOAuth2AuthorizedClientProvider.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -40,7 +40,12 @@
4040
* @since 5.2
4141
* @see OAuth2AuthorizedClientProvider
4242
* @see DefaultPasswordTokenResponseClient
43+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use of
44+
* the Resource Owner Password Credentials grant. See reference <a target="_blank" href=
45+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
46+
* 2.0 Security Best Current Practice.</a>
4347
*/
48+
@Deprecated
4449
public final class PasswordOAuth2AuthorizedClientProvider implements OAuth2AuthorizedClientProvider {
4550

4651
private OAuth2AccessTokenResponseClient<OAuth2PasswordGrantRequest> accessTokenResponseClient = new DefaultPasswordTokenResponseClient();

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/PasswordReactiveOAuth2AuthorizedClientProvider.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -40,7 +40,12 @@
4040
* @since 5.2
4141
* @see ReactiveOAuth2AuthorizedClientProvider
4242
* @see WebClientReactivePasswordTokenResponseClient
43+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use of
44+
* the Resource Owner Password Credentials grant. See reference <a target="_blank" href=
45+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
46+
* 2.0 Security Best Current Practice.</a>
4347
*/
48+
@Deprecated
4449
public final class PasswordReactiveOAuth2AuthorizedClientProvider implements ReactiveOAuth2AuthorizedClientProvider {
4550

4651
private ReactiveOAuth2AccessTokenResponseClient<OAuth2PasswordGrantRequest> accessTokenResponseClient = new WebClientReactivePasswordTokenResponseClient();

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/ReactiveOAuth2AuthorizedClientProviderBuilder.java

+12
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ public ReactiveOAuth2AuthorizedClientProviderBuilder clientCredentials(
139139
/**
140140
* Configures support for the {@code password} grant.
141141
* @return the {@link ReactiveOAuth2AuthorizedClientProviderBuilder}
142+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use
143+
* of the Resource Owner Password Credentials grant. See reference
144+
* <a target="_blank" href=
145+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
146+
* 2.0 Security Best Current Practice.</a>
142147
*/
148+
@Deprecated
143149
public ReactiveOAuth2AuthorizedClientProviderBuilder password() {
144150
this.builders.computeIfAbsent(PasswordReactiveOAuth2AuthorizedClientProvider.class,
145151
(k) -> new PasswordGrantBuilder());
@@ -151,7 +157,13 @@ public ReactiveOAuth2AuthorizedClientProviderBuilder password() {
151157
* @param builderConsumer a {@code Consumer} of {@link PasswordGrantBuilder} used for
152158
* further configuration
153159
* @return the {@link ReactiveOAuth2AuthorizedClientProviderBuilder}
160+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use
161+
* of the Resource Owner Password Credentials grant. See reference
162+
* <a target="_blank" href=
163+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
164+
* 2.0 Security Best Current Practice.</a>
154165
*/
166+
@Deprecated
155167
public ReactiveOAuth2AuthorizedClientProviderBuilder password(Consumer<PasswordGrantBuilder> builderConsumer) {
156168
PasswordGrantBuilder builder = (PasswordGrantBuilder) this.builders.computeIfAbsent(
157169
PasswordReactiveOAuth2AuthorizedClientProvider.class, (k) -> new PasswordGrantBuilder());

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/endpoint/DefaultPasswordTokenResponseClient.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -53,7 +53,12 @@
5353
* @see <a target="_blank" href=
5454
* "https://tools.ietf.org/html/rfc6749#section-4.3.3">Section 4.3.3 Access Token Response
5555
* (Resource Owner Password Credentials Grant)</a>
56+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use of
57+
* the Resource Owner Password Credentials grant. See reference <a target="_blank" href=
58+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
59+
* 2.0 Security Best Current Practice.</a>
5660
*/
61+
@Deprecated
5762
public final class DefaultPasswordTokenResponseClient
5863
implements OAuth2AccessTokenResponseClient<OAuth2PasswordGrantRequest> {
5964

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/endpoint/OAuth2PasswordGrantRequest.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -30,7 +30,12 @@
3030
* @see <a target="_blank" href=
3131
* "https://tools.ietf.org/html/rfc6749#section-1.3.3">Section 1.3.3 Resource Owner
3232
* Password Credentials</a>
33+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use of
34+
* the Resource Owner Password Credentials grant. See reference <a target="_blank" href=
35+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
36+
* 2.0 Security Best Current Practice.</a>
3337
*/
38+
@Deprecated
3439
public class OAuth2PasswordGrantRequest extends AbstractOAuth2AuthorizationGrantRequest {
3540

3641
private final String username;

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/endpoint/WebClientReactivePasswordTokenResponseClient.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -42,7 +42,12 @@
4242
* @see <a target="_blank" href=
4343
* "https://tools.ietf.org/html/rfc6749#section-4.3.3">Section 4.3.3 Access Token Response
4444
* (Resource Owner Password Credentials Grant)</a>
45+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use of
46+
* the Resource Owner Password Credentials grant. See reference <a target="_blank" href=
47+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
48+
* 2.0 Security Best Current Practice.</a>
4549
*/
50+
@Deprecated
4651
public final class WebClientReactivePasswordTokenResponseClient
4752
extends AbstractWebClientReactiveOAuth2AccessTokenResponseClient<OAuth2PasswordGrantRequest> {
4853

oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/AuthorizationGrantType.java

+8
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public final class AuthorizationGrantType implements Serializable {
5757

5858
public static final AuthorizationGrantType CLIENT_CREDENTIALS = new AuthorizationGrantType("client_credentials");
5959

60+
/**
61+
* @deprecated The latest OAuth 2.0 Security Best Current Practice disallows the use
62+
* of the Resource Owner Password Credentials grant. See reference
63+
* <a target="_blank" href=
64+
* "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-19#section-2.4">OAuth
65+
* 2.0 Security Best Current Practice.</a>
66+
*/
67+
@Deprecated
6068
public static final AuthorizationGrantType PASSWORD = new AuthorizationGrantType("password");
6169

6270
/**

0 commit comments

Comments
 (0)