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

Unable to delete a Tunnel with only API Token set #76

Open
KAllan357 opened this issue Mar 15, 2023 · 1 comment
Open

Unable to delete a Tunnel with only API Token set #76

KAllan357 opened this issue Mar 15, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@KAllan357
Copy link
Contributor

Hi,

Thanks for this tool! I've set it up and created a tunnel, but came across a potential edge case that I wanted to ask about:

INFO    No API token, or performing delete operation
ERROR    Trying to perform Delete request, or any other request with out APIToken, cannot find API Key or Email
github.com/adyanth/cloudflare-operator/controllers.CloudflareAPI.addAuthHeader
    /workspace/controllers/cloudflare_api.go:85
github.com/adyanth/cloudflare-operator/controllers.(*CloudflareAPI).DeleteCloudflareTunnel
    /workspace/controllers/cloudflare_api.go:157

I'm running version v0.10.0 and was wondering why the code was this way for deletes:

https://github.com/adyanth/cloudflare-operator/blob/v0.10.0/controllers/cloudflare_api.go#L157

It seems like Cloudflare's v4 API supports deleting an Argo Tunnel using the standard Bearer Auth - https://developers.cloudflare.com/api/operations/argo-tunnel-delete-an-argo-tunnel

I see this code was added in f59f153 - maybe Cloudflare changed their API since?

I locally tested this via curl and was successful:
t

curl --request DELETE --url https://api.cloudflare.com/client/v4/accounts/xxxx/tunnels/abc123 -H "Authorization: Bearer <API Token>"
{"success":true ... }
@adyanth
Copy link
Owner

adyanth commented Mar 15, 2023

Hey @KAllan357 thanks!

Regarding delete, iirc (it was quite some time ago), the API key does not work. Only the API token along with the email used to work and not the bearer token approach. I guess they have changed it since then. I will have to do that too. Thanks for pointing it out!

Also looks like the ArgoTunnel API is deprecated in favor of Cloudflare Tunnel API. Might as well change that too if they are compatible. Will get in to this probably in a couple of weeks. If you would like to contribute, feel free to do so!

Refs:
https://developers.cloudflare.com/api/operations/cloudflare-tunnel-delete-a-cloudflare-tunnel
https://developers.cloudflare.com/api/operations/argo-tunnel-delete-an-argo-tunnel

@adyanth adyanth added the bug Something isn't working label Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants