Skip to content
Snippets Groups Projects
Commit 4588a283 authored by Yordan Kinkov's avatar Yordan Kinkov
Browse files

Make oauth client not required by default

parent 538ab623
Branches
Tags
No related merge requests found
......@@ -80,10 +80,13 @@ func main() {
httpClient := httpClient()
// Create an HTTP Client which uses an authentication token.
// The token will auto-refresh as necessary.
oauthCtx := context.WithValue(context.Background(), oauth2.HTTPClient, httpClient)
oauthClient := newOAuth2Client(oauthCtx, cfg.OAuth.ClientID, cfg.OAuth.ClientSecret, cfg.OAuth.TokenURL)
oauthClient := httpClient
if cfg.Auth.Enabled {
// Create an HTTP Client which automatically issues and carries an OAuth2 token.
// The token will auto-refresh when its expiration is near.
oauthCtx := context.WithValue(context.Background(), oauth2.HTTPClient, httpClient)
oauthClient = newOAuth2Client(oauthCtx, cfg.OAuth.ClientID, cfg.OAuth.ClientSecret, cfg.OAuth.TokenURL)
}
credentials := credential.New(cfg.Credential.IssuerURI, httpClient)
......
......@@ -53,13 +53,13 @@ type metricsConfig struct {
}
type oauthConfig struct {
ClientID string `envconfig:"OAUTH_CLIENT_ID" required:"true"`
ClientSecret string `envconfig:"OAUTH_CLIENT_SECRET" required:"true"`
TokenURL string `envconfig:"OAUTH_TOKEN_URL" required:"true"`
ClientID string `envconfig:"OAUTH_CLIENT_ID"`
ClientSecret string `envconfig:"OAUTH_CLIENT_SECRET"`
TokenURL string `envconfig:"OAUTH_TOKEN_URL"`
}
type authConfig struct {
Enabled bool `envconfig:"AUTH_ENABLED" default:"true"`
Enabled bool `envconfig:"AUTH_ENABLED" default:"false"`
JwkURL string `envconfig:"AUTH_JWK_URL"`
RefreshInterval time.Duration `envconfig:"AUTH_REFRESH_INTERVAL" default:"1h"`
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment