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/manual/src/docs/asciidoc/_includes/reactive/oauth2/login.adoc
+7-3
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@ At this point, the OAuth Client retrieves your email address and basic profile i
89
89
== Using OpenID Provider Configuration
90
90
91
91
For well known providers, Spring Security provides the necessary defaults for the OAuth Authorization Provider's configuration.
92
-
If you are working with your own Authorization Provider that supports https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[OpenID Provider Configuration], you may use the https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationResponse[OpenID Provider Configuration Response] the issuer-uri can be used to configure the application.
92
+
If you are working with your own Authorization Provider that supports https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[OpenID Provider Configuration] or https://tools.ietf.org/html/rfc8414#section-3[Authorization Server Metadata], the https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationResponse[OpenID Provider Configuration Response]'s `issuer-uri` can be used to configure the application.
The `issuer-uri` instructs Spring Security to leverage the endpoint at `https://idp.example.com/auth/realms/demo/.well-known/openid-configuration` to discover the configuration.
109
+
The `issuer-uri` instructs Spring Security to query in series the endpoints `https://idp.example.com/auth/realms/demo/.well-known/openid-configuration`, `https://idp.example.com/.well-known/openid-configuration/auth/realms/demo`, or `https://idp.example.com/.well-known/oauth-authorization-server/auth/realms/demo` to discover the configuration.
110
+
111
+
[NOTE]
112
+
Spring Security will query the endpoints one at a time, stopping at the first that gives a 200 response.
113
+
110
114
The `client-id` and `client-secret` are linked to the provider because `keycloak` is used for both the provider and the registration.
111
115
112
116
@@ -120,7 +124,7 @@ A minimal OAuth2 Login configuration is shown below:
Copy file name to clipboardExpand all lines: docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/resource-server.adoc
+14-11
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
[[webflux-oauth2-resource-server]]
2
-
= OAuth2 Resource Server
2
+
= OAuth 2.0 Resource Server
3
3
4
4
Spring Security supports protecting endpoints using two forms of OAuth 2.0 https://tools.ietf.org/html/rfc6750.html[Bearer Tokens]:
5
5
@@ -36,15 +36,15 @@ spring:
36
36
oauth2:
37
37
resourceserver:
38
38
jwt:
39
-
issuer-uri: https://idp.example.com
39
+
issuer-uri: https://idp.example.com/issuer
40
40
----
41
41
42
-
Where `https://idp.example.com` is the value contained in the `iss` claim for JWT tokens that the authorization server will issue.
42
+
Where `https://idp.example.com/issuer` is the value contained in the `iss` claim for JWT tokens that the authorization server will issue.
43
43
Resource Server will use this property to further self-configure, discover the authorization server's public keys, and subsequently validate incoming JWTs.
44
44
45
45
[NOTE]
46
-
To use the `issuer-uri` property, it must also be true that `https://idp.example.com/.well-known/openid-configuration` is a supported endpoint for the authorization server.
47
-
This endpoint is referred to as a https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Provider Configuration] endpoint.
46
+
To use the `issuer-uri` property, it must also be true that one of `https://idp.example.com/issuer/.well-known/openid-configuration`, `https://idp.example.com/.well-known/openid-configuration/issuer`, or `https://idp.example.com/.well-known/oauth-authorization-server/issuer` is a supported endpoint for the authorization server.
47
+
This endpoint is referred to as a https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Provider Configuration] endpoint or a https://tools.ietf.org/html/rfc8414#section-3[Authorization Server Metadata] endpoint.
48
48
49
49
And that's it!
50
50
@@ -54,7 +54,7 @@ When this property and these dependencies are used, Resource Server will automat
54
54
55
55
It achieves this through a deterministic startup process:
56
56
57
-
1. Hit the Provider Configuration endpoint, `https://idp.example.com/.well-known/openid-configuration`, processing the response for the `jwks_url` property
57
+
1. Hit the Provider Configuration or Authorization Server Metadata endpoint, processing the response for the `jwks_url` property
58
58
2. Configure the validation strategy to query `jwks_url` for valid public keys
59
59
3. Configure the validation strategy to validate each JWTs `iss` claim against `https://idp.example.com`.
60
60
@@ -95,7 +95,7 @@ From here, consider jumping to:
95
95
[[webflux-oauth2resourceserver-jwt-jwkseturi]]
96
96
=== Specifying the Authorization Server JWK Set Uri Directly
97
97
98
-
If the authorization server doesn't support the Provider Configuration endpoint, or if Resource Server must be able to start up independently from the authorization server, then `issuer-uri` can be exchanged for `jwk-set-uri`:
98
+
If the authorization server doesn't support any configuration endpoints, or if Resource Server must be able to start up independently from the authorization server, then the `jwk-set-uri` can be supplied as well:
Calling `{security-api-url}org/springframework/security/oauth2/jwt/ReactiveJwtDecoders.html#fromIssuerLocation-java.lang.String-[ReactiveJwtDecoders#fromIssuerLocation]` is what invokes the Provider Configuration or Authorization Server Metadata endpoint in order to derive the JWK Set Uri.
176
179
If the application doesn't expose a `ReactiveJwtDecoder` bean, then Spring Boot will expose the above default one.
177
180
178
181
And its configuration can be overridden using `jwkSetUri()` or replaced using `decoder()`.
@@ -494,7 +497,7 @@ Resource Server uses `JwtTimestampValidator` to verify a token's validity window
@@ -153,6 +154,26 @@ The name may be used in certain scenarios, such as when displaying the name of t
153
154
The supported values are *header*, *form* and *query*.
154
155
<15> `userNameAttributeName`: The name of the attribute returned in the UserInfo Response that references the Name or Identifier of the end-user.
155
156
157
+
[[oauth2Client-client-registrations]]
158
+
==== ClientRegistrations
159
+
160
+
A `ClientRegistration` can be initially configured by hitting an authorization server's https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Provider Configuration] endpoint or a https://tools.ietf.org/html/rfc8414#section-3[Authorization Server Metadata] endpoint.
161
+
162
+
`ClientRegistrations` provides convenience methods for generating a `ClientRegistration` in this way, as can be seen in the following example:
163
+
164
+
[source,java]
165
+
----
166
+
@Bean
167
+
public ClientRegistrationRepository clientRegistrationRepository() {
return new InMemoryClientRegistrationRepository(clientRegistration);
171
+
}
172
+
----
173
+
174
+
The above code will query in series `https://idp.example.com/issuer/.well-known/openid-configuration`, and then `https://idp.example.com/.well-known/openid-configuration/issuer`, and finally `https://idp.example.com/.well-known/oauth-authorization-server/issuer`, stopping at the first to return a 200 response.
175
+
176
+
As an alternative, you can invoke `ClientRegistrations#fromOidcIssuerLocation` to only hit the OIDC Provider Configuration endpoint.
Copy file name to clipboardExpand all lines: docs/manual/src/docs/asciidoc/_includes/servlet/preface/oauth2-resourceserver.adoc
+14-10
Original file line number
Diff line number
Diff line change
@@ -36,15 +36,15 @@ spring:
36
36
oauth2:
37
37
resourceserver:
38
38
jwt:
39
-
issuer-uri: https://idp.example.com
39
+
issuer-uri: https://idp.example.com/issuer
40
40
----
41
41
42
-
Where `https://idp.example.com` is the value contained in the `iss` claim for JWT tokens that the authorization server will issue.
42
+
Where `https://idp.example.com/issuer` is the value contained in the `iss` claim for JWT tokens that the authorization server will issue.
43
43
Resource Server will use this property to further self-configure, discover the authorization server's public keys, and subsequently validate incoming JWTs.
44
44
45
45
[NOTE]
46
-
To use the `issuer-uri` property, it must also be true that `https://idp.example.com/.well-known/openid-configuration` is a supported endpoint for the authorization server.
47
-
This endpoint is referred to as a https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Provider Configuration] endpoint.
46
+
To use the `issuer-uri` property, it must also be true that one of `https://idp.example.com/issuer/.well-known/openid-configuration`, `https://idp.example.com/.well-known/openid-configuration/issuer`, or `https://idp.example.com/.well-known/oauth-authorization-server/issuer` is a supported endpoint for the authorization server.
47
+
This endpoint is referred to as a https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Provider Configuration] endpoint or a https://tools.ietf.org/html/rfc8414#section-3[Authorization Server Metadata] endpoint.
48
48
49
49
And that's it!
50
50
@@ -54,7 +54,7 @@ When this property and these dependencies are used, Resource Server will automat
54
54
55
55
It achieves this through a deterministic startup process:
56
56
57
-
1. Hit the Provider Configuration endpoint, `https://idp.example.com/.well-known/openid-configuration`, processing the response for the `jwks_url` property
57
+
1. Hit the Provider Configuration or Authorization Server Metadata endpoint, processing the response for the `jwks_url` property
58
58
2. Configure the validation strategy to query `jwks_url` for valid public keys
59
59
3. Configure the validation strategy to validate each JWTs `iss` claim against `https://idp.example.com`.
60
60
@@ -95,7 +95,7 @@ From here, consider jumping to:
95
95
[[oauth2resourceserver-jwt-jwkseturi]]
96
96
=== Specifying the Authorization Server JWK Set Uri Directly
97
97
98
-
If the authorization server doesn't support the Provider Configuration endpoint, or if Resource Server must be able to start up independently from the authorization server, then `issuer-uri` can be exchanged for `jwk-set-uri`:
98
+
If the authorization server doesn't support any configuration endpoints, or if Resource Server must be able to start up independently from the authorization server, then the `jwk-set-uri` can be supplied as well:
Calling `{security-api-url}org/springframework/security/oauth2/jwt/JwtDecoders.html#fromIssuerLocation-java.lang.String-[JwtDecoders#fromIssuerLocation]` is what invokes the Provider Configuration or Authorization Server Metadata endpoint in order to derive the JWK Set Uri.
175
+
172
176
If the application doesn't expose a `JwtDecoder` bean, then Spring Boot will expose the above default one.
173
177
174
178
And its configuration can be overridden using `jwkSetUri()` or replaced using `decoder()`.
@@ -512,7 +516,7 @@ Resource Server uses `JwtTimestampValidator` to verify a token's validity window
512
516
@Bean
513
517
JwtDecoder jwtDecoder() {
514
518
NimbusJwtDecoder jwtDecoder = (NimbusJwtDecoder)
515
-
JwtDecoders.fromOidcIssuerLocation(issuerUri);
519
+
JwtDecoders.fromIssuerLocation(issuerUri);
516
520
517
521
OAuth2TokenValidator<Jwt> withClockSkew = new DelegatingOAuth2TokenValidator<>(
518
522
new JwtTimestampValidator(Duration.ofSeconds(60)),
@@ -554,7 +558,7 @@ Then, to add into a resource server, it's a matter of specifying the `JwtDecoder
554
558
@Bean
555
559
JwtDecoder jwtDecoder() {
556
560
NimbusJwtDecoder jwtDecoder = (NimbusJwtDecoder)
557
-
JwtDecoders.fromOidcIssuerLocation(issuerUri);
561
+
JwtDecoders.fromIssuerLocation(issuerUri);
558
562
559
563
OAuth2TokenValidator<Jwt> audienceValidator = new AudienceValidator();
0 commit comments