From 01956b7c8b85b4fdda395bf4d288140bee2f9868 Mon Sep 17 00:00:00 2001 From: Tomohiro Nagai Date: Sun, 22 Mar 2020 17:33:23 +0900 Subject: [PATCH] [KEYCLOAK-10633] Fix oauth uri slash issue when using base-uri --- config.go | 4 ++-- handlers.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.go b/config.go index 080af6ad3..f2c871d57 100644 --- a/config.go +++ b/config.go @@ -77,10 +77,10 @@ func newDefaultConfig() *Config { // WithOAuthURI returns the oauth uri func (r *Config) WithOAuthURI(uri string) string { if r.BaseURI != "" { - return fmt.Sprintf("%s/%s/%s", r.BaseURI, r.OAuthURI, uri) + return fmt.Sprintf("%s%s%s", r.BaseURI, r.OAuthURI, uri) } - return fmt.Sprintf("%s/%s", r.OAuthURI, uri) + return fmt.Sprintf("%s%s", r.OAuthURI, uri) } // isValid validates if the config is valid diff --git a/handlers.go b/handlers.go index d04c285f9..8021b4c09 100644 --- a/handlers.go +++ b/handlers.go @@ -63,7 +63,7 @@ func (r *oauthProxy) getRedirectionURL(w http.ResponseWriter, req *http.Request) w.WriteHeader(http.StatusForbidden) return "" } - return fmt.Sprintf("%s%s", redirect, r.config.WithOAuthURI("callback")) + return fmt.Sprintf("%s%s", redirect, r.config.WithOAuthURI(callbackURL)) } // oauthAuthorizationHandler is responsible for performing the redirection to oauth provider