feat(accounts): add consent settings and organization management

This commit is contained in:
TakuyaYagam1 committed 2026-10-07 13:00:39 +03:00
1 parent 24638d46d2
commit 391af7a1ef
83 files changed
+10198 -613

No files matched your search

+15 -6
View File
@@ -102,7 +102,7 @@ The ML service answers its errors with the same `Problem` schema. Its `ProblemCo
### Identity: sessions, cookie, and CSRF
The `identity` tag covers registration, email verification, login, logout, and the current account. All operations are in the contract. `RegisterAccount`, `ResendEmailVerification`, `ConfirmEmail`, `Login`, `GetCurrentSession`, `Logout`, and `GetCurrentAccount` are implemented in the backend. The session boundary authenticates every operation protected by the contract; its principal comes from a verified account and an active PostgreSQL session. Other protected operations pass the boundary but answer 501 `not_implemented` after request validation until their business handlers exist. Frontend registration and confirmation screens remain placeholders.
The `identity` tag covers registration, email verification, login, logout, and the current account. All operations are in the contract. `RegisterAccount`, `ResendEmailVerification`, `ConfirmEmail`, `Login`, `GetCurrentSession`, `Logout`, and `GetCurrentAccount` are implemented in the backend. The session boundary authenticates every operation protected by the contract; its principal comes from a verified account and an active PostgreSQL session. Except for identity and the consent operations below, protected business operations currently pass the security boundary and answer 501 `not_implemented` after request validation. Frontend registration and confirmation screens remain placeholders.
| Method and path | operationId | Security | Success | Specific errors |
| --- | --- | --- | --- | --- |
@@ -530,21 +530,30 @@ No new problem code is added: the `ProblemCode` enum is copied byte-for-byte int
### Consents
The `consent` tag covers the consent ledger of the current account (PRD FR01, FR12, and 7.3): the independent consents C1-C5 with their text versions, sources, states, and revocations. The read operation is in the contract but its handler is not implemented: a guest answers 401 `unauthenticated`, and a request with a verified session reaches 501 `not_implemented`. The storage behind it exists (see [ARCHITECTURE.md](../docs/en/ARCHITECTURE.md#consent-ledger)).
The `consent` tag covers the consent ledger of the current account (PRD FR01, FR12, and 7.3): the independent consents C1-C5 with their text versions, sources, states, and revocations. Implemented handlers provide public C1 text, current settings text and the caller's own history, settings grants of C1/C2/C3/C5, revocation of C2/C3/C5, scoped C4 revocation for one organization, and a durable C1 account-deletion request. The request does not synchronously delete the account. Protected operations require an active verified PostgreSQL session; mutations also require the session-bound CSRF token and the sole `Origin` matching `APP_PUBLIC_URL`. Guests receive 401; a disallowed account role, Origin, or CSRF token receives 403.
| Method and path | operationId | Security | Success | Specific errors |
| --- | --- | --- | --- | --- |
| `GET /api/v1/identity/consent-texts/c1` | `GetConsentText` | public | 200 `ConsentText` | 400 `validation_failed` |
| `GET /api/v1/me/consent-texts/{purpose}` | `GetMyConsentText` | session | 200 `ConsentText`, `Cache-Control: no-store` | 400, 401 |
| `GET /api/v1/me/consents` | `ListMyConsents` | session | 200 `ConsentRecordList`, `Cache-Control: no-store` | 400, 401 |
| `PUT /api/v1/me/consents/{purpose}` | `GrantMyConsent` | session and CSRF | 200 `ConsentRecord`, `Cache-Control: no-store` | 400, 401, 403 |
| `DELETE /api/v1/me/consents/{purpose}` | `RevokeMyConsent` | session and CSRF | 204 | 401, 403 |
| `DELETE /api/v1/me/consents/c4/organizations/{org_id}` | `RevokeMyOrganizationContactConsent` | session and CSRF | 204 | 400, 401, 403 |
| `POST /api/v1/me/account-deletion-requests` | `RequestMyAccountDeletion` | session and CSRF | 202 `ConsentDeletionRequest`, `Cache-Control: no-store` | 401, 403 |
- Purposes (`ConsentPurposeCode`): `c1` personal data processing, `c2` publication of the candidate card, `c3` automatic categorization, `c4` transfer of selected contacts to one organization, `c5` import of FSP results. `ConsentPurpose` stays the subset whose text is public before registration (`c1`), so `GetConsentText` does not widen.
- Purposes (`ConsentPurposeCode`): `c1` personal data processing, `c2` publication of the candidate card, `c3` automatic categorization, `c4` transfer of selected contacts to one organization, `c5` import of FSP results. Public `GetConsentText` remains C1-only. `GetMyConsentText` returns the current C1/C2/C3/C5 text before a settings grant. C4 text remains part of an invitation with its specific scope.
- The subject comes from the session; no parameter names an account, so the response holds only the caller's own records. A page lists records newest grant first with cursor pagination; the optional `state` filter takes `active`, `superseded`, or `revoked`, and an unknown value answers 400 with the pointer `/state`.
- A `ConsentRecord` has the purpose, the accepted `text_version`, the `source` (`registration`, `consent_settings`, or `invitation_acceptance`), `granted_at`, the computed `state`, and `revoked_at` with `revocation_source` (`consent_settings` or `support_request`). A `c4` record also names the `organization` (`ConsentOrganization`, whose `name` is the snapshot the consent text showed, so a later rename does not change it), the contact `fields` (`ContactFieldKind`), the `invitation_id`, and the `invitation_terms_version`; they are null for every other purpose. A `c2` record proves the consent to the publication text; which fields were published, and when, is evidence of the publication history ([Candidate visibility](#candidate-visibility)), and a field scope on `c2` records would be an additive change. The record never carries a contact value, the subject, or the text hash: the server stores the SHA-256 of exactly the text the subject saw, and the client never sends or receives it, as for C1 at registration.
- The ledger is append-only. A newer text version of a purpose is a new record and the earlier one becomes `superseded` without any change; a revocation stamps the unrevoked records of the purpose, and for `c4` of one organization, once; a later grant is a new record, and a revoked `c4` of an invitation never comes back. Purposes are independent.
- Planned, additive: granting C1, C2, C3, and C5 in the consent settings and revoking any purpose with its consequences, as new operations of this tag; C1 at registration and C4 in `AcceptMyInvitation` already have their own operations. The C4 permission to pass data on to an ATS and the C4 of an application (PRD Q9) are planned as an additive flag and an additional `source` value.
- Settings grants require explicit `accepted: true` and the current version of the text the user read. C1 is available to candidate and employer accounts; C2/C3/C5 are candidate-only. C4 is excluded from the general settings grant and is granted only when accepting a specific invitation.
- The ledger is append-only. A newer text version is a new record and the earlier one becomes `superseded` without changes; revocation stamps every unrevoked record of the purpose, including earlier versions. C4 revocation is limited to one organization and takes its fields from stored records, never from request data. Repeated revocation is harmless and creates no duplicate event.
- C2 revocation closes the current publication, clears its fields, appends privacy history, and writes a bounded outbox intent in one transaction. A later C2 grant does not reopen the old publication. C3 revocation does not block the manual assessment path. C5 revocation immediately closes the consent gate for future imports and writes a stop/delete intent; no external FSP adapter exists, so actual deletion at FSP is not claimed.
- A C1 deletion request revokes C1 and creates or returns an active durable request plus an outbox intent in one transaction. Repeats return the same request; a later C1 grant never cancels it. The future account-deletion processor is not synchronous and is not implemented yet.
- The C4 permission to pass data on to an ATS and the C4 of an application (PRD Q9) are planned as an additive flag and an additional `source` value.
Open legal item: whether `c2` is a consent to the distribution of personal data under article 10.1 of 152-FZ, which requires its own consent with the categories of data.
No new problem code is added: the contract reuses `validation_failed` and `unauthenticated`. `TestConsentSchemaValidationPrecedesImplementation`, `TestConsentAccessBeforeImplementation`, and `TestConsentDTOsCarryNoHashSubjectOrContact` pin the generated server, and `frontend/src/shared/api/consent-contract.test.ts` pins the generated Zod rules and, at the type level, the absence of hash, subject, and contact fields.
No new problem code is added: the contract uses `validation_failed`, `unauthenticated`, `forbidden`, and `csrf_check_failed`. Contract tests pin the security schemes and validation order, `TestConsentSettingsOverHTTP` exercises consent behavior with real PostgreSQL and Redis, and `frontend/src/shared/api/consent-contract.test.ts` pins generated Zod rules and the absence of hashes, subjects, and contacts from the DTOs.
### Organizations
+15 -6
View File
@@ -102,7 +102,7 @@ ML-сервис отвечает на ошибки той же схемой `Pro
### Identity: сессии, cookie и CSRF
Тег `identity` описывает регистрацию, подтверждение email, вход, выход и текущий аккаунт. Все операции есть в контракте. `RegisterAccount`, `ResendEmailVerification`, `ConfirmEmail`, `Login`, `GetCurrentSession`, `Logout` и `GetCurrentAccount` реализованы в backend. Session boundary аутентифицирует все операции, защищенные контрактом; principal создается только из действующей PostgreSQL-сессии подтвержденного аккаунта. Остальные защищенные операции проходят эту границу, но отвечают 501 `not_implemented` после проверки запроса, пока для них нет бизнес-обработчиков. Экраны регистрации и подтверждения во frontend остаются заглушками.
Тег `identity` описывает регистрацию, подтверждение email, вход, выход и текущий аккаунт. Все операции есть в контракте. `RegisterAccount`, `ResendEmailVerification`, `ConfirmEmail`, `Login`, `GetCurrentSession`, `Logout` и `GetCurrentAccount` реализованы в backend. Session boundary аутентифицирует все операции, защищенные контрактом; principal создается только из действующей PostgreSQL-сессии подтвержденного аккаунта. Помимо identity и перечисленных ниже операций согласий, защищенные бизнес-операции пока проходят security boundary и отвечают 501 `not_implemented` после проверки запроса. Экраны регистрации и подтверждения во frontend остаются заглушками.
| Метод и путь | operationId | Защита | Успех | Конкретные ошибки |
| --- | --- | --- | --- | --- |
@@ -530,21 +530,30 @@ ML-сервис отвечает на ошибки той же схемой `Pro
### Согласия
Тег `consent` описывает журнал согласий текущего аккаунта (FR01, FR12 и 7.3 в PRD): независимые согласия C1-C5 с версиями текстов, источниками, состояниями и отзывами. Операция чтения есть в контракте, но ее обработчик еще не реализован: гость получает 401 `unauthenticated`, а запрос с подтвержденной сессией достигает 501 `not_implemented`. Хранение за ней уже есть (см. [ARCHITECTURE.md](../docs/ru/ARCHITECTURE.md#журнал-согласий)).
Тег `consent` описывает журнал согласий текущего аккаунта (FR01, FR12 и 7.3 в PRD): независимые согласия C1-C5 с версиями текстов, источниками, состояниями и отзывами. Реализованы публичное чтение C1, чтение текущих текстов настроек и собственной истории, выдача C1/C2/C3/C5, отзыв C2/C3/C5 и отзыв C4 в области одной организации. Запрос C1 создает долговечный запрос на удаление аккаунта; сама запись аккаунта не удаляется синхронно. Эти обработчики требуют действующую подтвержденную PostgreSQL-сессию, а изменяющие операции также требуют session-bound CSRF и единственный `Origin`, совпадающий с `APP_PUBLIC_URL`. Гость получает 401; неподходящая роль, неверный Origin или CSRF получают 403.
| Метод и путь | operationId | Защита | Успех | Конкретные ошибки |
| --- | --- | --- | --- | --- |
| `GET /api/v1/identity/consent-texts/c1` | `GetConsentText` | публичная | 200 `ConsentText` | 400 `validation_failed` |
| `GET /api/v1/me/consent-texts/{purpose}` | `GetMyConsentText` | сессия | 200 `ConsentText`, `Cache-Control: no-store` | 400, 401 |
| `GET /api/v1/me/consents` | `ListMyConsents` | сессия | 200 `ConsentRecordList`, `Cache-Control: no-store` | 400, 401 |
| `PUT /api/v1/me/consents/{purpose}` | `GrantMyConsent` | сессия и CSRF | 200 `ConsentRecord`, `Cache-Control: no-store` | 400, 401, 403 |
| `DELETE /api/v1/me/consents/{purpose}` | `RevokeMyConsent` | сессия и CSRF | 204 | 401, 403 |
| `DELETE /api/v1/me/consents/c4/organizations/{org_id}` | `RevokeMyOrganizationContactConsent` | сессия и CSRF | 204 | 400, 401, 403 |
| `POST /api/v1/me/account-deletion-requests` | `RequestMyAccountDeletion` | сессия и CSRF | 202 `ConsentDeletionRequest`, `Cache-Control: no-store` | 401, 403 |
- Цели (`ConsentPurposeCode`): `c1` - обработка персональных данных, `c2` - публикация карточки кандидата, `c3` - автоматическая категоризация, `c4` - передача выбранных контактов одной организации, `c5` - импорт результатов ФСП. `ConsentPurpose` остается подмножеством, текст которого доступен до регистрации (`c1`), поэтому `GetConsentText` не расширяется.
- Цели (`ConsentPurposeCode`): `c1` - обработка персональных данных, `c2` - публикация карточки кандидата, `c3` - автоматическая категоризация, `c4` - передача выбранных контактов одной организации, `c5` - импорт результатов ФСП. Публичный `GetConsentText` остается доступен только для C1; `GetMyConsentText` возвращает текущий текст C1/C2/C3/C5 перед выдачей в настройках. Текст C4 остается частью приглашения с его конкретной областью.
- Субъект берется из сессии; ни один параметр не называет аккаунт, поэтому ответ содержит только собственные записи вызывающего. Страница перечисляет записи от новой выдачи к старой с курсорной пагинацией; необязательный фильтр `state` принимает `active`, `superseded` или `revoked`, а неизвестное значение отвечает 400 с указателем `/state`.
- `ConsentRecord` содержит цель, принятую `text_version`, `source` (`registration`, `consent_settings` или `invitation_acceptance`), `granted_at`, вычисленное `state`, а также `revoked_at` и `revocation_source` (`consent_settings` или `support_request`). Запись `c4` дополнительно называет `organization` (`ConsentOrganization`, где `name` - снимок названия из текста согласия, поэтому последующее переименование его не меняет), поля контакта `fields` (`ContactFieldKind`), `invitation_id` и `invitation_terms_version`; для остальных целей они равны null. Запись `c2` доказывает согласие с текстом публикации; какие поля и когда опубликованы - доказательства истории публикации ([Видимость кандидата](#видимость-кандидата)), а scope полей в записях `c2` был бы аддитивным изменением. Запись никогда не содержит значения контакта, субъекта или хэш текста: сервер хранит SHA-256 ровно того текста, который видел субъект, а клиент его не отправляет и не получает, как и для C1 при регистрации.
- Журнал только дополняется. Новая версия текста цели - новая запись, а прежняя становится `superseded` без изменений; отзыв один раз ставит отметку на неотозванные записи цели, а для `c4` - одной организации; последующая выдача - новая запись, и отозванное `c4` приглашения не возвращается. Цели независимы.
- Запланировано, аддитивно: выдача C1, C2, C3 и C5 в настройках согласий и отзыв любой цели с последствиями новыми операциями этого тега; у C1 при регистрации и C4 в `AcceptMyInvitation` уже есть свои операции. Разрешение C4 на передачу данных в ATS и C4 при отклике (Q9 в PRD) запланированы как аддитивный флаг и дополнительное значение `source`.
- Выдача в настройках требует явного `accepted: true` и текущую версию прочитанного текста. C1 можно выдать аккаунту кандидата или работодателя; C2/C3/C5 доступны только кандидату. C4 нельзя выдать общей операцией настроек: он выдается только принятием конкретного приглашения.
- Журнал только дополняется. Новая версия текста цели - новая запись, а прежняя становится `superseded` без изменений; отзыв ставит отметку на все неотозванные записи цели, включая прежние версии. Отзыв C4 действует только для одной организации и берет набор полей из сохраненных записей, не из запроса. Повтор отзыва безопасен и не создает второе событие.
- Отзыв C2 в одной транзакции закрывает действующую публикацию, очищает ее поля, добавляет запись privacy history и пишет ограниченный по размеру outbox intent. Новая выдача C2 не открывает прежнюю публикацию. Отзыв C3 не блокирует ручной путь оценки. Отзыв C5 немедленно закрывает consent gate для будущего импорта и пишет stop/delete intent; внешнего адаптера ФСП нет, поэтому фактическое удаление данных во ФСП не заявляется.
- Запрос удаления C1 отзывает C1 и создает или возвращает активный запрос удаления и outbox intent в одной транзакции. Повтор возвращает тот же запрос; последующая выдача C1 его не отменяет. Обработчик будущего удаления аккаунта не синхронен и пока отсутствует.
- Разрешение C4 на передачу данных в ATS и C4 при отклике (Q9 в PRD) запланированы как аддитивный флаг и дополнительное значение `source`.
Открытый юридический вопрос: является ли `c2` согласием на распространение персональных данных по статье 10.1 152-ФЗ, которое требует отдельного согласия с категориями данных.
Новый код problem не добавляется: контракт использует `validation_failed` и `unauthenticated`. `TestConsentSchemaValidationPrecedesImplementation`, `TestConsentAccessBeforeImplementation` и `TestConsentDTOsCarryNoHashSubjectOrContact` закрепляют сгенерированный сервер, а `frontend/src/shared/api/consent-contract.test.ts` - сгенерированные правила Zod и, на уровне типов, отсутствие полей хэша, субъекта и контактов.
Новый код problem не добавляется: контракт использует `validation_failed`, `unauthenticated`, `forbidden` и `csrf_check_failed`. Контрактные тесты закрепляют security-схемы и порядок валидации, `TestConsentSettingsOverHTTP` проверяет согласия с настоящими PostgreSQL и Redis, а `frontend/src/shared/api/consent-contract.test.ts` закрепляет сгенерированные правила Zod и отсутствие в DTO хэшей, субъекта и контактов.
### Организации
+52 -1
View File
@@ -2531,6 +2531,21 @@ ConsentPurposeCode:
- c3
- c4
- c5
ConsentSettingsPurpose:
type: string
description: Consent text that an authenticated account can read and accept in settings. C4 is scoped to an invitation and organization, so it is not available through the general settings flow.
enum:
- c1
- c2
- c3
- c5
ConsentSettingsRevokePurpose:
type: string
description: Consent that can be revoked through the general settings flow. C1 uses the account deletion request, and C4 must be revoked for one organization.
enum:
- c2
- c3
- c5
ConsentState:
type: string
description: 'State of a consent record, computed from the ledger.
@@ -2676,6 +2691,42 @@ ConsentRecordList:
$ref: '#/ConsentRecord'
page:
$ref: '#/PageInfo'
ConsentSettingsGrantRequest:
type: object
description: Accept the current published text shown by GetMyConsentText. The server checks its version again before recording the grant.
additionalProperties: false
required:
- text_version
- accepted
properties:
text_version:
$ref: '#/ConsentTextVersion'
accepted:
type: boolean
enum:
- true
description: Must be true to record an explicit acceptance.
ConsentDeletionRequest:
type: object
description: Durable request to delete the account and its personal data. The request is recorded before asynchronous processing starts; it does not mean deletion has completed.
additionalProperties: false
required:
- id
- status
- requested_at
properties:
id:
type: string
format: uuid
description: Identifier of the durable deletion request.
status:
type: string
enum:
- requested
- processing
description: Current state of the deletion request.
requested_at:
$ref: '#/Timestamp'
ContactFieldKind:
type: string
description: 'Kind of personal data that the consent C4 can disclose to one organization (PRD FR01 and FR12). The candidate selects each kind separately; one kind never implies another.
@@ -2989,7 +3040,7 @@ ConsentText:
- published_at
properties:
purpose:
$ref: '#/ConsentPurpose'
$ref: '#/ConsentPurposeCode'
text_version:
$ref: '#/ConsentTextVersion'
text:
@@ -17,6 +17,27 @@ schemas:
- c3
- c4
- c5
ConsentSettingsPurpose:
type: string
description: >-
Consent text that an authenticated account can read and accept in
settings. C4 is scoped to an invitation and organization, so it is not
available through the general settings flow.
enum:
- c1
- c2
- c3
- c5
ConsentSettingsRevokePurpose:
type: string
description: >-
Consent that can be revoked through the general settings flow. C1 uses
the account deletion request, and C4 must be revoked for one
organization.
enum:
- c2
- c3
- c5
ConsentState:
type: string
description: |-
@@ -180,3 +201,44 @@ schemas:
$ref: "#/schemas/ConsentRecord"
page:
$ref: "./common_schemas.yml#/schemas/PageInfo"
ConsentSettingsGrantRequest:
type: object
description: >-
Accept the current published text shown by GetMyConsentText. The server
checks its version again before recording the grant.
additionalProperties: false
required:
- text_version
- accepted
properties:
text_version:
$ref: "./identity_schemas.yml#/schemas/ConsentTextVersion"
accepted:
type: boolean
enum:
- true
description: Must be true to record an explicit acceptance.
ConsentDeletionRequest:
type: object
description: >-
Durable request to delete the account and its personal data. The request
is recorded before asynchronous processing starts; it does not mean
deletion has completed.
additionalProperties: false
required:
- id
- status
- requested_at
properties:
id:
type: string
format: uuid
description: Identifier of the durable deletion request.
status:
type: string
enum:
- requested
- processing
description: Current state of the deletion request.
requested_at:
$ref: "./common_schemas.yml#/schemas/Timestamp"
@@ -89,7 +89,7 @@ schemas:
- published_at
properties:
purpose:
$ref: "#/schemas/ConsentPurpose"
$ref: "./consent_schemas.yml#/schemas/ConsentPurposeCode"
text_version:
$ref: "#/schemas/ConsentTextVersion"
text:
+247 -11
View File
@@ -88,6 +88,38 @@ paths:
$ref: '#/components/responses/ValidationFailed'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/consent-texts/{purpose}:
get:
operationId: GetMyConsentText
summary: Read a current consent text for account settings.
description: 'Requires a verified session. Returns the current published text and version of c1, c2, c3, or c5 so the user can read the exact text before an explicit settings grant. C4 is excluded: its text includes an organization snapshot and it is granted only during invitation acceptance. The response is private and is not cached.'
security:
- sessionCookie: []
tags:
- consent
parameters:
- name: purpose
in: path
required: true
description: Consent whose current text is requested.
schema:
$ref: '#/components/schemas/ConsentSettingsPurpose'
responses:
'200':
description: The current published consent text.
headers:
Cache-Control:
$ref: '#/components/headers/CacheControlNoStore'
content:
application/json:
schema:
$ref: '#/components/schemas/ConsentText'
'400':
$ref: '#/components/responses/ValidationFailed'
'401':
$ref: '#/components/responses/Unauthenticated'
default:
$ref: '#/components/responses/Problem'
/api/v1/identity/registrations:
post:
operationId: RegisterAccount
@@ -2212,7 +2244,7 @@ paths:
Without `state` the page lists the whole history; `state=active` lists the consents that hold now, one per purpose for c1, c2, c3, and c5 and one per accepted invitation for c4. A c4 record names the organization with the name its consent text showed (a snapshot that a later rename does not change), the selected contact fields, and the invitation with its terms version; it never carries a contact value. A c2 record proves the consent to the publication text; the published field set and its changes are evidence of the publication history.
Granting c1, c2, c3, and c5 in the consent settings and revoking any purpose are planned operations of this tag; c1 is given at registration and c4 only in AcceptMyInvitation.
Settings grants of c1, c2, c3, and c5 require the currently published text and an explicit acceptance. Revoking c2, c3, or c5 is available in settings; c1 creates a durable account-deletion request, and c4 is revoked only for one organization. C4 is granted only in AcceptMyInvitation.
Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated. A malformed `limit`, `cursor`, or `state` answers 400 validation_failed.
security:
@@ -2247,6 +2279,159 @@ paths:
$ref: '#/components/responses/Unauthenticated'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/consents/{purpose}:
put:
operationId: GrantMyConsent
summary: Record an explicit consent grant from settings.
description: |-
Requires a verified session, its CSRF token in X-CSRF-Token, and the exact configured Origin. The subject comes from the session. The body names the current text version the user read and requires `accepted: true`; the server verifies that version is still current and stores the hash of the exact text. A stale version answers 400 validation_failed at `/text_version`, without writing a grant.
C1 is available to candidate and employer accounts. C2, C3, and C5 are available only to candidate accounts. C4 is excluded and can be granted only by accepting an invitation. A repeated grant of the same current version returns the existing record; after revocation a grant creates a new record and never reopens a publication or restores an older grant.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- consent
parameters:
- name: purpose
in: path
required: true
description: Independent consent being granted. C4 is not available here.
schema:
$ref: '#/components/schemas/ConsentSettingsPurpose'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ConsentSettingsGrantRequest'
responses:
'200':
description: The created or existing consent record.
headers:
Cache-Control:
$ref: '#/components/headers/CacheControlNoStore'
content:
application/json:
schema:
$ref: '#/components/schemas/ConsentRecord'
'400':
$ref: '#/components/responses/ValidationFailed'
'401':
$ref: '#/components/responses/Unauthenticated'
'403':
description: CSRF or Origin validation failed, or an employer tried to grant a candidate-only purpose.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
examples:
csrf:
$ref: '#/components/examples/CsrfCheckFailed'
forbidden:
$ref: '#/components/examples/Forbidden'
default:
$ref: '#/components/responses/Problem'
delete:
operationId: RevokeMyConsent
summary: Revoke a non-scoped consent from settings.
description: |-
Requires a verified candidate session, its CSRF token in X-CSRF-Token, and the exact configured Origin. The subject comes from the session. Revokes every unrevoked record of c2, c3, or c5, including superseded records, and never changes another purpose. Repeating a revocation is harmless and creates no duplicate event.
Revoking c2 immediately closes the stored publication and records privacy history in the same transaction; a downstream revocation intent is written to the outbox. A later c2 grant does not reopen publication or restore old grants. Revoking c3 does not block the manual assessment path. Revoking c5 makes the consent gate deny further FSP import and writes a durable stop/delete intent; an external FSP deletion adapter is not available yet.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- consent
parameters:
- name: purpose
in: path
required: true
description: Consent being revoked. C1 has a deletion-request operation and C4 requires an organization scope.
schema:
$ref: '#/components/schemas/ConsentSettingsRevokePurpose'
responses:
'204':
description: Consent revoked, or it was already revoked.
'401':
$ref: '#/components/responses/Unauthenticated'
'403':
description: CSRF or Origin validation failed, or an employer account tried to revoke candidate consent.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
examples:
csrf:
$ref: '#/components/examples/CsrfCheckFailed'
forbidden:
$ref: '#/components/examples/Forbidden'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/consents/c4/organizations/{org_id}:
delete:
operationId: RevokeMyOrganizationContactConsent
summary: Revoke C4 for one organization.
description: Requires a verified candidate session, its CSRF token in X-CSRF-Token, and the exact configured Origin. The subject comes from the session; `org_id` is the only scope the caller may choose. The server revokes every unrevoked C4 record for this subject and organization, using the fields stored on those records to request downstream grant revocation. It does not affect another organization. Repeating the request is harmless and creates no duplicate event.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- consent
parameters:
- name: org_id
in: path
required: true
description: Organization whose stored C4 grants this account revokes. A well-formed identifier outside the account's stored records changes nothing and does not reveal whether that organization exists.
schema:
type: string
format: uuid
responses:
'204':
description: C4 revoked for this organization, or no active C4 was present.
'401':
$ref: '#/components/responses/Unauthenticated'
'403':
description: CSRF or Origin validation failed, or the caller is not a candidate.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
examples:
csrf:
$ref: '#/components/examples/CsrfCheckFailed'
forbidden:
$ref: '#/components/examples/Forbidden'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/account-deletion-requests:
post:
operationId: RequestMyAccountDeletion
summary: Revoke C1 and request account deletion.
description: Requires a verified session, its CSRF token in X-CSRF-Token, and the exact configured Origin. The subject comes from the session. In one transaction, revokes any active C1 record, creates or returns the subject's active durable deletion request, and writes the outbox intent. The API does not delete the account synchronously. Repeating the request returns the same active request; a later C1 grant never cancels it.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- consent
responses:
'202':
description: The durable account-deletion request is queued for processing.
headers:
Cache-Control:
$ref: '#/components/headers/CacheControlNoStore'
content:
application/json:
schema:
$ref: '#/components/schemas/ConsentDeletionRequest'
'401':
$ref: '#/components/responses/Unauthenticated'
'403':
description: CSRF or Origin validation failed.
$ref: '#/components/responses/CsrfCheckFailed'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/privacy:
get:
operationId: GetMyPrivacySettings
@@ -2990,6 +3175,21 @@ components:
description: 'Consent whose text the client may read before an account exists. Only the consents given at registration are listed: `c1` is the consent to the processing of personal data.'
enum:
- c1
ConsentSettingsPurpose:
type: string
description: Consent text that an authenticated account can read and accept in settings. C4 is scoped to an invitation and organization, so it is not available through the general settings flow.
enum:
- c1
- c2
- c3
- c5
ConsentSettingsRevokePurpose:
type: string
description: Consent that can be revoked through the general settings flow. C1 uses the account deletion request, and C4 must be revoked for one organization.
enum:
- c2
- c3
- c5
ConsentText:
type: object
description: Currently published consent text. The server stores an acceptance with `text_version` and the hash of exactly this text.
@@ -3001,7 +3201,7 @@ components:
- published_at
properties:
purpose:
$ref: '#/components/schemas/ConsentPurpose'
$ref: '#/components/schemas/ConsentPurposeCode'
text_version:
$ref: '#/components/schemas/ConsentTextVersion'
text:
@@ -7785,6 +7985,42 @@ components:
$ref: '#/components/schemas/ConsentRecord'
page:
$ref: '#/components/schemas/PageInfo'
ConsentSettingsGrantRequest:
type: object
description: Accept the current published text shown by GetMyConsentText. The server checks its version again before recording the grant.
additionalProperties: false
required:
- text_version
- accepted
properties:
text_version:
$ref: '#/components/schemas/ConsentTextVersion'
accepted:
type: boolean
enum:
- true
description: Must be true to record an explicit acceptance.
ConsentDeletionRequest:
type: object
description: Durable request to delete the account and its personal data. The request is recorded before asynchronous processing starts; it does not mean deletion has completed.
additionalProperties: false
required:
- id
- status
- requested_at
properties:
id:
type: string
format: uuid
description: Identifier of the durable deletion request.
status:
type: string
enum:
- requested
- processing
description: Current state of the deletion request.
requested_at:
$ref: '#/components/schemas/Timestamp'
OrganizationVersion:
type: integer
format: int64
@@ -9864,6 +10100,15 @@ components:
pointer: /salary_from
code: invalid
message: The value does not match the contract.
Unauthenticated:
summary: No valid session
value:
type: urn:lincodex:problem:unauthenticated
title: Authentication required
status: 401
code: unauthenticated
detail: Sign in and repeat the request.
trace_id: 4f2d1c3b-6a5e-4d7f-8b9a-0c1d2e3f4a5b
RegistrationValidationFailed:
summary: The password is too short and the consent text is outdated
value:
@@ -9979,15 +10224,6 @@ components:
code: email_not_verified
detail: Confirm the email address with the link from the verification message.
trace_id: 7f8a9b0c-1d2e-4f3a-8b4c-5d6e7f8a9b0c
Unauthenticated:
summary: No valid session
value:
type: urn:lincodex:problem:unauthenticated
title: Authentication required
status: 401
code: unauthenticated
detail: Sign in and repeat the request.
trace_id: 4f2d1c3b-6a5e-4d7f-8b9a-0c1d2e3f4a5b
CandidateAccount:
summary: A verified candidate on the questionnaire step
value:
+16
View File
@@ -81,6 +81,8 @@ paths:
$ref: ./routes/healthz.yml
/api/v1/identity/consent-texts/{purpose}:
$ref: ./routes/identity_consent_texts.yml
/api/v1/me/consent-texts/{purpose}:
$ref: ./routes/my_consent_texts.yml
/api/v1/identity/registrations:
$ref: ./routes/identity_registrations.yml
/api/v1/identity/email-verification-requests:
@@ -149,6 +151,12 @@ paths:
$ref: ./routes/candidate_invitation_cancel.yml
/api/v1/me/consents:
$ref: ./routes/consents.yml
/api/v1/me/consents/{purpose}:
$ref: ./routes/my_consent.yml
/api/v1/me/consents/c4/organizations/{org_id}:
$ref: ./routes/my_consent_c4.yml
/api/v1/me/account-deletion-requests:
$ref: ./routes/account_deletion_requests.yml
/api/v1/me/privacy:
$ref: ./routes/candidate_privacy.yml
/api/v1/me/privacy/publication:
@@ -195,6 +203,10 @@ components:
$ref: ./components/schemas.yml#/OnboardingStep
ConsentPurpose:
$ref: ./components/schemas.yml#/ConsentPurpose
ConsentSettingsPurpose:
$ref: ./components/schemas.yml#/ConsentSettingsPurpose
ConsentSettingsRevokePurpose:
$ref: ./components/schemas.yml#/ConsentSettingsRevokePurpose
ConsentText:
$ref: ./components/schemas.yml#/ConsentText
ConsentTextVersion:
@@ -731,6 +743,10 @@ components:
$ref: ./components/schemas.yml#/ConsentRecord
ConsentRecordList:
$ref: ./components/schemas.yml#/ConsentRecordList
ConsentSettingsGrantRequest:
$ref: ./components/schemas.yml#/ConsentSettingsGrantRequest
ConsentDeletionRequest:
$ref: ./components/schemas.yml#/ConsentDeletionRequest
OrganizationVersion:
$ref: ./components/schemas.yml#/OrganizationVersion
OrganizationName:
@@ -0,0 +1,27 @@
post:
operationId: RequestMyAccountDeletion
summary: Revoke C1 and request account deletion.
description: |-
Requires a verified session, its CSRF token in X-CSRF-Token, and the exact configured Origin. The subject comes from the session. In one transaction, revokes any active C1 record, creates or returns the subject's active durable deletion request, and writes the outbox intent. The API does not delete the account synchronously. Repeating the request returns the same active request; a later C1 grant never cancels it.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- consent
responses:
"202":
description: The durable account-deletion request is queued for processing.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/ConsentDeletionRequest
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
description: CSRF or Origin validation failed.
$ref: ../components/responses.yml#/CsrfCheckFailed
default:
$ref: ../components/responses.yml#/Problem
+1 -1
View File
@@ -8,7 +8,7 @@ get:
Without `state` the page lists the whole history; `state=active` lists the consents that hold now, one per purpose for c1, c2, c3, and c5 and one per accepted invitation for c4. A c4 record names the organization with the name its consent text showed (a snapshot that a later rename does not change), the selected contact fields, and the invitation with its terms version; it never carries a contact value. A c2 record proves the consent to the publication text; the published field set and its changes are evidence of the publication history.
Granting c1, c2, c3, and c5 in the consent settings and revoking any purpose are planned operations of this tag; c1 is given at registration and c4 only in AcceptMyInvitation.
Settings grants of c1, c2, c3, and c5 require the currently published text and an explicit acceptance. Revoking c2, c3, or c5 is available in settings; c1 creates a durable account-deletion request, and c4 is revoked only for one organization. C4 is granted only in AcceptMyInvitation.
Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated. A malformed `limit`, `cursor`, or `state` answers 400 validation_failed.
security:
+89
View File
@@ -0,0 +1,89 @@
put:
operationId: GrantMyConsent
summary: Record an explicit consent grant from settings.
description: |-
Requires a verified session, its CSRF token in X-CSRF-Token, and the exact configured Origin. The subject comes from the session. The body names the current text version the user read and requires `accepted: true`; the server verifies that version is still current and stores the hash of the exact text. A stale version answers 400 validation_failed at `/text_version`, without writing a grant.
C1 is available to candidate and employer accounts. C2, C3, and C5 are available only to candidate accounts. C4 is excluded and can be granted only by accepting an invitation. A repeated grant of the same current version returns the existing record; after revocation a grant creates a new record and never reopens a publication or restores an older grant.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- consent
parameters:
- name: purpose
in: path
required: true
description: Independent consent being granted. C4 is not available here.
schema:
$ref: ../components/schemas.yml#/ConsentSettingsPurpose
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/ConsentSettingsGrantRequest
responses:
"200":
description: The created or existing consent record.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/ConsentRecord
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
description: CSRF or Origin validation failed, or an employer tried to grant a candidate-only purpose.
content:
application/problem+json:
schema:
$ref: ../components/schemas.yml#/Problem
examples:
csrf:
$ref: ../components/examples.yml#/CsrfCheckFailed
forbidden:
$ref: ../components/examples.yml#/Forbidden
default:
$ref: ../components/responses.yml#/Problem
delete:
operationId: RevokeMyConsent
summary: Revoke a non-scoped consent from settings.
description: |-
Requires a verified candidate session, its CSRF token in X-CSRF-Token, and the exact configured Origin. The subject comes from the session. Revokes every unrevoked record of c2, c3, or c5, including superseded records, and never changes another purpose. Repeating a revocation is harmless and creates no duplicate event.
Revoking c2 immediately closes the stored publication and records privacy history in the same transaction; a downstream revocation intent is written to the outbox. A later c2 grant does not reopen publication or restore old grants. Revoking c3 does not block the manual assessment path. Revoking c5 makes the consent gate deny further FSP import and writes a durable stop/delete intent; an external FSP deletion adapter is not available yet.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- consent
parameters:
- name: purpose
in: path
required: true
description: Consent being revoked. C1 has a deletion-request operation and C4 requires an organization scope.
schema:
$ref: ../components/schemas.yml#/ConsentSettingsRevokePurpose
responses:
"204":
description: Consent revoked, or it was already revoked.
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
description: CSRF or Origin validation failed, or an employer account tried to revoke candidate consent.
content:
application/problem+json:
schema:
$ref: ../components/schemas.yml#/Problem
examples:
csrf:
$ref: ../components/examples.yml#/CsrfCheckFailed
forbidden:
$ref: ../components/examples.yml#/Forbidden
default:
$ref: ../components/responses.yml#/Problem
+39
View File
@@ -0,0 +1,39 @@
delete:
operationId: RevokeMyOrganizationContactConsent
summary: Revoke C4 for one organization.
description: |-
Requires a verified candidate session, its CSRF token in X-CSRF-Token, and the exact configured Origin. The subject comes from the session; `org_id` is the only scope the caller may choose. The server revokes every unrevoked C4 record for this subject and organization, using the fields stored on those records to request downstream grant revocation. It does not affect another organization. Repeating the request is harmless and creates no duplicate event.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- consent
parameters:
- name: org_id
in: path
required: true
description: >-
Organization whose stored C4 grants this account revokes. A well-formed
identifier outside the account's stored records changes nothing and
does not reveal whether that organization exists.
schema:
type: string
format: uuid
responses:
"204":
description: C4 revoked for this organization, or no active C4 was present.
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
description: CSRF or Origin validation failed, or the caller is not a candidate.
content:
application/problem+json:
schema:
$ref: ../components/schemas.yml#/Problem
examples:
csrf:
$ref: ../components/examples.yml#/CsrfCheckFailed
forbidden:
$ref: ../components/examples.yml#/Forbidden
default:
$ref: ../components/responses.yml#/Problem
+36
View File
@@ -0,0 +1,36 @@
get:
operationId: GetMyConsentText
summary: Read a current consent text for account settings.
description: >-
Requires a verified session. Returns the current published text and version
of c1, c2, c3, or c5 so the user can read the exact text before an explicit
settings grant. C4 is excluded: its text includes an organization snapshot
and it is granted only during invitation acceptance. The response is
private and is not cached.
security:
- sessionCookie: []
tags:
- consent
parameters:
- name: purpose
in: path
required: true
description: Consent whose current text is requested.
schema:
$ref: ../components/schemas.yml#/ConsentSettingsPurpose
responses:
"200":
description: The current published consent text.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/ConsentText
"401":
$ref: ../components/responses.yml#/Unauthenticated
"400":
$ref: ../components/responses.yml#/ValidationFailed
default:
$ref: ../components/responses.yml#/Problem