Skip to content

Let the native app create papers and import ZIPs through /api/latex - #80

Merged
lmwmason merged 2 commits into
mainfrom
fix/latex-native-origin
Nov 26, 2026
Merged

lmwmason merged 2 commits into
mainfrom
fix/latex-native-origin

Conversation

@lmwmason

Copy link
Copy Markdown
Contributor

Follow-up to #78. `/api/latex/{action}` POST required `Origin === https://`, so the app got 403 when creating a paper or importing a ZIP (`new`, `import`, `upload-begin|chunk|finish|cancel`, `trash`, `allocate`).

Change

One line: the Origin check now uses the shared `writeOriginAllowed` rule from `schoolsProxySecurity` (Bearer, no Origin, no Cookie, no Sec-Fetch-*). A present Origin is checked exactly as before. Host allow-list (`cbgpu.com`, `researcher`, `app`), action allow-list, token verification and rate limits are unchanged.

Tests

`tests/latex-native-origin.test.mts` runs the real route: all five write actions succeed for an app request and reach the editor service with the identity taken from the verified token; own-page requests still work; foreign / suffix-spoofed Origin, cookie without Origin, browser metadata without Origin and no credentials are all 403 and never reach the editor service; invalid token still 401; wrong host and unknown action still 404.

🤖 Generated with Claude Code

tyuteu5-lab and others added 2 commits November 26, 2026 16:34
The POST path required an Origin equal to our own host, which an app never
sends, so paper creation and ZIP import returned 403. Use the shared write
origin rule (Bearer, no Origin, no cookie, no Sec-Fetch-*) like the school, GPU,
arcade, deploy and study routes. A present Origin is still checked exactly as
before; host, action and authentication checks are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The route now uses the shared write-origin rule, and this test's module
whitelist did not know it. Inject the real module so the test keeps exercising
the actual policy.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019WGLWH38z9TSjANcYp59QN
@lmwmason
lmwmason merged commit 931911c into main Nov 26, 2026
2 of 3 checks passed
@lmwmason
lmwmason deleted the fix/latex-native-origin branch November 26, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants