From f3e444e65a2228262c9b8b408b9b07e139cfe955 Mon Sep 17 00:00:00 2001 From: Nicholas Wiersma Date: Wed, 27 Mar 2024 09:56:32 +0200 Subject: [PATCH] feat: migrate to new auth provider (#21) --- ec/provider/provider.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ec/provider/provider.go b/ec/provider/provider.go index bb62256..5d59273 100644 --- a/ec/provider/provider.go +++ b/ec/provider/provider.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/url" + "sync" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -268,12 +269,12 @@ func resolveTokenURL(m map[string]any) (string, error) { if err != nil { return "", fmt.Errorf("invalid host: %w", err) } - u.Host = "auth-" + u.Host - u.Path = "/auth/realms/enterprise-console/protocol/openid-connect/token" + u.Path = "/auth/token" return u.String(), nil } type lazyTokenSource struct { + mu sync.Mutex ts oauth2.TokenSource newFn func() (oauth2.TokenSource, error) } @@ -283,6 +284,9 @@ func newLazyTokenSource(newFn func() (oauth2.TokenSource, error)) *lazyTokenSour } func (s *lazyTokenSource) Token() (*oauth2.Token, error) { + s.mu.Lock() + defer s.mu.Unlock() + if s.ts == nil { var err error s.ts, err = s.newFn()