Repository navigation
feat(cms): sign in through Cloudflare Access with a GitHub App proxy - #20
Merged
Merged
Conversation
Sveltia's GitHub calls go to a same-origin Pages Function that verifies the Access JWT (RS256, kid, aud, iss, exp, nbf, owner email) and forwards an allow-list of paths, writes and GraphQL mutations with a GitHub App installation token held in memory. No DELETE, no merges, commits only on cms/ branches. The sign-in popup (auth.html) completes Sveltia's handshake with a placeholder token, so no GitHub credential reaches the browser. Missing settings fail closed with 503. Claude-Session: https://claude.ai/code/session_01426xQEC2VhQSZVe7cBXuz5
Deploying blog with
|
| Latest commit: |
f826aed
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5dbc4ff1.blog-7qk.pages.dev |
| Branch Preview URL: | https://feat-cms-access-auth.blog-7qk.pages.dev |
Reject %2E and %5C as well as %2F in proxied paths, build the upstream URL by concatenation onto the fixed api.github.com origin, stop passing GitHub's Link header (its /repositories/<id>/ links 404 behind the proxy), and redirect /gh/comdotlinux/blog/... (Sveltia's "View on GitHub" links) to github.com. Tests for each path and write rule, query forwarding and the User-Agent on every upstream call. README: Publish is refused, reload after the 24 h Access session, keep the key until the live check passes. Claude-Session: https://claude.ai/code/session_01426xQEC2VhQSZVe7cBXuz5
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.
Do not merge until the GitHub App exists and the four Production settings are in the
blog-cmsPages project (cms/README.md, "One-time setup"). Without them every/gh/call answers 503 and the editor cannot load posts.What
cms/functions/gh/[[path]].ts: Pages Function on/gh/*, the only path from Sveltia to GitHub.Sec-Fetch-Site, elseOrigin).Cf-Access-Jwt-Assertionor theCF_Authorizationcookie: RS256 only, key bykidfrom the team certs (5 min cache, refetch on unknownkidat most every 30 s),aud,iss,exp,nbf(60 s skew),emailequal toOWNER_EMAIL...,., empty segments, encoded slashes, double encoding, control chars; allows only/user,/repos/comdotlinux/blog/**,/graphql.DELETE, no PR merge, ref PATCH only underheads/cms/. GraphQL: root mutations limited tocreateCommitOnBranch(branchcms/only),createRef(refs/heads/cms/only),convertPullRequestToDraft,markPullRequestReadyForReview,disablePullRequestAutoMerge; fragment spreads, directives and inline arguments at the mutation root are refused; the parsed body is what gets forwarded.Cf-*or the incomingAuthorization; responses carryCache-Control: no-store. Logs fixed text and status codes only.GET /userfrom the publiccomdotlinuxprofile;permissions.pushadded to the repo response (installation tokens get neither).GITHUB_APP_ID,GITHUB_APP_INSTALLATION_ID,GITHUB_APP_PRIVATE_KEY(PKCS#8),OWNER_EMAIL: 503 "CMS GitHub App not configured".cms/public/auth.html: static popup answering Sveltia's handshake with the placeholder tokencf-access;postMessageonly tolocation.origin.cms/public/admin/config.yml:base_url,auth_endpoint: auth,api_root(proxy),auth_methods: [oauth].cms/test/unit/config.test.tsbackend assertion extended for these keys (owner-approved edit).access-jwt.test.ts,gh-proxy.test.ts,auth-page.test.ts(generated RSA keys, fake JWKS, mocked GitHub), e2eauth.spec.ts(real Sveltia from the CDN, stubbed/gh/: the/usercall carriestoken cf-access, no request goes toapi.github.com, no access-token field).cms/README.md(how sign-in works, owner setup steps),cms/AGENTS.md, rootCLAUDE.md.Checks
Root gate: lint 0 errors, build 27 pages, unit 75, e2e 96, Lighthouse 99.6% avg. CMS: format clean, unit 159, integration 2, e2e 2. Local
wrangler pages devon a copy ofcms/: Functions compile; 503 without settings, 401 without or with a forged JWT, 403 cross-site.Not verified (needs the App and a deploy)
cms/functionswith rootcms, no build command,SKIP_DEPENDENCY_INSTALL=1./gh/*requests./userand repopermissions(shims assume the documented 403 and missing field).https://claude.ai/code/session_01426xQEC2VhQSZVe7cBXuz5