Merge pull request #361 from jehiah/gofmt_361
travis: run gofmt and go vet
This commit is contained in:
		
						commit
						bb9b607440
					
				| 
						 | 
				
			
			@ -199,7 +199,7 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
 | 
			
		|||
		skipAuthRegex:      opts.SkipAuthRegex,
 | 
			
		||||
		compiledRegex:      opts.CompiledRegex,
 | 
			
		||||
		PassBasicAuth:      opts.PassBasicAuth,
 | 
			
		||||
		PassUserHeaders:   opts.PassUserHeaders,
 | 
			
		||||
		PassUserHeaders:    opts.PassUserHeaders,
 | 
			
		||||
		BasicAuthPassword:  opts.BasicAuthPassword,
 | 
			
		||||
		PassAccessToken:    opts.PassAccessToken,
 | 
			
		||||
		SkipProviderButton: opts.SkipProviderButton,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ type Options struct {
 | 
			
		|||
	PassAccessToken    bool     `flag:"pass-access-token" cfg:"pass_access_token"`
 | 
			
		||||
	PassHostHeader     bool     `flag:"pass-host-header" cfg:"pass_host_header"`
 | 
			
		||||
	SkipProviderButton bool     `flag:"skip-provider-button" cfg:"skip_provider_button"`
 | 
			
		||||
	PassUserHeaders   bool     `flag:"pass-user-headers" cfg:"pass_user_headers"`
 | 
			
		||||
	PassUserHeaders    bool     `flag:"pass-user-headers" cfg:"pass_user_headers"`
 | 
			
		||||
 | 
			
		||||
	// These options allow for other providers besides Google, with
 | 
			
		||||
	// potential overrides.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,11 +3,11 @@ package providers
 | 
			
		|||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/bitly/go-simplejson"
 | 
			
		||||
	"github.com/bitly/oauth2_proxy/api"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"github.com/bitly/go-simplejson"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type AzureProvider struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -67,26 +67,26 @@ func getAzureHeader(access_token string) http.Header {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func getEmailFromJSON(json *simplejson.Json) (string, error) {
 | 
			
		||||
 	var email string
 | 
			
		||||
	var email string
 | 
			
		||||
	var err error
 | 
			
		||||
	 
 | 
			
		||||
 | 
			
		||||
	email, err = json.Get("mail").String()
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
	if err != nil || email == "" {
 | 
			
		||||
		otherMails, otherMailsErr := json.Get("otherMails").Array()
 | 
			
		||||
		if len(otherMails) > 0{
 | 
			
		||||
		if len(otherMails) > 0 {
 | 
			
		||||
			email = otherMails[0].(string)
 | 
			
		||||
		}
 | 
			
		||||
		err = otherMailsErr
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	return email, err
 | 
			
		||||
 }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *AzureProvider) GetEmailAddress(s *SessionState) (string, error) {
 | 
			
		||||
	var email string
 | 
			
		||||
	var err error
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	if s.AccessToken == "" {
 | 
			
		||||
		return "", errors.New("missing access token")
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -109,16 +109,16 @@ func (p *AzureProvider) GetEmailAddress(s *SessionState) (string, error) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	email, err = json.Get("userPrincipalName").String()
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Printf("failed making request %s", err)
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	if email == "" {
 | 
			
		||||
		log.Printf("failed to get email address")
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	return email, err
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -197,4 +197,4 @@ func TestAzureProviderGetEmailAddressIncorrectOtherMails(t *testing.T) {
 | 
			
		|||
	email, err := p.GetEmailAddress(session)
 | 
			
		||||
	assert.Equal(t, "type assertion to string failed", err.Error())
 | 
			
		||||
	assert.Equal(t, "", email)
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue