-
Notifications
You must be signed in to change notification settings - Fork 9
cors-proxy: Phase 1 — WAC-gated proxy for browser apps (#378) #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5a21bac
e1d3582
5f982d7
04130f0
93af554
3208a29
c1a469c
0f51b60
22f0b89
c860022
46ae2f4
c6b80e8
00a7e3d
451509f
361e563
8d7f883
8395d60
6ec53f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,13 @@ export const defaults = { | |
| // Git HTTP backend | ||
| git: false, | ||
|
|
||
| // CORS proxy (#378) — pod-hosted, WAC-gated proxy for browser apps to | ||
| // fetch arbitrary upstreams that don't return CORS headers. | ||
| corsProxy: false, | ||
| corsProxyMaxBytes: 50 * 1024 * 1024, // 50 MB ceiling on upstream response size | ||
| corsProxyTimeoutMs: 30_000, // 30 s deadline for upstream to send headers (504 if exceeded). The timeout does not apply during body streaming — body size is capped by corsProxyMaxBytes; see follow-up for streaming-phase timeout. | ||
| corsProxyMaxRedirects: 5, // each redirect re-validated for SSRF | ||
|
|
||
| // Nostr relay | ||
| nostr: false, | ||
| nostrPath: '/relay', | ||
|
|
@@ -147,6 +154,10 @@ const envMap = { | |
| JSS_MASHLIB_VERSION: 'mashlibVersion', | ||
| JSS_MASHLIB_MODULE: 'mashlibModule', | ||
| JSS_GIT: 'git', | ||
| JSS_CORS_PROXY: 'corsProxy', | ||
| JSS_CORS_PROXY_MAX_BYTES: 'corsProxyMaxBytes', | ||
| JSS_CORS_PROXY_TIMEOUT_MS: 'corsProxyTimeoutMs', | ||
| JSS_CORS_PROXY_MAX_REDIRECTS: 'corsProxyMaxRedirects', | ||
|
Comment on lines
154
to
+160
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in e1d3582: corsProxy added to BOOLEAN_KEYS; corsProxyMaxBytes, corsProxyTimeoutMs, corsProxyMaxRedirects added to the numeric-key list so JSS_CORS_PROXY=true and JSS_CORS_PROXY_MAX_BYTES=104857600 etc. are parsed correctly. |
||
| JSS_NOSTR: 'nostr', | ||
| JSS_NOSTR_PATH: 'nostrPath', | ||
| JSS_NOSTR_MAX_EVENTS: 'nostrMaxEvents', | ||
|
|
@@ -208,6 +219,7 @@ const BOOLEAN_KEYS = new Set([ | |
| 'mashlib', | ||
| 'mashlibCdn', | ||
| 'git', | ||
| 'corsProxy', | ||
| 'nostr', | ||
| 'webrtc', | ||
| 'terminal', | ||
|
|
@@ -243,7 +255,13 @@ function parseEnvValue(value, key) { | |
| } | ||
|
|
||
| // Numeric values for known numeric keys | ||
| if ((key === 'port' || key === 'nostrMaxEvents' || key === 'payCost' || key === 'payRate') && !isNaN(value)) { | ||
| if ((key === 'port' || | ||
| key === 'nostrMaxEvents' || | ||
| key === 'payCost' || | ||
| key === 'payRate' || | ||
| key === 'corsProxyMaxBytes' || | ||
| key === 'corsProxyTimeoutMs' || | ||
| key === 'corsProxyMaxRedirects') && !isNaN(value)) { | ||
| return parseInt(value, 10); | ||
| } | ||
|
Comment on lines
257
to
266
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 93af554: added a positiveInt() helper in server.js that validates each corsProxy* numeric option is a finite positive number, falling back to the documented default if not. `JSS_CORS_PROXY_MAX_BYTES=banana` now boots clean with the 50 MB default. corsProxy itself is now `=== true` to reject string-truthy values from misconfiguration. |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 22f0b89: `authorize()` JSDoc now documents `options.skipParentForMissing` with shape, behavior, and the rationale (without it, POST /proxy on a virtual endpoint falls back to checking ACL on `/` — too permissive).