git.iko.soy/typeable/oauth2-proxy
on master help sign in
gofmt
c5fc7baJehiah Czebotar
oauthproxy.go+1−1
@@ -199,7 +199,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
199 skipAuthRegex: opts.SkipAuthRegex,
199 skipAuthRegex: opts.SkipAuthRegex,
200 compiledRegex: opts.CompiledRegex,
200 compiledRegex: opts.CompiledRegex,
201 PassBasicAuth: opts.PassBasicAuth,
201 PassBasicAuth: opts.PassBasicAuth,
202− PassUserHeaders: opts.PassUserHeaders,
202+ PassUserHeaders: opts.PassUserHeaders,
203 BasicAuthPassword: opts.BasicAuthPassword,
203 BasicAuthPassword: opts.BasicAuthPassword,
204 PassAccessToken: opts.PassAccessToken,
204 PassAccessToken: opts.PassAccessToken,
205 SkipProviderButton: opts.SkipProviderButton,
205 SkipProviderButton: opts.SkipProviderButton,
options.go+1−1
@@ -54,7 +54,7 @@ type Options struct {
54 PassAccessToken bool `flag:"pass-access-token" cfg:"pass_access_token"`
54 PassAccessToken bool `flag:"pass-access-token" cfg:"pass_access_token"`
55 PassHostHeader bool `flag:"pass-host-header" cfg:"pass_host_header"`
55 PassHostHeader bool `flag:"pass-host-header" cfg:"pass_host_header"`
56 SkipProviderButton bool `flag:"skip-provider-button" cfg:"skip_provider_button"`
56 SkipProviderButton bool `flag:"skip-provider-button" cfg:"skip_provider_button"`
57− PassUserHeaders bool `flag:"pass-user-headers" cfg:"pass_user_headers"`
57+ PassUserHeaders bool `flag:"pass-user-headers" cfg:"pass_user_headers"`
58
58
59 // These options allow for other providers besides Google, with
59 // These options allow for other providers besides Google, with
60 // potential overrides.
60 // potential overrides.
providers/azure.go+11−11
@@ -3,11 +3,11 @@ package providers
3import (
3import (
4 "errors"
4 "errors"
5 "fmt"
5 "fmt"
6+ "github.com/bitly/go-simplejson"
6 "github.com/bitly/oauth2_proxy/api"
7 "github.com/bitly/oauth2_proxy/api"
7 "log"
8 "log"
8 "net/http"
9 "net/http"
9 "net/url"
10 "net/url"
10− "github.com/bitly/go-simplejson"
11)
11)
12
12
13type AzureProvider struct {
13type AzureProvider struct {
@@ -67,26 +67,26 @@ func getAzureHeader(access_token string) http.Header {
67}
67}
68
68
69func getEmailFromJSON(json *simplejson.Json) (string, error) {
69func getEmailFromJSON(json *simplejson.Json) (string, error) {
70− var email string
70+ var email string
71 var err error
71 var err error
72−
72+
73 email, err = json.Get("mail").String()
73 email, err = json.Get("mail").String()
74−
74+
75 if err != nil || email == "" {
75 if err != nil || email == "" {
76 otherMails, otherMailsErr := json.Get("otherMails").Array()
76 otherMails, otherMailsErr := json.Get("otherMails").Array()
77− if len(otherMails) > 0{
77+ if len(otherMails) > 0 {
78 email = otherMails[0].(string)
78 email = otherMails[0].(string)
79 }
79 }
80 err = otherMailsErr
80 err = otherMailsErr
81 }
81 }
82−
82+
83 return email, err
83 return email, err
84− }
84+}
85
85
86func (p *AzureProvider) GetEmailAddress(s *SessionState) (string, error) {
86func (p *AzureProvider) GetEmailAddress(s *SessionState) (string, error) {
87 var email string
87 var email string
88 var err error
88 var err error
89−
89+
90 if s.AccessToken == "" {
90 if s.AccessToken == "" {
91 return "", errors.New("missing access token")
91 return "", errors.New("missing access token")
92 }
92 }
@@ -109,16 +109,16 @@ func (p *AzureProvider) GetEmailAddress(s *SessionState) (string, error) {
109 }
109 }
110
110
111 email, err = json.Get("userPrincipalName").String()
111 email, err = json.Get("userPrincipalName").String()
112−
112+
113 if err != nil {
113 if err != nil {
114 log.Printf("failed making request %s", err)
114 log.Printf("failed making request %s", err)
115 return "", err
115 return "", err
116 }
116 }
117−
117+
118 if email == "" {
118 if email == "" {
119 log.Printf("failed to get email address")
119 log.Printf("failed to get email address")
120 return "", err
120 return "", err
121 }
121 }
122−
122+
123 return email, err
123 return email, err
124}
124}
providers/azure_test.go+1−1
@@ -197,4 +197,4 @@ func TestAzureProviderGetEmailAddressIncorrectOtherMails(t *testing.T) {
197 email, err := p.GetEmailAddress(session)
197 email, err := p.GetEmailAddress(session)
198 assert.Equal(t, "type assertion to string failed", err.Error())
198 assert.Equal(t, "type assertion to string failed", err.Error())
199 assert.Equal(t, "", email)
199 assert.Equal(t, "", email)
200−}
200+}