fix: expand token regex to support newer cfut_ format tokens#129
Open
Toothless5143 wants to merge 3 commits intocaddy-dns:masterfrom
Open
fix: expand token regex to support newer cfut_ format tokens#129Toothless5143 wants to merge 3 commits intocaddy-dns:masterfrom
Toothless5143 wants to merge 3 commits intocaddy-dns:masterfrom
Conversation
Cloudflare's newer API tokens use the cfut_ prefix and are 53 characters long, exceeding the previous 50 character limit in the regex validator. Expanding the upper bound to 100 to accommodate current and future token formats.
Cloudflare's newer API tokens use the cfut_ prefix and are 53 characters long, exceeding the previous 50 character limit. Expanding upper bound to 70 to accommodate current and future token formats.
Cloudflare now issues tokens with cfut_ prefix that are 53 characters, exceeding the previous 50 character limit. Expanding upper bound to 70. Added cfut_ prefixed token to TestValidToken.
|
mine starts with |
Author
Cloudflare seems to use different prefixes depending on the token type. The fix to expand the upper bound to 70 characters should cover both formats since the character set remains the same. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Cloudflare recently changed their API token format. New tokens now use a
cfut_prefix and are 53 characters long, exceeding the previous hard limitof 50 characters in the regex validator:
This causes Caddy to reject perfectly valid tokens with:
Users are forced to either patch the binary themselves or paste the token
directly into the Caddyfile (which is a security risk).
Fix
Expanded the upper bound of
cloudflareTokenRegexpfrom 50 to 70 charactersto accommodate current and future Cloudflare token formats while keeping the
character set validation intact.
Changes
cloudflare.go— updated regex upper bound from 50 to 70cloudflare_test.go— addedcfut_prefixed token toTestValidTokenTesting
Verified working locally with a real
cfut_prefixed token of 53 characterson Caddy v2.11.2.