From 2a317c68918096e89b2480fc761fd4e0521a7b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Thu, 17 Oct 2024 16:16:30 +0200 Subject: [PATCH] Use ReadAuthSettings instead --- pkg/infinity/client.go | 6 +----- pkg/infinity/oauth.go | 10 +++------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/pkg/infinity/client.go b/pkg/infinity/client.go index 29da0f5c..a8f94e42 100644 --- a/pkg/infinity/client.go +++ b/pkg/infinity/client.go @@ -108,11 +108,7 @@ func NewClient(ctx context.Context, settings models.InfinitySettings) (client *C httpClient = ApplyDigestAuth(ctx, httpClient, settings) httpClient = ApplyOAuthClientCredentials(ctx, httpClient, settings) httpClient = ApplyOAuthJWT(ctx, httpClient, settings) - httpClient, err = ApplyAWSAuth(ctx, httpClient, settings) - if err != nil { - logger.Error("error applying aws auth", "datasource uid", settings.UID, "datasource name", settings.Name) - return client, err - } + httpClient = ApplyAWSAuth(ctx, httpClient, settings) httpClient, err = ApplySecureSocksProxyConfiguration(ctx, httpClient, settings) if err != nil { diff --git a/pkg/infinity/oauth.go b/pkg/infinity/oauth.go index 9f133a1f..27d51b0b 100644 --- a/pkg/infinity/oauth.go +++ b/pkg/infinity/oauth.go @@ -2,7 +2,6 @@ package infinity import ( "context" - "errors" "net/http" "net/url" "strings" @@ -89,7 +88,7 @@ func ApplyDigestAuth(ctx context.Context, httpClient *http.Client, settings mode func IsDigestAuthConfigured(settings models.InfinitySettings) bool { return settings.AuthenticationMethod == models.AuthenticationMethodDigestAuth } -func ApplyAWSAuth(ctx context.Context, httpClient *http.Client, settings models.InfinitySettings) (*http.Client, error) { +func ApplyAWSAuth(ctx context.Context, httpClient *http.Client, settings models.InfinitySettings) *http.Client { ctx, span := tracing.DefaultTracer().Start(ctx, "ApplyAWSAuth") defer span.End() if IsAwsAuthConfigured(settings) { @@ -113,18 +112,15 @@ func ApplyAWSAuth(ctx context.Context, httpClient *http.Client, settings models. AccessKey: settings.AWSAccessKey, SecretKey: settings.AWSSecretKey, } - authSettings, found := awsds.ReadAuthSettingsFromContext(ctx) - if !found { - return nil, errors.New("AWS auth settings not found in context") - } + authSettings := awsds.ReadAuthSettings(ctx) rt, _ := sigv4.New(conf, *authSettings, sigv4.RoundTripperFunc(func(req *http.Request) (*http.Response, error) { req.Header.Add("Accept", "application/json") return tempHttpClient.Do(req) })) httpClient.Transport = rt } - return httpClient, nil + return httpClient } func IsAwsAuthConfigured(settings models.InfinitySettings) bool {