Files
lincodex/api/core/routes/identity_registrations.yml
T

68 lines
4.4 KiB
YAML

post:
operationId: RegisterAccount
summary: Register an account by email with a scenario and consent C1.
description: |-
Public operation without a session. The client reads the current C1 text with GetConsentText and sends the email, the password, the chosen scenario, and consent C1 with the version of the text the user accepted.
The answer is the same 202 whether the email is new, registered but not verified, or verified, so registration does not enumerate accounts:
- New email: the server creates an unverified account with the scenario and the first onboarding step, records C1 with its text version and text hash, stores only the hash of a one-time verification token plus the pending registration credentials, and queues the verification message, all in one transaction.
- Registered but not verified: the server treats the request as a new registration of that address. In one transaction it advances the registration version, replaces the C1 record, invalidates every earlier verification token, and queues a message with a new token carrying the pending password hash, scenario, and onboarding step. The account's saved credentials and scenario change only when the address owner confirms that token with its registration password, so a pre-registration with someone else's password cannot take over the account.
- Verified: nothing changes. The server may queue a rate-limited "you already have an account" notice to the address.
Every verification token is bound to the registration version it was issued for, so a token issued before a re-registration can never confirm the newer credentials. An account that stays unverified is deleted with its consent record and tokens 7 days after its last registration (planned value from configuration). Verification tokens live 24 hours (planned value from configuration).
The response does not depend on the branch in content or timing. Before it looks up the email, the server validates the whole body, including the password bounds after normalization, the password blocklist, and the C1 version, and it computes the Argon2id hash on every branch; a 400 therefore never depends on whether the email exists. Mail is delivered asynchronously from the outbox.
The operation requires Idempotency-Key. For this anonymous operation the key is scoped by the operation, the key, and an HMAC of the normalized email, and the request fingerprint is an HMAC-SHA-256 with a server secret over the canonical JSON body. The server never stores the body, the password, or a plain hash of either; the secret keeps the fingerprint from serving as an offline password check. A retry with the same key, email, and body replays the stored 202 without a second message; the same key and email with a different body answers 422 idempotency_key_reused.
It is rate-limited per client and per email and answers 429 with Retry-After when the limit is reached. Like every unsafe request, it requires an allowed Origin and answers 403 csrf_check_failed otherwise.
security: []
tags:
- identity
parameters:
- $ref: ../components/parameters.yml#/IdempotencyKey
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/RegistrationRequest
examples:
candidate:
summary: Candidate registration
value:
email: candidate@example.com
password: correct horse battery staple
scenario: candidate
consent_c1:
text_version: c1-2026-10-01
accepted: true
responses:
"202":
description: >-
Registration request accepted. If the email can be registered, a
verification link is on its way; the response does not say whether
it was.
content:
application/json:
schema:
$ref: ../components/schemas.yml#/IdentityRequestAccepted
examples:
accepted:
summary: Neutral acknowledgement
value:
status: accepted
"400":
$ref: ../components/responses.yml#/RegistrationValidationFailed
"403":
$ref: ../components/responses.yml#/CsrfCheckFailed
"409":
$ref: ../components/responses.yml#/IdempotencyInProgress
"422":
$ref: ../components/responses.yml#/UnprocessableContent
"429":
$ref: ../components/responses.yml#/TooManyRequests
default:
$ref: ../components/responses.yml#/Problem