Skip to content

Commit 6a085f9

Browse files
committed
Document Authorization Server PKCE settings
Updated the documentation to reflect recent changes to enable PKCE by default for `authorization_code` flows in the documentation for both authorization_server and client. Signed-off-by: Elayne Bloom <5840349+bloomsei@users.noreply.github.com>
1 parent 0d5f42f commit 6a085f9

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,19 @@ spring:
7474
----
7575

7676
Public Clients are supported using https://tools.ietf.org/html/rfc7636[Proof Key for Code Exchange] (PKCE).
77-
If the client is running in an untrusted environment (eg. native application or web browser-based application) and therefore incapable of maintaining the confidentiality of it's credentials, PKCE will automatically be used when the following conditions are true:
77+
If the client is running in an untrusted environment (eg. native application or web browser-based application) and therefore incapable of maintaining the confidentiality of its credentials, PKCE will automatically be used when the following conditions are true:
7878

79-
. `client-secret` is omitted (or empty)
80-
. `client-authentication-method` is set to "none" (`ClientAuthenticationMethod.NONE`)
79+
. `client-secret` is omitted (or empty) and
80+
. `client-authentication-method` is set to `none` (`ClientAuthenticationMethod.NONE`)
8181

8282
or
8383

84-
. When `ClientRegistration.clientSettings.requireProofKey` is `true` (in this case `ClientRegistration.authorizationGrantType` must be `authorization_code`)
84+
. `authorization-grant-type` is set to `authorization_code` (`AuthorizationGrantType.AUTHORIZATION_CODE`)
85+
8586

8687
[TIP]
8788
====
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())`.
89+
If the OAuth 2.0 Provider doesn't support PKCE for https://tools.ietf.org/html/rfc6749#section-2.1[Confidential Clients], you need to disable it by setting `ClientRegistration.clientSettings.requireProofKey` to `false`.
8990
====
9091

9192
[[oauth2-client-authorization-code-redirect-uri]]

docs/modules/ROOT/pages/reactive/oauth2/client/core.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The name may be used in certain scenarios, such as when displaying the name of t
6868
<15> `(userInfoEndpoint)authenticationMethod`: The authentication method used when sending the access token to the UserInfo Endpoint.
6969
The supported values are *header*, *form* and *query*.
7070
<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.
71+
<17> [[oauth2Client-client-registration-requireProofKey]]`requireProofKey`: If `true` or if `clientAuthenticationMethod` is `none`, then PKCE will be enabled. Defaults to `true` for `authorization_code` grant type and `false` for other grant types.
7272

7373
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].
7474

docs/modules/ROOT/pages/servlet/oauth2/authorization-server/core-model-components.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,32 @@ public class RegisteredClient implements Serializable {
9292
<12> `clientSettings`: The custom settings for the client – for example, require https://datatracker.ietf.org/doc/html/rfc7636[PKCE], require authorization consent, and others.
9393
<13> `tokenSettings`: The custom settings for the OAuth2 tokens issued to the client – for example, access/refresh token time-to-live, reuse refresh tokens, and others.
9494

95+
[[oauth2AuthorizationServer-client-settings]]
96+
== ClientSettings
97+
98+
`ClientSettings` is a configuration object that contains custom settings for a client. The following example shows the available settings and their default values:
99+
100+
[source,java]
101+
----
102+
ClientSettings.builder()
103+
.requireProofKey() <1>
104+
.requireAuthorizationConsent() <2>
105+
.jwkSetUrl() <3>
106+
.tokenEndpointAuthenticationSigningAlgorithm() <4>
107+
.x509CertificateSubjectDN() <5>
108+
.build();
109+
----
110+
<1> `requireProofKey`: If `true`, the client is required to provide a proof key challenge and verifier when performing the Authorization Code Grant flow (PKCE). The default is `true`.
111+
<2> `requireAuthorizationConsent`: If `true`, authorization consent is required when the client requests access. The default is `false`.
112+
<3> `jwkSetUrl`: The URL for the client's JSON Web Key Set. Used for `client_secret_jwt` and `private_key_jwt` client authentication methods, as well as for Self-Signed Certificate Mutual-TLS.
113+
<4> `tokenEndpointAuthenticationSigningAlgorithm`: The JWS algorithm required for signing the JWT used to authenticate the client at the Token Endpoint.
114+
<5> `x509CertificateSubjectDN`: The expected subject distinguished name in the client X509Certificate for PKI Mutual-TLS client authentication.
115+
116+
[NOTE]
117+
====
118+
https://datatracker.ietf.org/doc/html/rfc7636[Proof Key for Code Exchange (PKCE)] is enabled by default for all clients using the Authorization Code grant. To disable PKCE, set `requireProofKey` to `false`
119+
====
120+
95121
[[oauth2AuthorizationServer-registered-client-repository]]
96122
== RegisteredClientRepository
97123

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ If the client is running in an untrusted environment (such as a native applicati
8282

8383
or
8484

85-
. When `ClientRegistration.clientSettings.requireProofKey` is `true` (in this case `ClientRegistration.authorizationGrantType` must be `authorization_code`)
85+
. `authorization-grant-type` is set to `authorization_code` (`AuthorizationGrantType.AUTHORIZATION_CODE`)
8686

8787

8888
[TIP]
8989
====
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())`.
90+
If the OAuth 2.0 Provider doesn't support PKCE for https://tools.ietf.org/html/rfc6749#section-2.1[Confidential Clients], you need to disable it by setting `ClientRegistration.clientSettings.requireProofKey` to `false`.
9191
====
9292

9393
[[oauth2-client-authorization-code-redirect-uri]]

docs/modules/ROOT/pages/servlet/oauth2/client/core.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ This information is available only if the Spring Boot property `spring.security.
6969
<15> `(userInfoEndpoint)authenticationMethod`: The authentication method used when sending the access token to the UserInfo Endpoint.
7070
The supported values are *header*, *form*, and *query*.
7171
<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 `clientAuthenticationMethod` is `none`, then PKCE will be enabled.
72+
<17> [[oauth2Client-client-registration-requireProofKey]]`requireProofKey`: If `true` or if `clientAuthenticationMethod` is `none`, then PKCE will be enabled. Defaults to `true` for `authorization_code` grant type and `false` for other grant types.
7373

7474
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].
7575

0 commit comments

Comments
 (0)