mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2024-11-28 09:08:44 +02:00
Refactor makeLoginURL to accept extraParams
And don't require the caller to know how to use the returned params.
This commit is contained in:
parent
4eb9612679
commit
74918c40d8
@ -212,10 +212,10 @@ func (p *AzureProvider) GetEmailAddress(ctx context.Context, s *sessions.Session
|
||||
}
|
||||
|
||||
func (p *AzureProvider) GetLoginURL(redirectURI, state string) string {
|
||||
a, params := makeLoginURL(p.ProviderData, redirectURI, state)
|
||||
extraParams := url.Values{}
|
||||
if p.ProtectedResource != nil && p.ProtectedResource.String() != "" {
|
||||
params.Add("resource", p.ProtectedResource.String())
|
||||
extraParams.Add("resource", p.ProtectedResource.String())
|
||||
}
|
||||
a.RawQuery = params.Encode()
|
||||
a := makeLoginURL(p.ProviderData, redirectURI, state, extraParams)
|
||||
return a.String()
|
||||
}
|
||||
|
@ -225,12 +225,12 @@ func (p *LoginGovProvider) Redeem(ctx context.Context, redirectURL, code string)
|
||||
|
||||
// GetLoginURL overrides GetLoginURL to add login.gov parameters
|
||||
func (p *LoginGovProvider) GetLoginURL(redirectURI, state string) string {
|
||||
a, params := makeLoginURL(p.ProviderData, redirectURI, state)
|
||||
extraParams := url.Values{}
|
||||
if p.AcrValues == "" {
|
||||
acr := "http://idmanagement.gov/ns/assurance/loa/1"
|
||||
params.Add("acr_values", acr)
|
||||
extraParams.Add("acr_values", acr)
|
||||
}
|
||||
params.Add("nonce", p.Nonce)
|
||||
a.RawQuery = params.Encode()
|
||||
extraParams.Add("nonce", p.Nonce)
|
||||
a := makeLoginURL(p.ProviderData, redirectURI, state, extraParams)
|
||||
return a.String()
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ func (p *ProviderData) Redeem(ctx context.Context, redirectURL, code string) (s
|
||||
|
||||
// GetLoginURL with typical oauth parameters
|
||||
func (p *ProviderData) GetLoginURL(redirectURI, state string) string {
|
||||
a, params := makeLoginURL(p, redirectURI, state)
|
||||
a.RawQuery = params.Encode()
|
||||
extraParams := url.Values{}
|
||||
a := makeLoginURL(p, redirectURI, state, extraParams)
|
||||
return a.String()
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ func makeOIDCHeader(accessToken string) http.Header {
|
||||
return makeAuthorizationHeader(tokenTypeBearer, accessToken, extraHeaders)
|
||||
}
|
||||
|
||||
func makeLoginURL(p *ProviderData, redirectURI, state string) (url.URL, url.Values) {
|
||||
func makeLoginURL(p *ProviderData, redirectURI, state string, extraParams url.Values) url.URL {
|
||||
a := *p.LoginURL
|
||||
params, _ := url.ParseQuery(a.RawQuery)
|
||||
params.Set("redirect_uri", redirectURI)
|
||||
@ -47,5 +47,11 @@ func makeLoginURL(p *ProviderData, redirectURI, state string) (url.URL, url.Valu
|
||||
params.Set("client_id", p.ClientID)
|
||||
params.Set("response_type", "code")
|
||||
params.Add("state", state)
|
||||
return a, params
|
||||
for n, p := range extraParams {
|
||||
for _, v := range p {
|
||||
params.Add(n, v)
|
||||
}
|
||||
}
|
||||
a.RawQuery = params.Encode()
|
||||
return a
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user