Open cross-origin reads for third-party frontends - #309
Merged
Conversation
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.
Summary
Completes #297: the public read surface now answers cross-origin browser requests from any origin with
Access-Control-Allow-Origin: *— no per-origin onboarding — while the credentialed first-party posture is untouched.New
PublicReadCORSMiddleware(pure ASGI, registered outside the credentialedCORSMiddleware), implementing the design notes recorded on the issue:CORSMiddlewarecan't express both (wildcard andallow_credentialsare mutually exclusive per spec): criticalbit origins keep the credentialed echo for the management surface; everyone else gets*on public/v1GET/HEAD.*, never an origin echo — echoing requiresVary: Origin, which fragments CDN cache entries per origin;*is constant and cache-safe. The layer never touchesVary./v1/meexcluded — a GET, but per-user and cookie-authenticated; it stays first-party-only. Writes and infra routes get nothing.EventSourceincluded) — no preflight machinery needed or wanted; documented in the README consumer section.CORSMiddlewarestampsallow-credentials: trueon every response, allowed origin or not — paired with*that's a spec-invalid combination, so the layer strips the stray header on the responses it opens (that branch only runs for non-first-party origins, so no grant is ever revoked)./v1/streamresponse passes through untouched.README's third-party-frontend section rewritten for the new posture (browser apps work from any origin; keep requests simple; write API unchanged).
Tests
598 passed. New matrix: third-party GET →
*with no credentials header; first-party origin → credentialed echo preserved (no downgrade to*);/v1/me→ never opened; third-party write → nothing; no Origin header → nothing; infra routes → nothing.Closes #297