Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: client intialized with ticket and CSRF prevention Token #373

Merged
merged 3 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions proxmox/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ func (c *Client) SetAPIToken(userID, token string) {
c.session.SetAPIToken(userID, token)
}

func (c *Client) SetTicket(ticket, csrfPreventionToken string) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment to this?
Just a notice that it is different from the normal login/api authentication methods and what it is used for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

c.session.SetTicket(ticket, csrfPreventionToken)
}

func (c *Client) Login(username string, password string, otp string) (err error) {
c.Username = username
c.Password = password
Expand Down
5 changes: 5 additions & 0 deletions proxmox/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ func (s *Session) SetAPIToken(userID, token string) {
s.AuthToken = auth
}

func (s *Session) SetTicket(ticket, csrfPreventionToken string) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this private so setTicket? Nothing in Session should be exposed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (Session)setTicket made private

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 != "" {
Expand Down
Loading