diff --git a/proxmox/client.go b/proxmox/client.go index 6fb156d8..b26c1940 100644 --- a/proxmox/client.go +++ b/proxmox/client.go @@ -131,6 +131,18 @@ func (c *Client) SetAPIToken(userID, token string) { c.session.SetAPIToken(userID, token) } +// SetTicket let's set directly ticket and csrfPreventionToken obtained in +// a different way, for example using OIDC identity provider +// +// Parameters: +// - `ticket` +// - `csrfPreventionToken` +// +// Docs: https://pve.proxmox.com/wiki/Proxmox_VE_API#Authentication +func (c *Client) SetTicket(ticket, csrfPreventionToken string) { + c.session.setTicket(ticket, csrfPreventionToken) +} + func (c *Client) Login(username string, password string, otp string) (err error) { c.Username = username c.Password = password diff --git a/proxmox/session.go b/proxmox/session.go index 5cf39203..e5667194 100644 --- a/proxmox/session.go +++ b/proxmox/session.go @@ -167,6 +167,11 @@ func (s *Session) SetAPIToken(userID, token string) { s.AuthToken = auth } +func (s *Session) setTicket(ticket, csrfPreventionToken string) { + s.AuthTicket = ticket + s.CsrfToken = csrfPreventionToken +} + func (s *Session) Login(username string, password string, otp string) (err error) { reqUser := map[string]interface{}{"username": username, "password": password} if otp != "" {