Skip to content

Commit a11e614

Browse files
bedlajgrandja
authored andcommitted
Document OAuth2 Client behind proxy and redirect_uri
Fixes gh-7312
1 parent 345bfdd commit a11e614

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/login.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registra
4242
The *_registrationId_* is a unique identifier for the <<jc-oauth2login-client-registration,ClientRegistration>>.
4343
For our example, the `registrationId` is `google`.
4444

45+
IMPORTANT: If the OAuth Client is running behind a proxy server, it is recommended to check <<appendix-proxy-server, Proxy Server Configuration>> to ensure the application is correctly configured.
46+
Also, see the supported <<oauth2Client-auth-code-redirect-uri, `URI` template variables>> for `redirect-uri`.
47+
4548
[[webflux-oauth2-login-sample-config]]
4649
=== Configure `application.yml`
4750

docs/manual/src/docs/asciidoc/_includes/servlet/appendix/proxy-server.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ To fix this you can use https://tools.ietf.org/html/rfc7239[RFC 7239] to specify
99
To make the application aware of this, you need to either configure your application server aware of the X-Forwarded headers.
1010
For example Tomcat uses the https://tomcat.apache.org/tomcat-8.0-doc/api/org/apache/catalina/valves/RemoteIpValve.html[RemoteIpValve] and Jetty uses https://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/server/ForwardedRequestCustomizer.html[ForwardedRequestCustomizer].
1111
Alternatively, Spring 4.3+ users can leverage https://github.com/spring-projects/spring-framework/blob/v4.3.3.RELEASE/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java[ForwardedHeaderFilter].
12+
13+
Spring Boot users may use the `server.use-forward-headers` property to configure the application.
14+
See the https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-use-tomcat-behind-a-proxy-server[Spring Boot documentation] for further details.

docs/manual/src/docs/asciidoc/_includes/servlet/oauth2/oauth2-client.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ If the client is running in an untrusted environment (eg. native application or
430430
. `client-secret` is omitted (or empty)
431431
. `client-authentication-method` is set to "none" (`ClientAuthenticationMethod.NONE`)
432432

433+
[[oauth2Client-auth-code-redirect-uri]]
433434
The `DefaultOAuth2AuthorizationRequestResolver` also supports `URI` template variables for the `redirect-uri` using `UriComponentsBuilder`.
434435

435436
The following configuration uses all the supported `URI` template variables:

docs/manual/src/docs/asciidoc/_includes/servlet/oauth2/oauth2-login.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ In the "Set a redirect URI" sub-section, ensure that the *Authorized redirect UR
4242
TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registrationId}`.
4343
The *_registrationId_* is a unique identifier for the <<oauth2Client-client-registration,ClientRegistration>>.
4444

45+
IMPORTANT: If the OAuth Client is running behind a proxy server, it is recommended to check <<appendix-proxy-server, Proxy Server Configuration>> to ensure the application is correctly configured.
46+
Also, see the supported <<oauth2Client-auth-code-redirect-uri, `URI` template variables>> for `redirect-uri`.
47+
4548

4649
[[oauth2login-sample-application-config]]
4750
==== Configure application.yml

samples/boot/oauth2login-webflux/README.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ In the "Set a redirect URI" sub-section, ensure that the *Authorized redirect UR
4646
TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registrationId}`.
4747
The *_registrationId_* is a unique identifier for the `ClientRegistration`.
4848

49+
IMPORTANT: If the application is running behind a proxy server, it is recommended to check https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#appendix-proxy-server[Proxy Server Configuration] to ensure the application is correctly configured.
50+
Also, see the supported https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2Client-auth-code-redirect-uri[`URI` template variables] for `redirect-uri`.
51+
4952
[[google-application-config]]
5053
=== Configure application.yml
5154

@@ -110,6 +113,9 @@ and have granted access to the OAuth application on the _Authorize application_
110113
TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registrationId}`.
111114
The *_registrationId_* is a unique identifier for the `ClientRegistration`.
112115

116+
IMPORTANT: If the application is running behind a proxy server, it is recommended to check https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#appendix-proxy-server[Proxy Server Configuration] to ensure the application is correctly configured.
117+
Also, see the supported https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2Client-auth-code-redirect-uri[`URI` template variables] for `redirect-uri`.
118+
113119
[[github-application-config]]
114120
=== Configure application.yml
115121

@@ -185,6 +191,9 @@ and have granted access to the application on the _Authorize application_ page.
185191
TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registrationId}`.
186192
The *_registrationId_* is a unique identifier for the `ClientRegistration`.
187193

194+
IMPORTANT: If the application is running behind a proxy server, it is recommended to check https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#appendix-proxy-server[Proxy Server Configuration] to ensure the application is correctly configured.
195+
Also, see the supported https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2Client-auth-code-redirect-uri[`URI` template variables] for `redirect-uri`.
196+
188197
[[facebook-application-config]]
189198
=== Configure application.yml
190199

@@ -258,6 +267,9 @@ and have granted access to the application on the _Authorize application_ page.
258267
TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registrationId}`.
259268
The *_registrationId_* is a unique identifier for the `ClientRegistration`.
260269

270+
IMPORTANT: If the application is running behind a proxy server, it is recommended to check https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#appendix-proxy-server[Proxy Server Configuration] to ensure the application is correctly configured.
271+
Also, see the supported https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2Client-auth-code-redirect-uri[`URI` template variables] for `redirect-uri`.
272+
261273
[[okta-assign-application-people]]
262274
=== Assign Application to People
263275

samples/boot/oauth2login/README.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ In the "Set a redirect URI" sub-section, ensure that the *Authorized redirect UR
4343
TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registrationId}`.
4444
The *_registrationId_* is a unique identifier for the `ClientRegistration`.
4545

46+
IMPORTANT: If the application is running behind a proxy server, it is recommended to check https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#appendix-proxy-server[Proxy Server Configuration] to ensure the application is correctly configured.
47+
Also, see the supported https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2Client-auth-code-redirect-uri[`URI` template variables] for `redirect-uri`.
48+
4649
[[google-application-config]]
4750
=== Configure application.yml
4851

@@ -107,6 +110,9 @@ and have granted access to the OAuth application on the _Authorize application_
107110
TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registrationId}`.
108111
The *_registrationId_* is a unique identifier for the `ClientRegistration`.
109112

113+
IMPORTANT: If the application is running behind a proxy server, it is recommended to check https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#appendix-proxy-server[Proxy Server Configuration] to ensure the application is correctly configured.
114+
Also, see the supported https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2Client-auth-code-redirect-uri[`URI` template variables] for `redirect-uri`.
115+
110116
[[github-application-config]]
111117
=== Configure application.yml
112118

@@ -182,6 +188,9 @@ and have granted access to the application on the _Authorize application_ page.
182188
TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registrationId}`.
183189
The *_registrationId_* is a unique identifier for the `ClientRegistration`.
184190

191+
IMPORTANT: If the application is running behind a proxy server, it is recommended to check https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#appendix-proxy-server[Proxy Server Configuration] to ensure the application is correctly configured.
192+
Also, see the supported https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2Client-auth-code-redirect-uri[`URI` template variables] for `redirect-uri`.
193+
185194
[[facebook-application-config]]
186195
=== Configure application.yml
187196

@@ -255,6 +264,9 @@ and have granted access to the application on the _Authorize application_ page.
255264
TIP: The default redirect URI template is `{baseUrl}/login/oauth2/code/{registrationId}`.
256265
The *_registrationId_* is a unique identifier for the `ClientRegistration`.
257266

267+
IMPORTANT: If the application is running behind a proxy server, it is recommended to check https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#appendix-proxy-server[Proxy Server Configuration] to ensure the application is correctly configured.
268+
Also, see the supported https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2Client-auth-code-redirect-uri[`URI` template variables] for `redirect-uri`.
269+
258270
[[okta-assign-application-people]]
259271
=== Assign Application to People
260272

0 commit comments

Comments
 (0)