Skip to content

Don't overwrite existing Authorization headers (breaks Solid-OIDC/DPoP) #5

Done

Description

@melvincarvalho

Problem

Podkey's fetch/XHR interceptors in `src/nip98-interceptor.js` and `src/injected.js` unconditionally overwrite the request's `Authorization` header, even when the page already set one (e.g., `Authorization: DPoP ` for Solid-OIDC).

Result: any page using Solid-OIDC — including the pilot app on `test.solid.social` — has its DPoP access token replaced by Podkey's NIP-98 signature. JSS then authenticates the request as `did:nostr:` instead of the user's real WebID, and ACL denies access to the user's own profile. User gets 403 on writes.

Observed in JSS issue #306.

Code pointers

  • `src/nip98-interceptor.js:72,75,96,98,129`
  • `src/injected.js:41,44,67,69,110,112,144`

All of these unconditionally assign `Authorization` without checking whether the page already set one.

Fix

Before injecting, check if an `Authorization` header is already present. If yes, skip Podkey's injection — the page is already authenticating itself and Podkey shouldn't interfere.

The 401-retry path is different: if the page's own Authorization failed (401), Podkey can retry with NIP-98 (this behavior stays). The fix is specifically about the initial request.

Workaround

Disable Podkey (or use incognito) when using Solid-OIDC apps. Not acceptable long-term.

Activity

  1. jjohare commented on Nov 28, 2026

    @jjohare
    Collaborator

    Mostly fixed by #6; two cases remain at bd39ce8, so leaving this open.

    Fixed: XHR (src/nip98-interceptor.js:230-238), and fetch with a Headers object, a tuple array, a plain object in any case, or a Request input with no init.

    Still broken:

    1. fetch(requestWithDPoP, { headers: undefined }). The check at src/nip98-interceptor.js:52 uses hasOwnProperty('headers'), so an explicit undefined counts as "init has headers", the Request's own Authorization is not looked at, and DPoP is replaced with Nostr …. Fix: treat init.headers === undefined as absent.
    2. The 401 retry builds { ...options } (src/nip98-interceptor.js:205-206). The copy is shallow, so setAuthorizationOnOptions deletes the page's own Authorization key from the caller's headers object and writes the Nostr header in its place. The page's next request with that object carries a stale Nostr token instead of its DPoP token. Fix: copy the headers as well as init before writing to them, on both the first attempt and the retry.

    The second point is the same root cause as follow-up 1 on #34.

  2. jjohare commented on Nov 28, 2026

    @jjohare
    Collaborator

    Fixed in 0.0.13 (a2265b7). init.headers === undefined counts as absent, so a Request's own Authorization is respected, and Podkey copies the options and headers before signing and never writes into the caller's objects, on the first attempt or the 401 retry. Tests build a real Request so header replacement is visible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions