Repository navigation
A 403 that challenges is an auth failure; permission refusals said to a person - #70
Merged
Merged
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 setunauthorizedStatuses: [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-Authenticatechallenge is an auth failure. It is what an ended session answers to a request sent withX-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: aHeaders, anything withget(name)(an axios response'sheaders), or a plain record. With them, a challenged 403 iskind: "auth". A 403 without a challenge, or with no headers given, iskind: "forbidden"as before.onUnauthorizednow runs for such a 403 by default, with "retry" and "retry-write" as for a 401; its context gainsheaders;client.explaingives the sign-in sentence instead of "not allowed".unauthorizedStatusesnow 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.transportConformancehas the case and a control. A custom transport passes the headers where it builds a refusal, for axiosapiErrorFromResponse(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:
Violation'Security'Storyexplain: "Refused (security)." to a developertypeLabelViolation'Security'Storykind: "invalid", message "Bad Request", echoed to a developerkind: "forbidden", worded by the violation, the same sentence to a useroutcomeis"notApplied"for both, as before. A branch onkind === "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:
WWW-Authenticate: Bearerand was a session problem (missing, invalid, expired);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: falseskipping the hook; rest-1's refusal not re-coded as a rejected query; both explanations, with a control rule that stays a developer's.Generated by Claude Code