git.iko.soy/typeable/oauth2-proxy
on master help sign in
gofmt
commitc5fc7baa8690eeafe2fe89b794973960b765d204 authorJehiah Czebotar <jehiah@gmail.com> dateWed 29 Mar 2017, 09:36 (10 years ago) parentc1116ea
4 files changed+14−14
oauthproxy.go+1−1 options.go+1−1 providers/azure.go+11−11 providers/azure_test.go+1−1
oauthproxy.go+1−1
@@ -199,7 +199,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
199199 skipAuthRegex: opts.SkipAuthRegex,
200200 compiledRegex: opts.CompiledRegex,
201201 PassBasicAuth: opts.PassBasicAuth,
202− PassUserHeaders: opts.PassUserHeaders,
202+ PassUserHeaders: opts.PassUserHeaders,
203203 BasicAuthPassword: opts.BasicAuthPassword,
204204 PassAccessToken: opts.PassAccessToken,
205205 SkipProviderButton: opts.SkipProviderButton,
options.go+1−1
@@ -54,7 +54,7 @@ type Options struct {
5454 PassAccessToken bool `flag:"pass-access-token" cfg:"pass_access_token"`
5555 PassHostHeader bool `flag:"pass-host-header" cfg:"pass_host_header"`
5656 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"`
5858
5959 // These options allow for other providers besides Google, with
6060 // potential overrides.
providers/azure.go+11−11
@@ -3,11 +3,11 @@ package providers
33import (
44 "errors"
55 "fmt"
6+ "github.com/bitly/go-simplejson"
67 "github.com/bitly/oauth2_proxy/api"
78 "log"
89 "net/http"
910 "net/url"
10− "github.com/bitly/go-simplejson"
1111)
1212
1313type AzureProvider struct {
@@ -67,26 +67,26 @@ func getAzureHeader(access_token string) http.Header {
6767}
6868
6969func getEmailFromJSON(json *simplejson.Json) (string, error) {
70− var email string
70+ var email string
7171 var err error
72−
72+
7373 email, err = json.Get("mail").String()
74−
74+
7575 if err != nil || email == "" {
7676 otherMails, otherMailsErr := json.Get("otherMails").Array()
77− if len(otherMails) > 0{
77+ if len(otherMails) > 0 {
7878 email = otherMails[0].(string)
7979 }
8080 err = otherMailsErr
8181 }
82−
82+
8383 return email, err
84− }
84+}
8585
8686func (p *AzureProvider) GetEmailAddress(s *SessionState) (string, error) {
8787 var email string
8888 var err error
89−
89+
9090 if s.AccessToken == "" {
9191 return "", errors.New("missing access token")
9292 }
@@ -109,16 +109,16 @@ func (p *AzureProvider) GetEmailAddress(s *SessionState) (string, error) {
109109 }
110110
111111 email, err = json.Get("userPrincipalName").String()
112−
112+
113113 if err != nil {
114114 log.Printf("failed making request %s", err)
115115 return "", err
116116 }
117−
117+
118118 if email == "" {
119119 log.Printf("failed to get email address")
120120 return "", err
121121 }
122−
122+
123123 return email, err
124124}
providers/azure_test.go+1−1
@@ -197,4 +197,4 @@ func TestAzureProviderGetEmailAddressIncorrectOtherMails(t *testing.T) {
197197 email, err := p.GetEmailAddress(session)
198198 assert.Equal(t, "type assertion to string failed", err.Error())
199199 assert.Equal(t, "", email)
200−}
200+}