Authenticate the identity GitHub reads with an optional read token - #92
Merged
Merged
Conversation
Anonymous api.github.com calls leave Cloudflare's shared worker egress addresses whose per-IP quota is persistently exhausted, breaking every new enrollment with 503 upstream_unavailable. An optional GITHUB_READ_TOKEN secret (read-only) gives the worker its own quota; a rejected or absent token degrades to exactly one anonymous retry after a short pause instead of failing enrollment closed. 404 proof handling and all size/redirect guards are unchanged.
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.
What this changes
Fixes the production identity-enrollment outage found tonight:
POST /api/v1/identitiesanswered503 upstream_unavailableacross four clean challenge/gist cycles over ~50 minutes. Root cause:githubJson()calledapi.github.comanonymously, and anonymous calls leave Cloudflare's shared worker egress addresses whose per-IP quota (60/h) is persistently exhausted by other tenants.identity.mjs: an optionalGITHUB_READ_TOKENsecret authenticates the two fixed public reads (gist + user), giving the worker its own quota. A rejected (401/403/429) or absent token degrades to exactly one anonymous retry after a short pause — never a wider request and never a silent failure of enrollment.wrangler.example.tomldocuments the optional secret; two new tests cover token-auth + degradation and the anonymous fail-closed path (suite 85 → 87).Deployment note
No schema or module-list changes (
identity.mjsis already pinned). After merge: standard promotion chain; then the operator sets theGITHUB_READ_TOKENsecret on the live worker (read-only PAT recommended; the current stopgap may be replaced anytime without code changes — an invalid token simply degrades to the anonymous path).Verification
Full commons suite 87/87 in node:24; agent-data self-tests 84 rejected.