Skip to content

Commit d5cb411

Browse files
committed
Update reactive OAuth2 docs
Issue gh-15938
1 parent 9d2ca3d commit d5cb411

File tree

6 files changed

+499
-215
lines changed

6 files changed

+499
-215
lines changed

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

Lines changed: 131 additions & 185 deletions
Large diffs are not rendered by default.

docs/modules/ROOT/pages/reactive/oauth2/client/authorized-clients.adoc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
[[oauth2Client-additional-features]]
2-
= Authorized Clients
1+
[[oauth2-client-additional-features]]
2+
= [[oauth2Client-additional-features]]Authorized Client Features
33

4+
This section covers additional features provided by Spring Security for OAuth2 Client.
45

5-
[[oauth2Client-registered-authorized-client]]
6-
== Resolving an Authorized Client
6+
[[oauth2-client-registered-authorized-client]]
7+
== [[oauth2Client-registered-authorized-client]]Resolving an Authorized Client
78

89
The `@RegisteredOAuth2AuthorizedClient` annotation provides the capability of resolving a method parameter to an argument value of type `OAuth2AuthorizedClient`.
910
This is a convenient alternative compared to accessing the `OAuth2AuthorizedClient` using the `ReactiveOAuth2AuthorizedClientManager` or `ReactiveOAuth2AuthorizedClientService`.
@@ -42,16 +43,15 @@ class OAuth2ClientController {
4243
----
4344
======
4445

45-
The `@RegisteredOAuth2AuthorizedClient` annotation is handled by `OAuth2AuthorizedClientArgumentResolver`, which directly uses a <<oauth2Client-authorized-manager-provider, ReactiveOAuth2AuthorizedClientManager>> and therefore inherits it's capabilities.
46+
The `@RegisteredOAuth2AuthorizedClient` annotation is handled by `OAuth2AuthorizedClientArgumentResolver`, which directly uses a xref:reactive/oauth2/client/core.adoc#oauth2Client-authorized-manager-provider[ReactiveOAuth2AuthorizedClientManager] and therefore inherits it's capabilities.
4647

47-
48-
[[oauth2Client-webclient-webflux]]
49-
== WebClient integration for Reactive Environments
48+
[[oauth2-client-web-client]]
49+
== [[oauth2Client-webclient-webflux]]WebClient integration for Reactive Environments
5050

5151
The OAuth 2.0 Client support integrates with `WebClient` using an `ExchangeFilterFunction`.
5252

5353
The `ServerOAuth2AuthorizedClientExchangeFilterFunction` provides a simple mechanism for requesting protected resources by using an `OAuth2AuthorizedClient` and including the associated `OAuth2AccessToken` as a Bearer Token.
54-
It directly uses an <<oauth2Client-authorized-manager-provider, ReactiveOAuth2AuthorizedClientManager>> and therefore inherits the following capabilities:
54+
It directly uses an xref:reactive/oauth2/client/core.adoc#oauth2Client-authorized-manager-provider[ReactiveOAuth2AuthorizedClientManager] and therefore inherits the following capabilities:
5555

5656
* An `OAuth2AccessToken` will be requested if the client has not yet been authorized.
5757
** `authorization_code` - triggers the Authorization Request redirect to initiate the flow
@@ -91,6 +91,7 @@ fun webClient(authorizedClientManager: ReactiveOAuth2AuthorizedClientManager): W
9191
----
9292
======
9393

94+
[[oauth2-client-web-client-authorized-client]]
9495
=== Providing the Authorized Client
9596

9697
The `ServerOAuth2AuthorizedClientExchangeFilterFunction` determines the client to use (for a request) by resolving the `OAuth2AuthorizedClient` from the `ClientRequest.attributes()` (request attributes).
@@ -184,7 +185,7 @@ fun index(): Mono<String> {
184185
======
185186
<1> `clientRegistrationId()` is a `static` method in `ServerOAuth2AuthorizedClientExchangeFilterFunction`.
186187

187-
188+
[[oauth2-client-web-client-default-authorized-client]]
188189
=== Defaulting the Authorized Client
189190

190191
If neither `OAuth2AuthorizedClient` or `ClientRegistration.getRegistrationId()` is provided as a request attribute, the `ServerOAuth2AuthorizedClientExchangeFilterFunction` can determine the _default_ client to use depending on it's configuration.

docs/modules/ROOT/pages/reactive/oauth2/client/client-authentication.adoc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
[[oauth2Client-client-auth-support]]
2-
= Client Authentication Support
1+
[[oauth2-client-authentication]]
2+
= [[oauth2Client-client-auth-support]]Client Authentication Support
33

4-
[[oauth2Client-client-credentials-auth]]
5-
== Client Credentials
4+
[[oauth2-client-authentication-client-credentials]]
5+
== [[oauth2Client-client-credentials-auth]]Client Credentials
66

7+
[[oauth2-client-authentication-client-credentials-client-secret-basic]]
78
=== Authenticate using `client_secret_basic`
89

910
Client Authentication with HTTP Basic is supported out of the box and no customization is necessary to enable it.
@@ -55,6 +56,7 @@ tokenResponseClient.setHeadersConverter(headersConverter)
5556
----
5657
======
5758

59+
[[oauth2-client-authentication-client-credentials-client-secret-post]]
5860
=== Authenticate using `client_secret_post`
5961

6062
Client Authentication with client credentials included in the request-body is supported out of the box and no customization is necessary to enable it.
@@ -76,8 +78,8 @@ spring:
7678
...
7779
----
7880

79-
[[oauth2Client-jwt-bearer-auth]]
80-
== JWT Bearer
81+
[[oauth2-client-authentication-jwt-bearer]]
82+
== [[oauth2Client-jwt-bearer-auth]]JWT Bearer
8183

8284
[NOTE]
8385
Please refer to JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication and Authorization Grants for further details on https://datatracker.ietf.org/doc/html/rfc7523#section-2.2[JWT Bearer] Client Authentication.
@@ -89,7 +91,7 @@ a signed JSON Web Token (JWS) in the `client_assertion` parameter.
8991
The `java.security.PrivateKey` or `javax.crypto.SecretKey` used for signing the JWS
9092
is supplied by the `com.nimbusds.jose.jwk.JWK` resolver associated with `NimbusJwtClientAuthenticationParametersConverter`.
9193

92-
94+
[[oauth2-client-authentication-jwt-bearer-private-key-jwt]]
9395
=== Authenticate using `private_key_jwt`
9496

9597
Given the following Spring Boot properties for an OAuth 2.0 Client registration:
@@ -160,7 +162,7 @@ tokenResponseClient.addParametersConverter(
160162
----
161163
======
162164

163-
165+
[[oauth2-client-authentication-jwt-bearer-client-secret-jwt]]
164166
=== Authenticate using `client_secret_jwt`
165167

166168
Given the following Spring Boot properties for an OAuth 2.0 Client registration:
@@ -230,6 +232,7 @@ tokenResponseClient.addParametersConverter(
230232
----
231233
======
232234

235+
[[oauth2-client-authentication-jwt-bearer-assertion]]
233236
=== Customizing the JWT assertion
234237

235238
The JWT produced by `NimbusJwtClientAuthenticationParametersConverter` contains the `iss`, `sub`, `aud`, `jti`, `iat` and `exp` claims by default. You can customize the headers and/or claims by providing a `Consumer<NimbusJwtClientAuthenticationParametersConverter.JwtClientAuthenticationContext<T>>` to `setJwtClientAssertionCustomizer()`. The following example shows how to customize claims of the JWT:
@@ -265,8 +268,8 @@ converter.setJwtClientAssertionCustomizer { context ->
265268
----
266269
======
267270

268-
[[oauth2Client-public-auth]]
269-
== Public Authentication
271+
[[oauth2-client-authentication-public]]
272+
== [[oauth2Client-public-auth]]Public Authentication
270273

271274
Public Client Authentication is supported out of the box and no customization is necessary to enable it.
272275

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ The OAuth 2.0 Client features provide support for the Client role as defined in
77
At a high-level, the core features available are:
88

99
.Authorization Grant support
10-
* https://tools.ietf.org/html/rfc6749#section-1.3.1[Authorization Code]
11-
* https://tools.ietf.org/html/rfc6749#section-6[Refresh Token]
12-
* https://tools.ietf.org/html/rfc6749#section-1.3.4[Client Credentials]
13-
* https://tools.ietf.org/html/rfc6749#section-1.3.3[Resource Owner Password Credentials]
14-
* https://datatracker.ietf.org/doc/html/rfc7523#section-2.1[JWT Bearer]
15-
* https://datatracker.ietf.org/doc/html/rfc8693#section-2.1[Token Exchange]
10+
* xref:reactive/oauth2/client/authorization-grants.adoc#oauth2-client-authorization-code[Authorization Code]
11+
* xref:reactive/oauth2/client/authorization-grants.adoc#oauth2-client-refresh-token[Refresh Token]
12+
* xref:reactive/oauth2/client/authorization-grants.adoc#oauth2-client-client-credentials[Client Credentials]
13+
* xref:reactive/oauth2/client/authorization-grants.adoc#oauth2-client-password[Resource Owner Password Credentials]
14+
* xref:reactive/oauth2/client/authorization-grants.adoc#oauth2-client-jwt-bearer[JWT Bearer]
15+
* xref:reactive/oauth2/client/authorization-grants.adoc#oauth2-client-token-exchange[Token Exchange]
1616

1717
.Client Authentication support
18-
* https://datatracker.ietf.org/doc/html/rfc7523#section-2.2[JWT Bearer]
18+
* xref:reactive/oauth2/client/client-authentication.adoc#oauth2-client-authentication-jwt-bearer[JWT Bearer]
1919

2020
.HTTP Client support
21-
* xref:reactive/oauth2/client/authorized-clients.adoc#oauth2Client-webclient-webflux[`WebClient` integration for Reactive Environments] (for requesting protected resources)
21+
* xref:reactive/oauth2/client/authorized-clients.adoc#oauth2-client-web-client[`WebClient` integration for Reactive Environments] (for requesting protected resources)
2222

2323
The `ServerHttpSecurity.oauth2Client()` DSL provides a number of configuration options for customizing the core components used by OAuth 2.0 Client.
2424

docs/modules/ROOT/pages/reactive/oauth2/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class SecurityConfig {
166166
[[oauth2-resource-server-access-token-opaque]]
167167
==== Opaque Token Support
168168

169-
The following example configures an `OpaqueTokenIntrospector` bean using Spring Boot configuration properties:
169+
The following example configures an `ReactiveOpaqueTokenIntrospector` bean using Spring Boot configuration properties:
170170

171171
[source,yaml]
172172
----
@@ -1608,7 +1608,7 @@ class SecurityConfig {
16081608
[[further-reading]]
16091609
== Further Reading
16101610

1611-
This preceding sections introduced Spring Security's support for OAuth2 with examples for common scenarios.
1611+
The preceding sections introduced Spring Security's support for OAuth2 with examples for common scenarios.
16121612
You can read more about OAuth2 Client and Resource Server in the following sections of the reference documentation:
16131613

16141614
* xref:reactive/oauth2/login/index.adoc[]

0 commit comments

Comments
 (0)