Skip to content
Snippets Groups Projects
Commit 67d8b0fe 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/policy!16
parents f40a22a6 a6f561a9
No related branches found
No related tags found
No related merge requests found
Pipeline #55544 failed with stages
in 3 minutes and 40 seconds
...@@ -62,10 +62,13 @@ func main() { ...@@ -62,10 +62,13 @@ func main() {
httpClient := httpClient() httpClient := httpClient()
// Create an HTTP Client which automatically issues and carries an OAuth2 token. oauthClient := httpClient
// The token will auto-refresh when its expiration is near. if cfg.Auth.Enabled {
oauthCtx := context.WithValue(context.Background(), oauth2.HTTPClient, httpClient) // Create an HTTP Client which automatically issues and carries an OAuth2 token.
oauthClient := newOAuth2Client(oauthCtx, cfg.OAuth.ClientID, cfg.OAuth.ClientSecret, cfg.OAuth.TokenURL) // 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)
}
// create cache client // create cache client
cache := cache.New(cfg.Cache.Addr, cache.WithHTTPClient(oauthClient)) cache := cache.New(cfg.Cache.Addr, cache.WithHTTPClient(oauthClient))
......
...@@ -59,9 +59,9 @@ type ocmConfig struct { ...@@ -59,9 +59,9 @@ type ocmConfig 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"`
} }
type refresherConfig struct { type refresherConfig struct {
...@@ -69,7 +69,7 @@ type refresherConfig struct { ...@@ -69,7 +69,7 @@ type refresherConfig 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"`
} }
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