From 549766666ef0c9989f8f63b250f27f6b43c37f84 Mon Sep 17 00:00:00 2001 From: dt-rush Date: Tue, 5 Mar 2019 09:58:26 -0500 Subject: [PATCH] fix redirect url param handling (#10) * Added conditional to prevent user-supplied redirect URL getting clobbered Change-type: patch * use redirectURL as OAuthCallbackURL (as it should be!) Change-type: patch --- CHANGELOG.md | 1 + oauthproxy.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0805a6b..cc3171a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - [#68](https://github.com/pusher/oauth2_proxy/pull/68) forward X-Auth-Access-Token header (@davidholsgrove) - [#41](https://github.com/pusher/oauth2_proxy/pull/41) Added option to manually specify OIDC endpoints instead of relying on discovery - [#83](https://github.com/pusher/oauth2_proxy/pull/83) Add `id_token` refresh to Google provider (@leki75) +- [#10](https://github.com/pusher/oauth2_proxy/pull/10) fix redirect url param handling (@dt-rush) # v3.1.0 diff --git a/oauthproxy.go b/oauthproxy.go index 68b1522..941e934 100644 --- a/oauthproxy.go +++ b/oauthproxy.go @@ -183,7 +183,9 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy { } redirectURL := opts.redirectURL - redirectURL.Path = fmt.Sprintf("%s/callback", opts.ProxyPrefix) + if redirectURL.String() == "" { + redirectURL.Path = fmt.Sprintf("%s/callback", opts.ProxyPrefix) + } log.Printf("OAuthProxy configured for %s Client ID: %s", opts.provider.Data().ProviderName, opts.ClientID) refresh := "disabled" @@ -218,7 +220,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy { SignInPath: fmt.Sprintf("%s/sign_in", opts.ProxyPrefix), SignOutPath: fmt.Sprintf("%s/sign_out", opts.ProxyPrefix), OAuthStartPath: fmt.Sprintf("%s/start", opts.ProxyPrefix), - OAuthCallbackPath: fmt.Sprintf("%s/callback", opts.ProxyPrefix), + OAuthCallbackPath: redirectURL.Path, AuthOnlyPath: fmt.Sprintf("%s/auth", opts.ProxyPrefix), ProxyPrefix: opts.ProxyPrefix,