Allow using API tokens for Proxmox authentication#10797
Allow using API tokens for Proxmox authentication#10797sylviamoss merged 8 commits intohashicorp:masterfrom
Conversation
Codecov Report
|
|
Upstream PR is open, let's see which one wins: Telmate/proxmox-api-go#108 |
|
now using the method from the client lib |
| type authenticatedTransport struct { | ||
| rt http.RoundTripper | ||
| user string | ||
| token string | ||
| } | ||
|
|
||
| func newAuthenticatedTransport(rt http.RoundTripper, user, token string) *authenticatedTransport { | ||
| return &authenticatedTransport{rt, user, token} | ||
| } | ||
|
|
||
| func (t *authenticatedTransport) RoundTrip(req *http.Request) (*http.Response, error) { | ||
| auth := fmt.Sprintf("PVEAPIToken=%s=%s", t.user, t.token) | ||
| req.Header.Set("Authorization", auth) | ||
| return t.rt.RoundTrip(req) | ||
| } |
There was a problem hiding this comment.
There's a linter failure because these are unused. I suppose they are from before moving the bits upstream?
| return t.rt.RoundTrip(req) | ||
| } | ||
|
|
||
| func NewProxmoxClient(config Config) (*proxmox.Client, error) { |
There was a problem hiding this comment.
Nit: This strictly doesn't need to be exported, right?
sylviamoss
left a comment
There was a problem hiding this comment.
Nice! I'll merge it once @carlpett's comments are addressed.
|
is there something that will let me know once this lands in a stable release? |
|
Hey 👋 @mraerino, there is no automatic notification. This feature will be available for use in our next nightly release which is a glimpse of what you can expect in the next v1.7.1 release which is set to go out next week. As far as notifications go we announce Packer releases to the Packer email distribution list. You can also subscribe to the GitHub RSS feeds so that you can see when new releases drop https://github.com/hashicorp/packer/releases.atom Thanks again for making this change. |
|
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Proxmox allows people to create API tokens with limited privileges that can be rotated without deleting a user account. It is usually useful for giving automated systems specific access to parts of the Proxmox API, e.g. a single VM resource pool.
The current authentication flow used for the Proxmox client is not compatible though:
Instead the required auth flow for API tokens is described here:
This PR introduces a new parameter
tokenfor the Proxmox builder which allows using the alternative API token flow.It will take precedence over
passwordif both are given.Tests are provided, docs have been updated.
I tested a development build with a proxmox setup locally.