This repository was archived by the owner on Apr 5, 2022. It is now read-only.
Fix OAuth1 redirect URL when server is behind a proxy.#261
Closed
brendanjbaker wants to merge 1 commit intospring-attic:masterfrom
Closed
Fix OAuth1 redirect URL when server is behind a proxy.#261brendanjbaker wants to merge 1 commit intospring-attic:masterfrom
brendanjbaker wants to merge 1 commit intospring-attic:masterfrom
Conversation
…me fix for OAuth1AuthenticationService that was applied to OAuth2AuthenticationService in commit 385e7ca (SOCIAL-447). Specifically, if the "Host" header is present in the request, the "X-Forwarded-Proto" and "X-Forwarded-Port" headers are used to generate the callback URL. This is because a reverse proxy may receive a request via HTTPS on port 443, but an internal application server will see the request as coming via HTTP over port 8080 (for example), and that information will subsequently be used to generate an incorrect redirect URL.
|
@brendanjbaker Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
|
@brendanjbaker Thank you for signing the Contributor License Agreement! |
codeconsole
added a commit
to codeconsole/spring-social
that referenced
this pull request
Oct 15, 2018
…cialAuthenticationService. Add Oath2 proxy fix to Oath1 implementation. Fixes spring-attic#261.
Contributor
|
Thanks for tagging me, this really seems like it should be moved into AbstractSocialAuthenticationService.java to prevent code duplication (especially considering the original solution doesn't work in all environments). #259 now includes your fix. |
Author
|
@codeconsole I agree fully. Since #259 has the same effect (and fix) as this, and since the other change included in #259 seems quite agreeable, I'm going to close this pull request. @habuma -- Can you please review and/or approve/merge #259? Than you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the same fix for
OAuth1AuthenticationServicethat was applied toOAuth2AuthenticationServicein commit 385e7ca (SOCIAL-447). Specifically, if theHostheader is present in the request, theX-Forwarded-ProtoandX-Forwarded-Portheaders are used to generate the callback URL. This is because a reverse proxy may receive a request via HTTPS on port 443, but an internal application server will see the request as coming via HTTP over port 8080 (for example), and that information will subsequently be used to generate an incorrect redirect URL.The callback URL automatically generated by
OAuth1AuthenticationServicewas:http://example.com/auth/twitter...Despite our site being HTTPS. Due to Twitter recently beginning to enforce strict callback URL matching, Twitter logins were broken because our Twitter application configuration defined our callback URL as:
https://example.com/auth/twitterI am using this fork in my production application and Twitter logins are now working. My specific setup is Spring Boot 2.0.5 running on Jetty, hosted behind nginx. The site is HTTPS-only, and HTTPS connections are terminated at nginx and forwarded to our internal Jetty host over HTTP, which is running on port 8080.
In case it's helpful for anybody, my nginx configuration for the reverse proxy section is as follows:
Tagging @jaffadog because he was the author of the original
OAuth2AuthenticationServicefix, in case he has any interest in following this or providing any feedback.Tagging @codeconsole because he has an open pull request (#259) that alters the corresponding logic in
OAuth2AuthenticationService. You may want to include the same change inOAuth1AuthenticationServiceif/when this is merged.