Skip to content

Accept Cloudflare cfut_/cfat_ API tokens#123

Merged
mholt merged 1 commit intocaddy-dns:masterfrom
ogerman:master
Mar 23, 2026
Merged

Accept Cloudflare cfut_/cfat_ API tokens#123
mholt merged 1 commit intocaddy-dns:masterfrom
ogerman:master

Conversation

@ogerman
Copy link
Copy Markdown
Contributor

@ogerman ogerman commented Mar 18, 2026

Cloudflare introduced new token formats (user cfut_…, account cfat_…) alongside the existing legacy tokens. This PR extends provisioning validation so those shapes are accepted

@tjhorner
Copy link
Copy Markdown

tjhorner commented Mar 19, 2026

It seems unlikely the token format will change again in the future, but to prevent this from happening again I feel like this sort of validation should produce a warning instead of failing entirely. Or, instead of strictly matching against the token format, simply check for the common mistakes mentioned in the log message:

return fmt.Errorf("API token '%s' appears invalid; ensure it's correctly entered and not wrapped in braces nor quotes", p.Provider.APIToken)

@ItzDabbzz
Copy link
Copy Markdown

This is currently blocking me from setting up a Caddy instance with the Cloudflare DNS provider, as the only token's I can generate are the new ones so far that i know of, Whats the status on this being merged?

@jharris1829
Copy link
Copy Markdown

jharris1829 commented Mar 19, 2026

It seems unlikely the token format will change again in the future, but to prevent this from happening again I feel like this sort of validation should produce a warning instead of failing entirely. Or, instead of strictly matching against the token format, simply check for the common mistakes mentioned in the log message:

I like this as well. In the end if it is an invalid token then it will fail when trying to authenticate and a warning will provide the feedback necessary to double check the format. Unless I am missing something I'm not sure a process-killing error just based on length is necessary.

mtane0412 added a commit to kasseika/idobata that referenced this pull request Mar 19, 2026
caddy-dns/cloudflareプラグインがcfut_プレフィックスのトークンを
不正と判断するバグを修正するため、PR #123のコミットを指定してビルドする

参考: caddy-dns/cloudflare#123

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mtane0412 added a commit to kasseika/idobata that referenced this pull request Mar 19, 2026
* fix: cfut_プレフィックスのCloudflare APIトークンに対応

caddy-dns/cloudflareプラグインがcfut_プレフィックスのトークンを
不正と判断するバグを修正するため、PR #123のコミットを指定してビルドする

参考: caddy-dns/cloudflare#123

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix: Dockerfile.caddy にARGを追加しコミットSHAの出典を明記

- ARG CLOUDFLARE_DNS_CLOUDFLARE_REF でコミットSHAを変数化
- コメントで出典(公式リポジトリの未マージPR digitaldemocracy2030#123)・内容・暫定理由を明記
- コミットSHA自体は公式リポジトリでHTTP 200確認済み

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@will528
Copy link
Copy Markdown

will528 commented Mar 19, 2026

@ItzDabbzz I'm using this in the meantime while I wait for this to be merged. Hope it helps you too.

xcaddy build \
   --with github.com/caddy-dns/cloudflare=github.com/ogerman/cloudflare@master

@jph00
Copy link
Copy Markdown

jph00 commented Mar 21, 2026

@mholt thought you might want to know about this one - currently all new Cloudflare tokens are failing with caddy due to the new format. Fix in this PR is just a simple update to the format check. We've tested it and it seems to be working fine.

@sweetgiorni
Copy link
Copy Markdown

In the end if it is an invalid token then it will fail when trying to authenticate and a warning will provide the feedback necessary to double check the format

+1 +1 +1

Maybe don't validate formats you don't own?

@emielmolenaar
Copy link
Copy Markdown

In the end if it is an invalid token then it will fail when trying to authenticate and a warning will provide the feedback necessary to double check the format

+1 +1 +1

Maybe don't validate formats you don't own?

I agree with you, but it’s possible this was designed with security in mind. Since these tokens originate from userland, blindly passing arbitrary strings through the code could introduce vulnerabilities.

@mholt
Copy link
Copy Markdown
Contributor

mholt commented Mar 23, 2026

Thanks for the ping. Did Cloudflare just break every API client out there?? Any link to the change?

@mholt
Copy link
Copy Markdown
Contributor

mholt commented Mar 23, 2026

We could just remove the validation if they can just change it instantly like that and break everything.

The validation was deemed necessary after too many people had erroneous configs where their tokens weren't being set properly in the environment or whatever else, because Cloudflare's error messages were so bad, I think even misleading IIRC.

The validation made it obvious and "proved" that it wasn't a problem with this code, it was something on their end, and was to compensate for Cloudflare's terrible error messages.

But again, if it's going to break people, and Cloudflare is just going to change formats out of the blue, we can just remove the validation and leave users on their own.

@emielmolenaar
Copy link
Copy Markdown

Thanks for the ping. Did Cloudflare just break every API client out there?? Any link to the change?

I can not find any news / blog post from Cloudflare regarding the new format. I have generated some keys in the past couple of months and started noticing this change since last week. At first I thought I made a mistake because the keys were prefixed "cfat_". But as we've all seen these are actually keys in a new format.

@ItzDabbzz
Copy link
Copy Markdown

ItzDabbzz commented Mar 23, 2026

Thanks for the ping. Did Cloudflare just break every API client out there?? Any link to the change?

I found 0 news about the change, Although I did notice that their docs for the create-token page was last updated at Feb 9, 2026. Although from the looks of it, they are preparing to deprecate Global API Key's & Origin CA Key's and transfer to Account API Tokens as the preferred method. As their docs recently added the legacy and deprecated tags next to the titles in the sidebar. CA-Keys was updated recently Mar 19, 2026

Copy link
Copy Markdown
Contributor

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Thanks; let's go with this for now. But I might want to remove the validation in the near future knowing that Cloudflare may change this at any time without warning. It will leave users hanging, though, unless Cloudflare fixes their error messages.

@mholt mholt merged commit a8737d0 into caddy-dns:master Mar 23, 2026
2 checks passed
@SteppingHat
Copy link
Copy Markdown

Thanks; let's go with this for now. But I might want to remove the validation in the near future knowing that Cloudflare may change this at any time without warning. It will leave users hanging, though, unless Cloudflare fixes their error messages.

@mholt Perhaps we can present a warning as a middle ground? That way users aren't left hanging, but it also won't cause things to break if the format changes.

@mholt
Copy link
Copy Markdown
Contributor

mholt commented Mar 30, 2026

We could try a warning, but my worry is that the eventual error from Cloudflare will overshadow the warning earlier in the logs. But you're right, it could be a good middle ground. (And the point of warnings is to warn you of future errors.)

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

Successfully merging this pull request may close these issues.

10 participants