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

63 lines
2.9 KiB
YAML

post:
operationId: Login
summary: Sign in with email and password and start a session.
description: |-
Public operation that starts a server session. The server verifies the password with Argon2id; for an unknown email it verifies against a fixed dummy hash, so the response time does not reveal whether the account exists. An unknown email and a wrong password both answer 401 invalid_credentials.
Correct credentials for an unverified email answer 403 email_not_verified and create no session. This reveals the verification state only to someone who already knows the password, which proves more than the state itself; the client offers to resend the link.
On success the server revokes the session that the request carried, if any, creates a new random session in PostgreSQL with a new identifier and a new CSRF token, sets the HttpOnly session cookie, and returns the account and the CSRF token. The new session follows the idle and absolute timeouts of the sessionCookie scheme. The client keeps the token in memory and sends it in X-CSRF-Token with every mutating request that requires a session.
Login is rate-limited per client and per email and answers 429 with Retry-After. Like every unsafe request, it requires an allowed Origin, which protects against login CSRF, and answers 403 csrf_check_failed otherwise.
security: []
tags:
- identity
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/LoginRequest
examples:
login:
summary: Email and password
value:
email: candidate@example.com
password: correct horse battery staple
responses:
"201":
description: Session started; the session cookie is set.
headers:
Set-Cookie:
$ref: ../components/headers.yml#/SessionCookieSet
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/Session
examples:
candidate:
$ref: ../components/examples.yml#/CandidateSession
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/InvalidCredentials
"403":
description: >-
Correct credentials for an unverified email (email_not_verified), or
a disallowed Origin (csrf_check_failed). No session was created.
content:
application/problem+json:
schema:
$ref: ../components/schemas.yml#/Problem
examples:
email_not_verified:
$ref: ../components/examples.yml#/EmailNotVerified
csrf_check_failed:
$ref: ../components/examples.yml#/CsrfCheckFailed
"429":
$ref: ../components/responses.yml#/TooManyRequests
default:
$ref: ../components/responses.yml#/Problem