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

Add support for CloudFlare API Tokens (Authorization: Bearer) #1127

Closed
ilyasotkov opened this issue Aug 2, 2019 · 12 comments
Closed

Add support for CloudFlare API Tokens (Authorization: Bearer) #1127

ilyasotkov opened this issue Aug 2, 2019 · 12 comments

Comments

@ilyasotkov
Copy link

API Tokens use the standard Authorization: Bearer header for authentication instead of x-auth-email and x-auth-key that API Keys use.

API tokens would allow granting external-dns access to only a specific DNS zone and not the whole CloudFlare account 🔒

@zackijack
Copy link

Hi @Evesy thanks for adding support for API token. But for now, the API token must be granted for all zone, cannot only to a specific zone.
when you generate token for specific zone, you will get this error:
level=error msg="error from makeRequest: HTTP status 403: insufficient permissions".

dmizelle pushed a commit to dmizelle/external-dns that referenced this issue Dec 3, 2019
Additionally:
* add a .dockerignore so we don't copy .git and docs to the
  container (gotta go fast)
* Change Dockerfile{,.mini} to not run `go mod` every time a file is
  changed.

This commit _should_ fix kubernetes-sigs#1127. While users in the past were able to
define ZoneIDFilter for this provider, it did not actually do anything
under the hood.

In this case, we're changing Zones() to iterate over the provided
zoneIDs and return only those zones.

I would have also done this for domainFilter, but unfortunately the
CloudFlare API requires that in order to list zones (and find them by
name) that you have "all" permissions, which seems silly. After talking
to their support, this is probably the best way to do this.
dmizelle pushed a commit to dmizelle/external-dns that referenced this issue Dec 3, 2019
Additionally:
* add a .dockerignore so we don't copy .git and docs to the
  container (gotta go fast)
* Change Dockerfile{,.mini} to not run `go mod` every time a file is
  changed.

This commit _should_ help kubernetes-sigs#1127. While users in the past were able to
define ZoneIDFilter for this provider, it did not actually do anything
under the hood.

In this case, we're changing Zones() to iterate over the provided
zoneIDs and return only those zones.

I would have also done this for domainFilter, but unfortunately the
CloudFlare API requires that in order to list zones (and find them by
name) that you have "all" permissions, which seems silly. After talking
to their support, this is probably the best way to do this.
@rofra
Copy link

rofra commented Dec 13, 2019

I do confirm the assumption of @zackijack, il only works when the token has granted permissions for all zones

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 12, 2020
@onedr0p
Copy link
Contributor

onedr0p commented Mar 12, 2020

/remove-lifecycle stale

1 similar comment
@simplyzee
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 1, 2020
@simplyzee
Copy link

Do we have an update on this? I'm also seeing this with Cloudflare API tokens.

level=error msg="error from makeRequest: HTTP status 403: insufficient permissions"

I don't necessarily want to generate wider permissions to see a zone specifically if I can help that.

@iMartyn
Copy link

iMartyn commented Apr 7, 2020

This appears to have regressed further, in that even with a token with zone.DNS.Edit permissions on all zones, you still get the above error. Seen as it's probably wise to rollback to 0.5.17 because of #1463 anyway, I'm going to wait until both of these are fixed before upgrading to something more recent than that.

james-callahan pushed a commit to james-callahan/external-dns that referenced this issue Apr 8, 2020
This commit _should_ help kubernetes-sigs#1127. While users in the past were able to
define ZoneIDFilter for this provider, it did not actually do anything
under the hood.

In this case, we're changing Zones() to iterate over the provided
zoneIDs and return only those zones.

I would have also done this for domainFilter, but unfortunately the
CloudFlare API requires that in order to list zones (and find them by
name) that you have "all" permissions, which seems silly. After talking
to their support, this is probably the best way to do this.

Signed-off-by: James Callahan <jamescallahan@bitgo.com>
james-callahan pushed a commit to james-callahan/external-dns that referenced this issue Apr 8, 2020
This commit _should_ help kubernetes-sigs#1127. While users in the past were able to
define ZoneIDFilter for this provider, it did not actually do anything
under the hood.

In this case, we're changing Zones() to iterate over the provided
zoneIDs and return only those zones.

I would have also done this for domainFilter, but unfortunately the
CloudFlare API requires that in order to list zones (and find them by
name) that you have "all" permissions, which seems silly. After talking
to their support, this is probably the best way to do this.

Signed-off-by: James Callahan <jamescallahan@bitgo.com>
@tapanhalani
Copy link

I am facing this issue currently with both latest and v0.5.17 docker images. My cloudflare token has zone:read and DNS:edit permissions for a particular zone in my client's account. Any updates on this issue will be really helpful, as we are depending on this setup for a multi-ingress setup.

@alexnauda
Copy link

Also ran into this issue. Is anyone actively working on this?

james-callahan added a commit to james-callahan/external-dns that referenced this issue May 21, 2020
This commit _should_ help kubernetes-sigs#1127. While users in the past were able to
define ZoneIDFilter for this provider, it did not actually do anything
under the hood.

In this case, we're changing Zones() to iterate over the provided
zoneIDs and return only those zones.

I would have also done this for domainFilter, but unfortunately the
CloudFlare API requires that in order to list zones (and find them by
name) that you have "all" permissions, which seems silly. After talking
to their support, this is probably the best way to do this.

Signed-off-by: James Callahan <jamescallahan@bitgo.com>
james-callahan pushed a commit to james-callahan/external-dns that referenced this issue May 21, 2020
This commit _should_ help kubernetes-sigs#1127. While users in the past were able to
define ZoneIDFilter for this provider, it did not actually do anything
under the hood.

In this case, we're changing Zones() to iterate over the provided
zoneIDs and return only those zones.

I would have also done this for domainFilter, but unfortunately the
CloudFlare API requires that in order to list zones (and find them by
name) that you have "all" permissions, which seems silly. After talking
to their support, this is probably the best way to do this.

Signed-off-by: James Callahan <jamescallahan@bitgo.com>
james-callahan pushed a commit to james-callahan/external-dns that referenced this issue May 21, 2020
This commit _should_ help kubernetes-sigs#1127. While users in the past were able to
define ZoneIDFilter for this provider, it did not actually do anything
under the hood.

In this case, we're changing Zones() to iterate over the provided
zoneIDs and return only those zones.

I would have also done this for domainFilter, but unfortunately the
CloudFlare API requires that in order to list zones (and find them by
name) that you have "all" permissions, which seems silly. After talking
to their support, this is probably the best way to do this.

Signed-off-by: James Callahan <jamescallahan@bitgo.com>
james-callahan pushed a commit to james-callahan/external-dns that referenced this issue May 21, 2020
This commit _should_ help kubernetes-sigs#1127. While users in the past were able to
define ZoneIDFilter for this provider, it did not actually do anything
under the hood.

In this case, we're changing Zones() to iterate over the provided
zoneIDs and return only those zones.

I would have also done this for domainFilter, but unfortunately the
CloudFlare API requires that in order to list zones (and find them by
name) that you have "all" permissions, which seems silly. After talking
to their support, this is probably the best way to do this.

Signed-off-by: James Callahan <jamescallahan@bitgo.com>
@sheerun
Copy link
Contributor

sheerun commented Jun 4, 2020

This should be implemented and fixed as of 0.7.2

To use api token you can write:

cloudflare:
  apiToken: "xxx"

To synchronize just single zone you can use:

zoneIdFilters:
  - asdfas

If someone has other issues or ideas, please open another issue

/close

@k8s-ci-robot
Copy link
Contributor

@sheerun: Closing this issue.

In response to this:

This should be implemented and fixed as of 0.7.2

To use api token you can write:

cloudflare:
 apiToken: "xxx"

To synchronize just single zone you can use:

zoneIdFilters:
 - asdfas

If someone has other issues or ideas, please open another issue

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@malarinv
Copy link

malarinv commented Sep 20, 2021

This appears to have regressed further, in that even with a token with zone.DNS.Edit permissions on all zones, you still get the above error. Seen as it's probably wise to rollback to 0.5.17 because of #1463 anyway, I'm going to wait until both of these are fixed before upgrading to something more recent than that.

This issue seems to be present even on v0.9.0 , had tested it on v0.7.2(from the tutorial) and v0.7.6 , happens on all the cases. my token permission looks like
cloudflare-token-permission

curl -X GET "https://api.cloudflare.com/client/v4/user/tokens/verify" \
    -H "Authorization: Bearer $CF_API_TOKEN" \
    -H "Content-Type:application/json"
{"result":{"id":"xxxxxxx","status":"active","not_before":"2021-09-ddT00:00:00Z","expires_on":"2021-10-ddT23:59:59Z"},"success":true,"errors":[],"messages":[{"code":10000,"message":"This API Token is valid and active","type":null}]}

is it working for anyone else?

[EDIT]
Nevermind it seems to be unsupported by cloudflare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests