mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
fix(api): give the remaining 401 throws a code, and say what the code covers
Three refusals still answered 401 with prose alone: the Bearer re-read on `/api/auth/me/sessions`, and the wrong-second-factor arm on both MFA step-up routes. The shared 401 description told clients the code is the field to branch on, so a client that took that advice landed in its default arm on all three — and on the MFA pair that is the difference between re-prompting for a digit and signing the user out over a typo. The sessions re-read is the same missing-credential fact the gate already names, so it reuses `auth.missing`. The MFA pair gets a code of its own, `auth.mfa.code_invalid`: none of the existing ones fit, because every other 401 code asks the client to discard something, and this one asks it to keep the session and try another code. The description narrows to match what is actually true. The generic gates name a reason; a route that checks a credential of its own — sign-in, the MFA challenge exchange, a password confirmation — still answers 401 with prose, and the text now says so instead of promising a field those responses do not carry.
This commit is contained in:
1 parent
dd8a724039
commit
2c63b0c4a7
7 files changed
+33
-10
No files matched your search
+10
-5
@@ -70,13 +70,18 @@ paths:
|
||||
schema:
|
||||
$ref: "#/components/schemas/CycleCustomSymptomListEnvelope"
|
||||
"401": &a1
|
||||
description: "Authentication required or invalid credentials. `meta.errorCode` says which, and it is the field to branch
|
||||
on — the English sentence beside it may be reworded or localised at any time. `auth.missing`: no session
|
||||
description: "Authentication required or invalid credentials. The generic auth gates — the ones every route passes
|
||||
through before its own body runs — name the reason in `meta.errorCode`, and that is the field to branch on
|
||||
there; the English sentence beside it may be reworded or localised at any time. `auth.missing`: no session
|
||||
cookie and no Bearer header; send the user to sign in. `auth.token.expired`: the Bearer token's lifetime has
|
||||
passed; refresh and retry the request. `auth.token.invalid`: unknown, revoked, or the owning account is
|
||||
gone; discard the credential and sign in again — retrying will not help. The related 403 refusals carry
|
||||
`auth.scope.insufficient` (the credential is valid but its scope does not reach this route, including any
|
||||
Bearer token against an admin surface) and `auth.admin.required` (a cookie session that is not an admin's)."
|
||||
gone; discard the credential and sign in again — retrying will not help. `auth.mfa.code_invalid`: a second
|
||||
factor presented on a step-up flow did not verify; re-prompt for a code and keep the session. The related
|
||||
403 refusals carry `auth.scope.insufficient` (the credential is valid but its scope does not reach this
|
||||
route, including any Bearer token against an admin surface) and `auth.admin.required` (a cookie session that
|
||||
is not an admin's). A route that checks a credential of its own — sign-in, the MFA challenge exchange, a
|
||||
password confirmation — may still answer 401 with prose and no code, so a missing `meta.errorCode` means the
|
||||
route refused the credential it was handed, not that the response is malformed."
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
|
||||
Reference in new issue
Block a user