Repository navigation
Conversation
Pulumi PreviewClick to expand preview output |
|
@dsp-ant this is ready for review. Three things need you, all in the Setup → @dsp-ant section of the description:
Sign-in starts as a pilot for me only ( The PR can merge before any of this; the deploy job skips until the secrets exist. Generated by Claude Code |
Automated review (Claude-generated)
Severity key: 🔴 High · 🟠 Medium · 🟡 Low · ⚪ Nit 🔴 High1. 2. Identity is trust-on-first-use of a mutable GitHub login — 🟠 Medium3. GitHub error callback causes a redirect loop — 4. OAuth 5. Key-rotation procedure can break verification for up to the JWKS cache TTL — 6. Deploy gate doesn't require the GitHub client secret — 7. Test fixtures are derived from live 🟡 Low8. 9. Eligibility predicate is re-implemented instead of shared — 10. 11. 12. ⚪ Nit13. Hand-rolled base64url — 14. Generated by Claude Code |
|
@dsp-ant thanks for the review. All 14 items are addressed in bf5bde6, and 72b7dcf simplifies the result:
Worker: 23 tests and typecheck pass. Repo: format, config validation and 79 tests pass. Generated by Claude Code |
|
Ready for review. The review fixes are in, and the access-site, repository CI, and Pulumi preview checks all passed. I also backfilled the numeric GitHub IDs for all 139 configured usernames in The Workspace SSO pilot is still limited to |
|
Thanks for working through the review. The overall design looks good to me. Three things we should fix before merging: 1. Sign-in fails in the Workers runtime (
2. The pilot allowlist fails open ( 3. Merge conflict in Two notes on CI. The The rest can be follow-ups, but verifying the backfilled GitHub IDs has to happen before we widen the pilot beyond you. Generated by Claude Code |
dce9ae3 to
aa706d7
Compare
0a9a350 to
9ba46ca
Compare
| * closed to UNMAPPED_NAME_ID. Literals are JSON-encoded, so config can't inject JSONata. | ||
| */ | ||
| export function buildNameIdTransform(table: Record<string, string>, githubIdpId: string): string { | ||
| return `( |
There was a problem hiding this comment.
The description says an engine difference fails closed. The expression does, but Cloudflare doesn't document what it sends when a transform errors or returns nothing, and the default NameID is the user's email. If it falls back to that, the allowlist is skipped for any org member whose GitHub email is on our domain.
Before the Google profile is assigned, can you capture the SAML response for an unlisted org member and confirm the NameID is unmapped@access.invalid, then do the same with a deliberately broken transform on a throwaway app? Narrowing the Access policy from the whole org to a dedicated team would also limit the damage if it does fall back.
Generated by Claude Code
There was a problem hiding this comment.
Both checks use a throwaway app, so they don't need this merged, and this thread has to be resolved before merge anyway. Can you run them first and post the results here? While the app is up:
- Use the exact expression from
buildNameIdTransform. - Save the app once in the dashboard, then read it back through the API to confirm the transform survives.
- If an error or empty result falls back to the email, try
nameIdFormat: 'id'and check that a mapped user still gets theemailAddressformat. - Keep Google's SP values off the throwaway app, and delete it afterwards.
Generated by Claude Code
There was a problem hiding this comment.
Ran both checks, plus the follow-ups from your second comment, on a throwaway SaaS app in the MCP account. It used the same settings as src/cloudflare.ts: GitHub IdP only, allowAuthenticateViaWarp: false, 1h, nameIdFormat: 'email', samlAttributeTransformJsonata: '{}', and the exact buildNameIdTransform output. Google's SP values were never set; the ACS was a local listener (http://localhost:8765/acs). The app has been deleted. Identifiers below are redacted (<…>), and signatures and certificates are trimmed.
Found a bug, now fixed in ad842e3. The NameID transform input has no idp field, so the original idp.id = "<github idp>" clause was always false. Everyone, including the mapped pilot, got unmapped@access.invalid. I captured the input by setting the transform to $string($):
{"id": <github-user-id>, "name": "<name>", "email": "<github-email>",
"groups": [{"id": 182288589, "name": "modelcontextprotocol",
"teams": [{"name": "<team>"}, … 8 teams]}]}The last-seen identity API does include idp, which is why the original expression passed against it locally. The fix drops the clause. GitHub is still enforced by allowedIdps, and the org and numeric-ID checks remain. The tests now use this captured shape.
Results
| Case | Outcome |
|---|---|
| API read-back | Both transforms and nameIdFormat returned byte-for-byte, with no custom attributes. The one dashboard save was not done. |
| Original expression, org member | Signed Success, NameID unmapped@access.invalid (emailAddress) |
| Fixed expression, mapped member | Signed Success, NameID <pilot>@modelcontextprotocol.io (emailAddress), empty AttributeStatement |
Transform error ($error("…")) |
No assertion. Access shows "Failed to generate a SAML Response — JSONata expression failed to transform the data … Error: pr230 forced error" |
Empty result ("") |
Signed Success with an empty <NameID/>, format switched to persistent. No fallback to email. |
Neither negative case falls back to the email, so I didn't try nameIdFormat: 'id'. The empty case still issues an assertion, but buildNameIdTransform always ends in a non-empty string literal, so it can't produce one.
Other observations:
- A transform change took about 20–40s to reach the edge. The NameID isn't fixed for the session, so the next assertion uses the current mapping.
- Not covered: a second, unlisted org member signing in live (the unmapped path is shown by the original-expression result above), and checking the signature against the app certificate (
Signatureelements were present on both Response and Assertion).
Fixed expression, mapped member (abridged)
<saml2p:Response Version="2.0" ID="_wS52bS14upoNoToc0P24L" IssueInstant="2026-11-29T03:36:48.531Z" Destination="http://localhost:8765/acs" InResponseTo="_d2939b40…">
<saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://modelcontextprotocol.cloudflareaccess.com/<aud></saml2:Issuer>
<Signature>… rsa-sha256 …</Signature>
<saml2p:Status><saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/></saml2p:Status>
<saml2:Assertion Version="2.0" ID="_wMRdgZD8Q9k0Z6cpMtmuI" IssueInstant="2026-11-29T03:36:48.531Z">
<saml2:Issuer …>https://modelcontextprotocol.cloudflareaccess.com/<aud></saml2:Issuer>
<Signature>… rsa-sha256 …</Signature>
<saml2:Subject>
<saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"><pilot>@modelcontextprotocol.io</saml2:NameID>
<saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml2:SubjectConfirmationData InResponseTo="_d2939b40…" Recipient="http://localhost:8765/acs" NotOnOrAfter="2026-11-29T03:41:48.536Z"/>
</saml2:SubjectConfirmation>
</saml2:Subject>
<saml2:Conditions NotBefore="2026-11-29T03:31:48.536Z" NotOnOrAfter="2026-11-29T03:41:48.536Z">
<saml2:AudienceRestriction><saml2:Audience>https://sso-test.invalid/sp</saml2:Audience></saml2:AudienceRestriction>
</saml2:Conditions>
<saml2:AuthnStatement AuthnInstant="2026-11-29T03:36:48.531Z" SessionNotOnOrAfter="2026-11-29T04:36:49.000Z">…PasswordProtectedTransport…</saml2:AuthnStatement>
<saml2:AttributeStatement/>
</saml2:Assertion>
</saml2p:Response>Original expression, org member: Subject
<saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">unmapped@access.invalid</saml2:NameID>Empty result (""): Subject
<saml2:Subject>
<saml2:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"/>
<saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml2:SubjectConfirmationData InResponseTo="_bbcaf5be…" Recipient="http://localhost:8765/acs" NotOnOrAfter="2026-11-29T03:43:36.033Z"/>
</saml2:SubjectConfirmation>
</saml2:Subject>There was a problem hiding this comment.
Thanks for running these, and good catch on idp. Four things left:
- With that check gone, GitHub-only rests on
allowedIdps, which Cloudflare documents as the providers a user can select, and Access evaluates a user's last-known state. Can we addrequires: [{ loginMethod: { id: githubIdentityProviderId } }]to the policy, and confirm a one-time PIN session is refused, including after the same user signs in with GitHub in another browser? - The unmapped result came from the old expression, which never reached the lookup. Can you rerun the final expression with a table that doesn't contain your ID? That needs no second person.
- The dashboard save is still open. If it clears the transform,
nameIdFormat: 'id'is still the fix to try. - The empty
AttributeStatementisn't valid under the SAML schema, which requires at least one attribute, so Google may reject it. Can the transform return one constant attribute instead of{}?
Generated by Claude Code
There was a problem hiding this comment.
Done. All four are in 1c778fe. I ran them on a second throwaway app with the same settings, except that the app allowed GitHub and one-time PIN so the PIN case could be exercised. It's deleted, and the identifiers below are redacted.
1. GitHub-only. Added requires: [{ loginMethod: { id: githubIdentityProviderId } }] to the policy. To reproduce your scenario without touching another app, a second throwaway app that allowed only PIN gave the same Access user (<github-email>) a PIN session in a private window. In the other browser, that user had signed in with GitHub a few minutes earlier. In the private window, opening the test app showed the sign-in picker. Access issued no assertion, and the request log has no onetimepin request for the app. I repeated it with the login-method rule removed and got the same picker, so Access didn't reuse the stored GitHub groups for the PIN session. The rule stays as defense in depth. One side note: Access only sends a PIN code to an address the app's policy could admit, so with an org-only policy no code is sent at all.
2. Unmapped with the final expression. I used the exact buildNameIdTransform output with a table that leaves out my ID ({"1": "someone-else@…"}). A GitHub sign-in by an org member returned a signed Success with NameID unmapped@access.invalid in emailAddress format, so the expression reaches the lookup and misses.
3. Dashboard save. I opened the app in the dashboard and saved without changes. Comparing the full app object from the API before and after, the only differences are the updated_at timestamps on the app and the policy. Everything else was unchanged: both transforms, nameIdFormat, the SP values, allowedIdps, the Cloudflare One Client setting, the session duration and the login-method rule. After that, a mapped sign-in returned <pilot>@modelcontextprotocol.io in emailAddress format. So nameIdFormat: 'id' isn't needed.
4. Constant attribute. samlAttributeTransformJsonata is now {"source": "cloudflare-access"}, exported as SAML_ATTRIBUTE_TRANSFORM and unit-tested. Both mapped and unmapped assertions carry exactly that one attribute, and the NameID is unaffected:
<saml2:AttributeStatement>
<saml2:Attribute Name="source" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
<saml2:AttributeValue xsi:type="xs:string">cloudflare-access</saml2:AttributeValue>
</saml2:Attribute>
</saml2:AttributeStatement>The PR description has the updated results and rollout step 1, which now also checks the login-method rule and the constant attribute on the deployed app. Still not covered: checking the signature against the app certificate.
There was a problem hiding this comment.
Follow-up on point 1: the login-method rule is now tested on its own. On a throwaway app whose email include matched the identity, I changed only requires.loginMethod. Requiring PIN refused a GitHub sign-in ("That account does not have access", no assertion), and requiring GitHub admitted the same sign-in. I also confirmed that PIN codes are delivered to the admitted address. All test apps have been deleted.
ccb1746 to
1a842f6
Compare
45305c3 to
f10a86b
Compare
|
Thanks for the review, @localden. I’ve addressed the profile defaults, GitHub ID and role checks, session duration, offboarding docs, and JSONata tests in I’ve left the NameID thread open. After merge, I’ll use a throwaway Cloudflare app to confirm an unlisted org member gets |
f10a86b to
3cd8c42
Compare
3cd8c42 to
9629912
Compare
9629912 to
ad842e3
Compare
ad842e3 to
c8fa190
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c8fa190 to
1c778fe
Compare
Summary
Allow a single maintainer,
sambhav, to sign in to MCP Google Workspace with GitHub through Cloudflare Access for SaaS. Cloudflare signs the SAML assertion. The earlier custom OIDC Worker, GitHub App and D1 database are no longer part of this change.The direct members of the
workspace-ssoGitHub team are the pilot roster. The same entries inusers.tssupply the numeric GitHub ID → Workspace email mapping. An enabled member needs a GitHub login and a current Google provisioning role, including inherited roles. CI resolves each enabled ID with GitHub and checks the login. The policy uses the slug from the Pulumi-managed team and requires a GitHub login method. The app allows only the GitHub identity provider, disables Cloudflare One Client authentication, and sends one constant SAML attribute (source: cloudflare-access) in place of Access's default group attributes. The app and policy each use a one-hour session duration.The NameID transform checks GitHub org membership and looks up the numeric GitHub ID. It does not check the identity provider, because Cloudflare's transform input has no
idpfield (verified live, see below). The policy's login-method rule enforces GitHub instead.allowedIdpsonly limits which providers the login page offers.Verification
npm run validate,npm test,npm run check-github-ids(live GitHub ID → login check, its own CI step) andnpm run format:check.Live results
The test used the app settings from
src/cloudflare.tsand Google's SP values were never set. Its policy admitted the whole GitHub org rather than theworkspace-ssoteam, so an unmapped member could reach the transform.nameIdFormatreturned byte-for-byte, with no custom attributesunmapped@access.invalid. The transform input is{id, name, email, groups[{id, name, teams[{name}]}]}, with noidpfield, so theidp.idclause was always false. Fixed in this PR, and the tests now use the captured shape.<pilot>@modelcontextprotocol.io, formatemailAddress, emptyAttributeStatementunmapped@access.invalid"")<NameID/>and the format switched topersistent. No fallback to email.buildNameIdTransformalways ends in a non-empty string literal, so it can't produce this.Second round, on Den's follow-ups. The app allowed GitHub and one-time PIN, so the PIN case could be exercised, and the policy included the login-method rule:
unmapped@access.invalidrequires.loginMethodchanged. Requiring PIN: a GitHub sign-in was refused ("That account does not have access", no assertion). Requiring GitHub: the same sign-in was admitted. The rule enforces the login method by itself.updated_atchanged. A mapped sign-in after the save still worked.source=cloudflare-access(xs:string). The NameID is unaffected, both mapped and unmapped.PIN codes were delivered to an address the policy admitted. In our tests no code arrived for addresses the policy did not admit, including every address under an org-only policy. Delivery was intermittent during testing, so that negative case is observed rather than proven.
Neither negative case fell back to email, so
nameIdFormat: 'id'is not needed.Pilot rollout
Before merge
Not covered, and not blocking: checking the signature against the app certificate.
After merge — connect Google and activate the pilot
cf zero-trust access applications get) and confirms:buildNameIdTransformand has noidpclause{"source": "cloudflare-access"}allowed_idpsis GitHub only and the Cloudflare One Client option is offworkspace-ssoteam is denied.access.invalidfails, but the signed response is visible before it's sent.sambhav@is enrolled and has no Workspace admin roleThe README covers enabling more members and revoking Google and Cloudflare sessions during offboarding. A mapping change takes effect on the next assertion, about a minute after deploy. Existing Google sessions and Access sessions still have to be revoked.