mirror of
https://github.com/Telmate/proxmox-api-go.git
synced 2026-04-26 07:55:50 +03:00
[GH-ISSUE #196] Custom HTTP headers for Proxmox API url #40
Labels
No labels
good first issue
issue/confirmed
issue/critical
proposal/accepted
pull-request
type/bug
type/enhancement
type/feature
type/question
type/refactoring
type/testing
type/testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/proxmox-api-go#40
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @forthal on GitHub (Sep 23, 2022).
Original GitHub issue: https://github.com/Telmate/proxmox-api-go/issues/196
I wanted to ask If there can be an option to add custom headers for request to Proxmox API?
I have Proxmox behind Cloudflare Access and for accessing Proxmox I need to add 2 custom headers to request https://developers.cloudflare.com/cloudflare-one/identity/service-tokens/ so then in: https://registry.terraform.io/providers/Telmate/proxmox/latest I could specify those "secrets" in order to access Proxmox hosted in homelab which is behing Cloudflare Access using Terraform Cloud.
Something like this: https://github.com/hashicorp/terraform-provider-nomad/blob/main/nomad/provider.go#L103
Thanks,
@BenediktBertsch commented on GitHub (Oct 3, 2022):
Hey @forthal,
I've created a test branch with the wanted funtionality. Sadly I can not test it myself, so could you try and test it?
https://github.com/BenediktBertsch/proxmox-api-go/tree/add-httpheaders
@mleone87 commented on GitHub (Oct 3, 2022):
There is an option to use a proxy server for requests, for example mitmproxy.
You can then add your headers to mitmproxy https://docs.mitmproxy.org/stable/addons-examples/
@forthal commented on GitHub (Oct 3, 2022):
Hi @BenediktBertsch,
Tried your changes - no success. Headers are present (I've checked
promox-go-apicommand with-debug), but seems like Client/Session is not handling properly Cloudflare (used same token for Nomad and it works in same shell) - getting 401 Unauthorized:./proxmox-api-go -debug start 100Maybe it's related to some redirections that occurs on Cloudflare side? Strange that using Nomad provider it's working like a charm. Using same Service Token I'm able to hit to the login page:
response:
EDIT: ok, it's related to Cloudflare - I'll try to tinker the setup.
Using:
response:
Hi @mleone87,
mitmproxy adds much more complexity - you need to deploy it somewhere (you have no access to Terraform Cloud runner, you could use some "hax" with local provisioners, etc., but to be honest - adding and handling headers is much more simpler) .
@BenediktBertsch commented on GitHub (Oct 3, 2022):
Hey @forthal,
just read your good debug, whats about this:
Is it just a debugging thing that the f in CF is lowercase? I think its important to be uppercase.
@forthal commented on GitHub (Oct 3, 2022):
Hi @BenediktBertsch,
I think "debug" mode is lowercasing this. I've double checked I'm using proper headers:
export HTTP_HEADERS="CF-Access-Client-Id,***,CF-Access-Client-Secret,***"EDIT:
I think I found the culprit: https://pkg.go.dev/net/http#Header.Add:
@BenediktBertsch commented on GitHub (Oct 3, 2022):
Hey @forthal,
pushed a fix for the case-sensitivity for headers. Pls check it out and test it once again.
@forthal commented on GitHub (Oct 3, 2022):
Hi @BenediktBertsch,
I've applied same fix locally, but having:
after building and running.
Setting up a debugger would help a lot :D
EDIT: I think I've solved it. Check out PR created to your fork.