Remove unneeded authenticator from github
parent
7f0e61e484
commit
9c3ffed99e
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue