added AuthN/AuthZ parameters to featurebase server configuration

This commit is contained in:
Souhaila Noor 2021-11-29 09:40:05 -06:00
parent 42f3b79640
commit 28e1be7540
2 changed files with 32 additions and 0 deletions

View file

@ -121,4 +121,11 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) {
// Toggle /schema/details endpoint.
flags.BoolVar(&srv.Config.SchemaDetailsOn, "schema-details-on", true, "Disable /schema/details endpoint")
// OAuth2.0 identity provider configuration
flags.BoolVar(&srv.Config.Auth.Enable, "auth.enable", false, "Enable AuthN/AuthZ of featurebase, disabled by default.")
flags.StringVar(&srv.Config.Auth.IdentityProviderURL, "auth.identity-provider-url", srv.Config.Auth.IdentityProviderURL, "Base URL for identity provider.")
flags.StringVar(&srv.Config.Auth.AuthorizeURL, "auth.authorize-url", srv.Config.Auth.AuthorizeURL, "Base URL for authorize.")
flags.StringVar(&srv.Config.Auth.UserInfoURL, "auth.user-info-url", srv.Config.Auth.UserInfoURL, "Base URL for user info.")
flags.StringVar(&srv.Config.Auth.ClientId, "auth.client-id", srv.Config.Auth.ClientId, "Application/Client ID")
}

View file

@ -240,6 +240,24 @@ type Config struct {
// Toggles /schema/details endpoint. If off, it returns empty.
SchemaDetailsOn bool `toml:"schema-details-on"`
// Enable AuthZ/AuthN
Auth struct {
// Enable AuthZ/AuthN for featurebase server
Enable bool `toml:"enable"`
// Base URL for identity provider
IdentityProviderURL string `toml:"identity-provider-url"`
// Authorize URL
AuthorizeURL string `toml:"authorize-url"`
// User info URL
UserInfoURL string `toml:"user-info-url"`
// Application/Client ID
ClientId string `toml:"client-id"`
} `toml:"auth"`
}
// Namespace returns the namespace to use based on the Future flag.
@ -392,6 +410,13 @@ func NewConfig() *Config {
// Schema Details Toggle
c.SchemaDetailsOn = true
// AuthZ/AuthN disabled by default
c.Auth.Enable = false
c.Auth.IdentityProviderURL = ""
c.Auth.AuthorizeURL = ""
c.Auth.UserInfoURL = ""
c.Auth.ClientId = ""
return c
}