mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 19:12:59 +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:
parent
a2f055a916
commit
e87bc4b941
@ -14,6 +14,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||||
|
|
||||||
@ -24,6 +25,8 @@ type ticketAuthenticator struct {
|
|||||||
conn *Connection
|
conn *Connection
|
||||||
authRequest string
|
authRequest string
|
||||||
authData *AuthenticationResponseData
|
authData *AuthenticationResponseData
|
||||||
|
|
||||||
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTicketAuthenticator returns a new ticket authenticator.
|
// 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) {
|
func (t *ticketAuthenticator) authenticate(ctx context.Context) (*AuthenticationResponseData, error) {
|
||||||
|
t.mu.Lock()
|
||||||
|
defer t.mu.Unlock()
|
||||||
|
|
||||||
if t.authData != nil {
|
if t.authData != nil {
|
||||||
return t.authData, nil
|
return t.authData, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user