Skip to content

A 403 that challenges is an auth failure; permission refusals said to a person - #70

Merged
jallers merged 4 commits into
masterfrom
claude/auth-403
Nov 27, 2026
Merged

jallers merged 4 commits into
masterfrom
claude/auth-403

Conversation

@jallers

@jallers jallers commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Stacked on #69 (the documentation fix about X-Requested-With). Until #69 merges, this diff shows its two commits as well; the commit that belongs here is "A 403 that challenges is an auth failure; a write refused for want of rights is said so to a person". It supersedes #69's advice to set unauthorizedStatuses: [401, 403], and corrects that wording here rather than by rewriting #69. Towards alpha.13; the version is not bumped.

Breaking (for custom transports)

A 403 that carries a WWW-Authenticate challenge is an auth failure. It is what an ended session answers to a request sent with X-Requested-With: XMLHttpRequest (to a plain request it answers 401, with the same challenge and body).

  • apiErrorFromResponse(status, body, headers) takes the response's headers as an optional third argument: a Headers, anything with get(name) (an axios response's headers), or a plain record. With them, a challenged 403 is kind: "auth". A 403 without a challenge, or with no headers given, is kind: "forbidden" as before.
  • The built-in transport passes them. onUnauthorized now runs for such a 403 by default, with "retry" and "retry-write" as for a 401; its context gains headers; client.explain gives the sign-in sentence instead of "not allowed".
  • unauthorizedStatuses now lists statuses that call the hook in addition to a 401 and a challenged 403, which always do. A consumer that set [401, 403] loses nothing: a 403 without a challenge still reaches its hook.
  • transportConformance has the case and a control. A custom transport passes the headers where it builds a refusal, for axios apiErrorFromResponse(response.status, response.data, response.headers). One that does not is told so by the suite. This repository's own axios example failed the new case until it was changed, which is the suite doing its job.

Changed

A write the member has no right to make is said so, to a person, on both write paths. Where it was looked at it was never a 403:

Path What the server answers Before Now
api/asset 200, the command failing with Violation'Security'Story explain: "Refused (security)." to a developer "Agility refused: this member is not allowed to do that." to a user, the type's label in typeLabel
rest-1 400, first exception Violation'Security'Story kind: "invalid", message "Bad Request", echoed to a developer kind: "forbidden", worded by the violation, the same sentence to a user

outcome is "notApplied" for both, as before. A branch on kind === "invalid" no longer sees rest-1's refusal.

What this rests on, and what is not checked

All of it is from a browser-app consumer's checks on one product release with OIDC sign-in:

  • every 401 and 403 seen carried WWW-Authenticate: Bearer and was a session problem (missing, invalid, expired);
  • a read-only member with a valid session got the two answers in the table, with and without X-Requested-With, neither with a challenge, and nothing was applied.

It could not be reproduced where this SDK's live tier runs: every request there is authenticated, as an administrator, so no session ends and nothing is denied. The unit fixtures are those responses with identities replaced.

Not checked: administration endpoints that might answer 403 for rights, other releases, other ways of signing in. For that reason the documentation still tells a hook that prompts a person to check first that the session is really gone.

Verification

  • npm run verify: 295 unit tests in 37 files, all passing. New: the classification with headers in each form and its controls; the built-in transport calling the hook for a challenged 403, handing it the headers, resending a read on "retry" and a write only on "retry-write", once per request; a plain 403 reaching the hook only when listed; reauthorize: false skipping the hook; rest-1's refusal not re-coded as a rejected query; both explanations, with a control rule that stays a developer's.
  • The integration tier against the API-testing instance: 91 passed, 3 skipped by design. Its first run failed on the axios example (see above); after the example passed the headers, all green.

Generated by Claude Code

… it an ended session answers 403, not 401

Documentation only. The transport's comment advised the header so that
the server would answer 401; a consumer who ended a real session saw a
401 without it and a 403 with it. An app sending the header needs
unauthorizedStatuses [401, 403] and a session check in its hook.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
…st for client.lists

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
… rights is said so to a person

An ended session answers 403, with the same WWW-Authenticate challenge
as its 401, to a request sent with X-Requested-With. apiErrorFromResponse
takes the response's headers and classifies that 403 as kind auth; the
built-in transport passes them, calls onUnauthorized for it by default
and hands the hook the headers. unauthorizedStatuses lists statuses in
addition to those. A custom transport passes the headers too, and the
conformance suite asks for it.

A permission denial was never a 403 where it was looked at: api/asset
reports it per command inside a 200 and rest-1 as a 400. rest-1's is now
kind forbidden, and explain says "not allowed" to a person for both.

From a consumer's captured responses; not reproducible where the SDK's
live tier runs, where every request is an administrator's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
…hich always call the hook

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rgicmffzzwb2CzyeDSEhBm
@jallers
jallers merged commit 9314738 into master Nov 27, 2026
4 checks passed
@jallers
jallers deleted the claude/auth-403 branch November 27, 2026 01:35
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