You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/reactive/oauth2/client/authorization-grants.adoc
+4
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,10 @@ If the client is running in an untrusted environment (eg. native application or
79
79
. `client-secret` is omitted (or empty)
80
80
. `client-authentication-method` is set to "none" (`ClientAuthenticationMethod.NONE`)
81
81
82
+
or
83
+
84
+
. When `ClientRegistration.clientSettings.requireProofKey` is `true` (in this case `ClientRegistration.authorizationGrantType` must be `authorization_code`)
85
+
82
86
[TIP]
83
87
====
84
88
If the OAuth 2.0 Provider supports PKCE for https://tools.ietf.org/html/rfc6749#section-2.1[Confidential Clients], you may (optionally) configure it using `DefaultServerOAuth2AuthorizationRequestResolver.setAuthorizationRequestCustomizer(OAuth2AuthorizationRequestCustomizers.withPkce())`.
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/reactive/oauth2/client/core.adoc
+5
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,10 @@ public final class ClientRegistration {
39
39
40
40
}
41
41
}
42
+
43
+
public static final class ClientSettings {
44
+
private boolean requireProofKey; // <17>
45
+
}
42
46
}
43
47
----
44
48
<1> `registrationId`: The ID that uniquely identifies the `ClientRegistration`.
@@ -64,6 +68,7 @@ The name may be used in certain scenarios, such as when displaying the name of t
64
68
<15> `(userInfoEndpoint)authenticationMethod`: The authentication method used when sending the access token to the UserInfo Endpoint.
65
69
The supported values are *header*, *form* and *query*.
66
70
<16> `userNameAttributeName`: The name of the attribute returned in the UserInfo Response that references the Name or Identifier of the end-user.
71
+
<17> [[oauth2Client-client-registration-requireProofKey]]`requireProofKey`: If `true` or if `authorizationGrantType` is `none`, then PKCE will be enabled by default.
67
72
68
73
A `ClientRegistration` can be initially configured using discovery of an OpenID Connect Provider's https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Configuration endpoint] or an Authorization Server's https://tools.ietf.org/html/rfc8414#section-3[Metadata endpoint].
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/servlet/oauth2/client/authorization-grants.adoc
+6-1
Original file line number
Diff line number
Diff line change
@@ -77,9 +77,14 @@ spring:
77
77
Public Clients are supported by using https://tools.ietf.org/html/rfc7636[Proof Key for Code Exchange] (PKCE).
78
78
If the client is running in an untrusted environment (such as a native application or web browser-based application) and is therefore incapable of maintaining the confidentiality of its credentials, PKCE is automatically used when the following conditions are true:
79
79
80
-
. `client-secret` is omitted (or empty)
80
+
. `client-secret` is omitted (or empty) and
81
81
. `client-authentication-method` is set to `none` (`ClientAuthenticationMethod.NONE`)
82
82
83
+
or
84
+
85
+
. When `ClientRegistration.clientSettings.requireProofKey` is `true` (in this case `ClientRegistration.authorizationGrantType` must be `authorization_code`)
86
+
87
+
83
88
[TIP]
84
89
====
85
90
If the OAuth 2.0 Provider supports PKCE for https://tools.ietf.org/html/rfc6749#section-2.1[Confidential Clients], you may (optionally) configure it using `DefaultOAuth2AuthorizationRequestResolver.setAuthorizationRequestCustomizer(OAuth2AuthorizationRequestCustomizers.withPkce())`.
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/servlet/oauth2/client/core.adoc
+5
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,10 @@ public final class ClientRegistration {
40
40
41
41
}
42
42
}
43
+
44
+
public static final class ClientSettings {
45
+
private boolean requireProofKey; // <17>
46
+
}
43
47
}
44
48
----
45
49
<1> `registrationId`: The ID that uniquely identifies the `ClientRegistration`.
@@ -65,6 +69,7 @@ This information is available only if the Spring Boot property `spring.security.
65
69
<15> `(userInfoEndpoint)authenticationMethod`: The authentication method used when sending the access token to the UserInfo Endpoint.
66
70
The supported values are *header*, *form*, and *query*.
67
71
<16> `userNameAttributeName`: The name of the attribute returned in the UserInfo Response that references the Name or Identifier of the end-user.
72
+
<17> [[oauth2Client-client-registration-requireProofKey]]`requireProofKey`: If `true` or if `authorizationGrantType` is `none`, then PKCE will be enabled by default.
68
73
69
74
You can initially configure a `ClientRegistration` by using discovery of an OpenID Connect Provider's https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Configuration endpoint] or an Authorization Server's https://tools.ietf.org/html/rfc8414#section-3[Metadata endpoint].
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/whats-new.adoc
+4
Original file line number
Diff line number
Diff line change
@@ -10,3 +10,7 @@ Below are the highlights of the release, or you can view https://github.com/spri
10
10
11
11
The `security.security.reached.filter.section` key name was corrected to `spring.security.reached.filter.section`.
12
12
Note that this may affect reports that operate on this key name.
13
+
14
+
== OAuth
15
+
16
+
* https://github.com/spring-projects/spring-security/pull/16386[gh-16386] - Enable PKCE for confidential clients using `ClientRegistration.clientSettings.requireProofKey=true` for xref:servlet/oauth2/client/core.adoc#oauth2Client-client-registration-requireProofKey[servlet] and xref:reactive/oauth2/client/core.adoc#oauth2Client-client-registration-requireProofKey[reactive] applications
Copy file name to clipboardExpand all lines: oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/jackson2/ClientRegistrationDeserializer.java
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2002-2020 the original author or authors.
2
+
* Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardExpand all lines: oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistration.java
+107-2
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2002-2022 the original author or authors.
2
+
* Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
26
26
importjava.util.LinkedHashSet;
27
27
importjava.util.List;
28
28
importjava.util.Map;
29
+
importjava.util.Objects;
29
30
importjava.util.Set;
30
31
31
32
importorg.apache.commons.logging.Log;
@@ -71,6 +72,8 @@ public final class ClientRegistration implements Serializable {
71
72
72
73
privateStringclientName;
73
74
75
+
privateClientSettingsclientSettings;
76
+
74
77
privateClientRegistration() {
75
78
}
76
79
@@ -162,6 +165,14 @@ public String getClientName() {
162
165
returnthis.clientName;
163
166
}
164
167
168
+
/**
169
+
* Returns the {@link ClientSettings client configuration settings}.
Copy file name to clipboardExpand all lines: oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/DefaultOAuth2AuthorizationRequestResolver.java
+3-2
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2002-2022 the original author or authors.
2
+
* Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardExpand all lines: oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/server/DefaultServerOAuth2AuthorizationRequestResolver.java
Copy file name to clipboardExpand all lines: oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/jackson2/OAuth2AuthorizedClientMixinTests.java
+69-1
Original file line number
Diff line number
Diff line change
@@ -214,6 +214,71 @@ public void deserializeWhenRequiredAttributesOnlyThenDeserializes() throws Excep
0 commit comments