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

Merge branch 'oauth-client-is-not-required-by-default' into 'main'

Make oauth client not required by default

See merge request gaia-x/data-infrastructure-federation-services/tsa/task!3
parents a339809d a2ce8897
No related branches found
No related merge requests found
Pipeline #55546 failed with stages
in 2 minutes and 12 seconds
...@@ -77,11 +77,13 @@ func main() { ...@@ -77,11 +77,13 @@ func main() {
httpClient := httpClient() httpClient := httpClient()
// create an HTTP Client which uses an authentication token oauthClient := httpClient
// Create an HTTP Client which uses an authentication token. if cfg.Auth.Enabled {
// The token will auto-refresh as necessary. // Create an HTTP Client which automatically issues and carries an OAuth2 token.
oauthCtx := context.WithValue(context.Background(), oauth2.HTTPClient, httpClient) // The token will auto-refresh when its expiration is near.
oauthClient := newOAuth2Client(oauthCtx, cfg.OAuth.ClientID, cfg.OAuth.ClientSecret, cfg.OAuth.TokenURL) oauthCtx := context.WithValue(context.Background(), oauth2.HTTPClient, httpClient)
oauthClient = newOAuth2Client(oauthCtx, cfg.OAuth.ClientID, cfg.OAuth.ClientSecret, cfg.OAuth.TokenURL)
}
// create policy client // create policy client
policy := policy.New(cfg.Policy.Addr, oauthClient) policy := policy.New(cfg.Policy.Addr, oauthClient)
......
...@@ -25,7 +25,7 @@ type httpConfig struct { ...@@ -25,7 +25,7 @@ type httpConfig struct {
} }
type authConfig struct { type authConfig struct {
Enabled bool `envconfig:"AUTH_ENABLED" default:"true"` Enabled bool `envconfig:"AUTH_ENABLED" default:"false"`
JwkURL string `envconfig:"AUTH_JWK_URL"` JwkURL string `envconfig:"AUTH_JWK_URL"`
RefreshInterval time.Duration `envconfig:"AUTH_REFRESH_INTERVAL" default:"1h"` RefreshInterval time.Duration `envconfig:"AUTH_REFRESH_INTERVAL" default:"1h"`
} }
...@@ -60,7 +60,7 @@ type metricsConfig struct { ...@@ -60,7 +60,7 @@ type metricsConfig struct {
} }
type oauthConfig struct { type oauthConfig struct {
ClientID string `envconfig:"OAUTH_CLIENT_ID" required:"true"` ClientID string `envconfig:"OAUTH_CLIENT_ID"`
ClientSecret string `envconfig:"OAUTH_CLIENT_SECRET" required:"true"` ClientSecret string `envconfig:"OAUTH_CLIENT_SECRET"`
TokenURL string `envconfig:"OAUTH_TOKEN_URL" required:"true"` TokenURL string `envconfig:"OAUTH_TOKEN_URL"`
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment