diff --git a/oauth2/github.go b/oauth2/github.go index 67395e4d8d..0f3e0e932d 100644 --- a/oauth2/github.go +++ b/oauth2/github.go @@ -15,26 +15,10 @@ import ( var _ Provider = &Github{} -// NewGithub constructs a Github with default scopes. -func NewGithub(clientID, clientSecret string, orgs []string, auth Authenticator, log chronograf.Logger) Github { - scopes := []string{"user:email"} - if len(orgs) > 0 { - scopes = append(scopes, "read:org") - } - return Github{ - ClientID: clientID, - ClientSecret: clientSecret, - Orgs: orgs, - Auth: auth, - Logger: log, - } -} - // Github provides OAuth Login and Callback server. Callback will set // an authentication cookie. This cookie's value is a JWT containing // the user's primary Github email address. type Github struct { - Auth Authenticator ClientID string ClientSecret string Orgs []string // Optional github organization checking diff --git a/server/mux.go b/server/mux.go index bc0aee55ac..4b72363b51 100644 --- a/server/mux.go +++ b/server/mux.go @@ -132,16 +132,14 @@ func NewMux(opts MuxOpts, service Service) http.Handler { // AuthAPI adds the OAuth routes if auth is enabled. func AuthAPI(opts MuxOpts, router *httprouter.Router) http.Handler { + gh := oauth2.Github{ + ClientID: opts.GithubClientID, + ClientSecret: opts.GithubClientSecret, + Orgs: opts.GithubOrgs, + Logger: opts.Logger, + } + auth := oauth2.NewJWT(opts.TokenSecret) - - gh := oauth2.NewGithub( - opts.GithubClientID, - opts.GithubClientSecret, - opts.GithubOrgs, - &auth, - opts.Logger, - ) - ghMux := oauth2.NewJWTMux(&gh, &auth, opts.Logger) router.Handler("GET", "/oauth/github/login", ghMux.Login()) router.Handler("GET", "/oauth/github/logout", ghMux.Logout())