resolved reviewer's comments

This commit is contained in:
Souhaila Noor 2021-12-02 16:15:15 -06:00
parent 50d80f2f1c
commit 78e11e0fda
3 changed files with 13 additions and 25 deletions

View file

@ -22,26 +22,14 @@ type AUTH struct {
GroupEndpointURL string
}
// func (c *config) Init(ClientId, ClientSecret, AuthorizeURL, TokenURL, GroupEndpointURL string) {
// c.ClientId = ClientId
// c.ClientSecret = ClientSecret
// c.AuthorizeURL = AuthorizeURL
// c.TokenURL = TokenURL
// c.GroupEndpointURL = GroupEndpointURL
// }
// apiOption is a functional option type for pilosa.API
type authOption func(*AUTH) error
func OptAuth(ClientId, ClientSecret, AuthorizeURL, TokenURL, GroupEndpointURL string) authOption {
return func(a *AUTH) error {
a.ClientId = ClientId
a.ClientSecret = ClientSecret
a.AuthorizeURL = AuthorizeURL
a.TokenURL = TokenURL
a.GroupEndpointURL = GroupEndpointURL
return nil
func NewAuth(ClientId, ClientSecret, AuthorizeURL, TokenURL, GroupEndpointURL string) AUTH {
a := AUTH{
ClientId: ClientId,
ClientSecret: ClientSecret,
AuthorizeURL: AuthorizeURL,
TokenURL: TokenURL,
GroupEndpointURL: GroupEndpointURL,
}
}
// redirectURL
return a
}

View file

@ -415,9 +415,6 @@ func NewConfig() *Config {
// Schema Details Toggle
c.SchemaDetailsOn = true
// AuthZ/AuthN disabled by default
c.Auth.Enable = false
return c
}

View file

@ -56,6 +56,7 @@ import (
"github.com/molecula/featurebase/v2/statsd"
"github.com/molecula/featurebase/v2/syswrap"
"github.com/molecula/featurebase/v2/testhook"
"github.com/molecula/featurebase/v2/vprint"
"github.com/pelletier/go-toml"
"github.com/pkg/errors"
)
@ -237,7 +238,9 @@ func (m *Command) Start() (err error) {
if m.Config.Auth.Enable == true {
m.Config.MustValidateAuth()
auth.OptAuth(m.Config.Auth.ClientId, m.Config.Auth.ClientSecret, m.Config.Auth.AuthorizeURL, m.Config.Auth.TokenURL, m.Config.Auth.GroupEndpointURL)
authArgs := auth.NewAuth(m.Config.Auth.ClientId, m.Config.Auth.ClientSecret, m.Config.Auth.AuthorizeURL, m.Config.Auth.TokenURL, m.Config.Auth.GroupEndpointURL)
vprint.VV("Auth: %v", authArgs)
// print statement is so that binary compiles, and golang doesn't complaint about declared but unused var
}
// Initialize server.