@@ -37,11 +37,6 @@ type OauthProxy struct {
3737
3838 redirectUrl *url.URL // the url to receive requests at
3939 provider providers.Provider
40− oauthLoginUrl *url.URL // to redirect the user to
41− oauthValidateUrl *url.URL // to validate the access token
42− oauthScope string
43− clientID string
44− clientSecret string
4540 ProxyPrefix string
4641 SignInMessage string
4742 HtpasswdFile *HtpasswdFile
@@ -147,25 +142,20 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
147142 OauthStartPath: fmt.Sprintf("%s/start", opts.ProxyPrefix),
148143 OauthCallbackPath: fmt.Sprintf("%s/callback", opts.ProxyPrefix),
149144
150− clientID: opts.ClientID,
151− clientSecret: opts.ClientSecret,
152− ProxyPrefix: opts.ProxyPrefix,
153− oauthScope: opts.provider.Data().Scope,
154− provider: opts.provider,
155− oauthLoginUrl: opts.provider.Data().LoginUrl,
156− oauthValidateUrl: opts.provider.Data().ValidateUrl,
157− serveMux: serveMux,
158− redirectUrl: redirectUrl,
159− skipAuthRegex: opts.SkipAuthRegex,
160− compiledRegex: opts.CompiledRegex,
161− PassBasicAuth: opts.PassBasicAuth,
162− PassAccessToken: opts.PassAccessToken,
163− AesCipher: aes_cipher,
164− templates: loadTemplates(opts.CustomTemplatesDir),
145+ ProxyPrefix: opts.ProxyPrefix,
146+ provider: opts.provider,
147+ serveMux: serveMux,
148+ redirectUrl: redirectUrl,
149+ skipAuthRegex: opts.SkipAuthRegex,
150+ compiledRegex: opts.CompiledRegex,
151+ PassBasicAuth: opts.PassBasicAuth,
152+ PassAccessToken: opts.PassAccessToken,
153+ AesCipher: aes_cipher,
154+ templates: loadTemplates(opts.CustomTemplatesDir),
165155 }
166156}
167157
168−func (p *OauthProxy) GetRedirectUrl(host string) string {
158+func (p *OauthProxy) GetRedirectURI(host string) string {
169159 // default to the request Host if not set
170160 if p.redirectUrl.Host != "" {
171161 return p.redirectUrl.String()
@@ -183,19 +173,6 @@ func (p *OauthProxy) GetRedirectUrl(host string) string {
183173 return u.String()
184174}
185175
186−func (p *OauthProxy) GetLoginURL(host, redirect string) string {
187− params := url.Values{}
188− params.Add("redirect_uri", p.GetRedirectUrl(host))
189− params.Add("approval_prompt", "force")
190− params.Add("scope", p.oauthScope)
191− params.Add("client_id", p.clientID)
192− params.Add("response_type", "code")
193− if strings.HasPrefix(redirect, "/") {
194− params.Add("state", redirect)
195− }
196− return fmt.Sprintf("%s?%s", p.oauthLoginUrl, params.Encode())
197−}
198−
199176func (p *OauthProxy) displayCustomLoginForm() bool {
200177 return p.HtpasswdFile != nil && p.DisplayHtpasswdForm
201178}
@@ -204,7 +181,7 @@ func (p *OauthProxy) redeemCode(host, code string) (string, string, error) {
204181 if code == "" {
205182 return "", "", errors.New("missing code")
206183 }
207− redirectUri := p.GetRedirectUrl(host)
184+ redirectUri := p.GetRedirectURI(host)
208185 body, access_token, err := p.provider.Redeem(redirectUri, code)
209186 if err != nil {
210187 return "", "", err
@@ -416,7 +393,8 @@ func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
416393 p.ErrorPage(rw, 500, "Internal Error", err.Error())
417394 return
418395 }
419− http.Redirect(rw, req, p.GetLoginURL(req.Host, redirect), 302)
396+ redirectURI := p.GetRedirectURI(req.Host)
397+ http.Redirect(rw, req, p.provider.GetLoginURL(redirectURI, redirect), 302)
420398 return
421399 }
422400 if req.URL.Path == p.OauthCallbackPath {