Skip to content

cors: expose WWW-Authenticate, Last-Modified, Accept-Query to cross-origin clients - #629

Merged
melvincarvalho merged 1 commit into
gh-pagesfrom
cors-expose-www-authenticate
Oct 14, 2026
Merged

melvincarvalho merged 1 commit into
gh-pagesfrom
cors-expose-www-authenticate

Conversation

@melvincarvalho

Copy link
Copy Markdown
Contributor

A browser client on another origin cannot read a 401's WWW-Authenticate unless it is listed in Access-Control-Expose-Headers — it is not CORS-safelisted. The default list in src/ldp/headers.js lacked it (the cors-proxy's list has it), so cross-origin discovery of the authorization server stops at the 401. Found with https://linkedwebstorage.com/todo/ against a local lwsd; the same applies to any cross-origin Solid-OIDC client reading the challenge.

Adds WWW-Authenticate, plus Last-Modified (date validators) and Accept-Query (lws10-index). One line in the header string; no behaviour change otherwise.

Related: #621, #625.

…s-origin clients

A browser client on another origin could not read the 401 challenge
(as_uri / resource_metadata for LWS, the Solid-OIDC challenge alike):
WWW-Authenticate is not CORS-safelisted and was missing from
Access-Control-Expose-Headers. Seen from linkedwebstorage.com/todo/
talking to a local lwsd. Last-Modified (date validators) and
Accept-Query (lws10-index) added for the same reason; the cors-proxy
already exposed WWW-Authenticate.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

It is a single-line, correctly formatted additive change whose exposed headers are either already emitted by the server or harmless when absent, matching the established cors-proxy list.

0 open findings

What changed in this PR

This PR widens the default CORS Access-Control-Expose-Headers list in src/ldp/headers.js so that cross-origin browser clients can read response headers that are otherwise not CORS-safelisted. The key motivation is WWW-Authenticate: without exposing it, a cross-origin Solid-OIDC client cannot read the 401 challenge and discover the authorization server. It also adds Last-Modified (date validators) and Accept-Query (for upcoming LWS index work), bringing the pod-wide list in line with the existing cors-proxy list.

Changes:

  • Add WWW-Authenticate to the exposed headers so cross-origin clients can read the 401 auth challenge.
  • Add Last-Modified and Accept-Query to the exposed headers, inserted to preserve the existing alphabetical ordering.
File Description
src/​ldp/​headers.js Extends getCorsHeaders Access-Control-Expose-Headers with WWW-Authenticate, Last-Modified, and Accept-Query.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@melvincarvalho
melvincarvalho merged commit a0ea57f into gh-pages Oct 14, 2026
2 checks passed
@melvincarvalho
melvincarvalho deleted the cors-expose-www-authenticate branch October 14, 2026 21:56
melvincarvalho added a commit that referenced this pull request Oct 18, 2026
Since 0.0.220:
- --git defers to plugin-owned prefixes (#616, #630): core's git preHandler
  returns early for a URL below an app path, so a plugin serving git
  smart-HTTP under its mount (the forge at /forge/<owner>/<name>.git) is no
  longer shadowed by core's 401. Pod git outside plugin prefixes is unchanged.
- CORS exposes WWW-Authenticate, Last-Modified and Accept-Query to
  cross-origin clients (#629).
- @fastify/websocket registered once at the root (#545, #620).
- Hardening: atomic quota reservation and idempotent deposit credit (#619).
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