0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-06-30 10:33:46 +00:00

fix: prevent authenticating multiple times in parallel (#1168)

Signed-off-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
This commit is contained in:
Leah 2024-03-27 23:27:07 +01:00 committed by GitHub
parent a2f055a916
commit e87bc4b941
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,6 +14,7 @@ import (
"fmt"
"net/http"
"net/url"
"sync"
"github.com/hashicorp/terraform-plugin-log/tflog"
@ -24,6 +25,8 @@ type ticketAuthenticator struct {
conn *Connection
authRequest string
authData *AuthenticationResponseData
mu sync.Mutex
}
// NewTicketAuthenticator returns a new ticket authenticator.
@ -46,6 +49,9 @@ func NewTicketAuthenticator(conn *Connection, creds *Credentials) (Authenticator
}
func (t *ticketAuthenticator) authenticate(ctx context.Context) (*AuthenticationResponseData, error) {
t.mu.Lock()
defer t.mu.Unlock()
if t.authData != nil {
return t.authData, nil
}