git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #131 from ebardsley/master

Allow passing the value of "approval_prompt" as a flag or option.

commitd1c0208824bff0147b59dec725045c813c29aff6 authorJehiah Czebotar <jehiah@gmail.com> dateThu 27 Aug 2015, 07:33 (11 years ago) parentba81a0d33045a7
5 files changed+26−16
README.md+1 main.go+1 options.go+14−7 providers/provider_data.go+9−8 providers/provider_default.go+1−1
README.md+1
@@ -93,6 +93,7 @@ An example [oauth2_proxy.cfg](contrib/oauth2_proxy.cfg.example) config file is i
9393
9494```
9595Usage of oauth2_proxy:
96+ -approval_prompt="force": Oauth approval_prompt
9697 -authenticated-emails-file="": authenticate against emails via file (one per line)
9798 -client-id="": the OAuth Client ID: ie: "123456.apps.googleusercontent.com"
9899 -client-secret="": the OAuth Client Secret
main.go+1
@@ -63,6 +63,7 @@ func main() {
6363 flagSet.String("profile-url", "", "Profile access endpoint")
6464 flagSet.String("validate-url", "", "Access token validation endpoint")
6565 flagSet.String("scope", "", "Oauth scope specification")
66+ flagSet.String("approval-prompt", "force", "Oauth approval_prompt")
6667
6768 flagSet.Parse(os.Args[1:])
6869
options.go+14−7
@@ -46,12 +46,13 @@ type Options struct {
4646
4747 // These options allow for other providers besides Google, with
4848 // potential overrides.
49− Provider string `flag:"provider" cfg:"provider"`
50− LoginUrl string `flag:"login-url" cfg:"login_url"`
51− RedeemUrl string `flag:"redeem-url" cfg:"redeem_url"`
52− ProfileUrl string `flag:"profile-url" cfg:"profile_url"`
53− ValidateUrl string `flag:"validate-url" cfg:"validate_url"`
54− Scope string `flag:"scope" cfg:"scope"`
49+ Provider string `flag:"provider" cfg:"provider"`
50+ LoginUrl string `flag:"login-url" cfg:"login_url"`
51+ RedeemUrl string `flag:"redeem-url" cfg:"redeem_url"`
52+ ProfileUrl string `flag:"profile-url" cfg:"profile_url"`
53+ ValidateUrl string `flag:"validate-url" cfg:"validate_url"`
54+ Scope string `flag:"scope" cfg:"scope"`
55+ ApprovalPrompt string `flag:"approval-prompt" cfg:"approval_prompt"`
5556
5657 RequestLogging bool `flag:"request-logging" cfg:"request_logging"`
5758
@@ -76,6 +77,7 @@ func NewOptions() *Options {
7677 PassBasicAuth: true,
7778 PassAccessToken: false,
7879 PassHostHeader: true,
80+ ApprovalPrompt: "force",
7981 RequestLogging: true,
8082 }
8183}
@@ -165,7 +167,12 @@ func (o *Options) Validate() error {
165167}
166168
167169func parseProviderInfo(o *Options, msgs []string) []string {
168− p := &providers.ProviderData{Scope: o.Scope, ClientID: o.ClientID, ClientSecret: o.ClientSecret}
170+ p := &providers.ProviderData{
171+ Scope: o.Scope,
172+ ClientID: o.ClientID,
173+ ClientSecret: o.ClientSecret,
174+ ApprovalPrompt: o.ApprovalPrompt,
175+ }
169176 p.LoginUrl, msgs = parseUrl(o.LoginUrl, "login", msgs)
170177 p.RedeemUrl, msgs = parseUrl(o.RedeemUrl, "redeem", msgs)
171178 p.ProfileUrl, msgs = parseUrl(o.ProfileUrl, "profile", msgs)
providers/provider_data.go+9−8
@@ -5,14 +5,15 @@ import (
55)
66
77type ProviderData struct {
8− ProviderName string
9− ClientID string
10− ClientSecret string
11− LoginUrl *url.URL
12− RedeemUrl *url.URL
13− ProfileUrl *url.URL
14− ValidateUrl *url.URL
15− Scope string
8+ ProviderName string
9+ ClientID string
10+ ClientSecret string
11+ LoginUrl *url.URL
12+ RedeemUrl *url.URL
13+ ProfileUrl *url.URL
14+ ValidateUrl *url.URL
15+ Scope string
16+ ApprovalPrompt string
1617}
1718
1819func (p *ProviderData) Data() *ProviderData { return p }
providers/provider_default.go+1−1
@@ -80,7 +80,7 @@ func (p *ProviderData) GetLoginURL(redirectURI, finalRedirect string) string {
8080 a = *p.LoginUrl
8181 params, _ := url.ParseQuery(a.RawQuery)
8282 params.Set("redirect_uri", redirectURI)
83− params.Set("approval_prompt", "force")
83+ params.Set("approval_prompt", p.ApprovalPrompt)
8484 params.Add("scope", p.Scope)
8585 params.Set("client_id", p.ClientID)
8686 params.Set("response_type", "code")