feat(api): declare identity contract for registration, verification, and sessions

This commit is contained in:
shira committed 2026-10-05 22:57:19 +03:00
1 parent 197661145e
commit 653f3775f8
86 files changed
+11826 -148

No files matched your search

@@ -0,0 +1,47 @@
post:
operationId: ConfirmEmail
summary: Verify an email with the one-time token from the link.
description: |-
Public operation without a session. The verification link has the form `<frontend origin>/verify-email#token=<token>`: the token travels in the URL fragment, so it never reaches a server log or a Referer header. The page first removes the fragment with `history.replaceState`, then waits for an explicit user action, such as a Confirm button, before it posts the token here. A link scanner that only fetches the page therefore does not consume the token.
The server looks up the token by its hash and, in one transaction, checks that it is unused, not expired, and bound to the current registration version, marks it used, and marks the email verified. Only one of several parallel requests with the same token succeeds. An expired token answers verification_token_expired; an unknown, used, replaced, or superseded token answers verification_token_invalid; neither changes anything. For both, the client offers a new link and sign-in, because the address may already be verified.
A repeated confirmation with an already used token is not an idempotent 200: exactly one request may succeed for a token, so the outcome of parallel requests stays unambiguous, and the next step after either outcome is sign-in anyway.
Success does not start a session: the link may be opened on another device or by a mail scanner, and a session must come only from the password. The response returns the scenario and the saved onboarding step so the client can continue after sign-in. The operation is rate-limited and requires an allowed Origin.
security: []
tags:
- identity
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/EmailVerificationRequest
examples:
token:
summary: Token from the link
value:
token: q3Zt9b2Kx7LmP4vR8sW1yC6nD0fH5jA2eG9uI3oT7kE
responses:
"200":
description: The email is verified.
content:
application/json:
schema:
$ref: ../components/schemas.yml#/EmailVerificationResult
examples:
candidate:
summary: A candidate continues with consents
value:
email_verified: true
scenario: candidate
onboarding_step: candidate_consents
"400":
$ref: ../components/responses.yml#/EmailVerificationFailed
"403":
$ref: ../components/responses.yml#/CsrfCheckFailed
"429":
$ref: ../components/responses.yml#/TooManyRequests
default:
$ref: ../components/responses.yml#/Problem