Events 2.3.0 (phase 1c): two-factor with an authenticator app, recovery codes

- TOTP (RFC 6238) next to email and WhatsApp: QR code and key to set up,
  the app's first code confirms it, a code can't be used twice, nothing
  is sent. The secret is stored encrypted.
- 10 single-use recovery codes whenever two-factor is turned on, shown
  once; accepted at sign-in in place of any code; a new set on request.
- Admins see each account's method; Reset 2FA clears the app and codes.
- Profile & Security, sign-in and Users pages; API types; 10 new tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 14:55:22 +02:00
co-authored by Claude Opus 5.5
parent b207d17db8
commit ee65ff358c
18 changed files with 815 additions and 60 deletions
+97 -4
View File
@@ -4787,7 +4787,7 @@ export interface paths {
put?: never;
/**
* Start turning on two-step sign-in
* @description Sends a code to confirm with.
* @description Sends a code to confirm with, or for `authenticator` (2.3.0) answers with `secret` and `otpauthUrl` to show as a QR code; the app's first code confirms it.
*
* **Who:** Any signed-in person.
*/
@@ -4818,6 +4818,28 @@ export interface paths {
patch?: never;
trace?: never;
};
"/me/two-factor/recovery-codes": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/**
* A new set of recovery codes
* @description Needs the password. The old codes stop working; the new ones are shown once.
*
* **Who:** Any signed-in person.
*/
post: operations["postMeTwo-factorRecovery-codes"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/me/two-factor/disable": {
parameters: {
query?: never;
@@ -12787,6 +12809,10 @@ export interface operations {
createdAt: string;
/** @description Their role must use two-step sign-in */
twoFactorRequired: boolean;
/** @description How their codes come (2.3.0: authenticator = an app) */
twoFactorMethod: ("email" | "whatsapp" | "authenticator") | null;
/** @description Unused recovery codes (0 with two-step sign-in off) */
recoveryCodesLeft: number;
newsPromptPending: boolean;
noticePromptPending: false | ("first" | "updated");
campusScope: string[] | null;
@@ -28100,7 +28126,7 @@ export interface operations {
data: {
challengeId: string;
/** @enum {string} */
method: "email" | "whatsapp";
method: "email" | "whatsapp" | "authenticator";
/** @description Where the code went, partly hidden */
destination: string;
} & {
@@ -28472,7 +28498,7 @@ export interface operations {
content: {
"application/json": {
/** @enum {string} */
method: "email" | "whatsapp";
method: "email" | "whatsapp" | "authenticator";
password: string;
} & {
[key: string]: unknown;
@@ -28490,9 +28516,13 @@ export interface operations {
data: {
challengeId: string;
/** @enum {string} */
method: "email" | "whatsapp";
method: "email" | "whatsapp" | "authenticator";
/** @description Where the code went, partly hidden */
destination: string;
/** @description authenticator: the key to type in by hand */
secret?: string | null;
/** @description authenticator: show as a QR code */
otpauthUrl?: string | null;
} & {
[key: string]: unknown;
};
@@ -28548,6 +28578,60 @@ export interface operations {
/** @constant */
twoFactorEnabled: true;
twoFactorMethod: string;
/** @description Shown once: single-use codes for when the app or phone is lost */
recoveryCodes: string[];
} & {
[key: string]: unknown;
};
};
};
};
/** @description Validation failed (VALIDATION_FAILED) */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
/** @description Not signed in (UNAUTHENTICATED) */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Error"];
};
};
};
};
"postMeTwo-factorRecovery-codes": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": {
password: string;
} & {
[key: string]: unknown;
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
data: {
recoveryCodes: string[];
} & {
[key: string]: unknown;
};
@@ -28738,6 +28822,9 @@ export interface operations {
role: "admin" | "supervisor" | "staff" | "user";
isActive?: boolean | null;
notificationPreference?: ("email" | "whatsapp" | "both") | null;
twoFactorEnabled?: boolean | null;
/** @description How their sign-in codes come (2.3.0: authenticator = an app) */
twoFactorMethod?: ("email" | "whatsapp" | "authenticator") | null;
homeCampusId?: string | null;
createdAt?: string | null;
} & {
@@ -28810,6 +28897,9 @@ export interface operations {
role: "admin" | "supervisor" | "staff" | "user";
isActive?: boolean | null;
notificationPreference?: ("email" | "whatsapp" | "both") | null;
twoFactorEnabled?: boolean | null;
/** @description How their sign-in codes come (2.3.0: authenticator = an app) */
twoFactorMethod?: ("email" | "whatsapp" | "authenticator") | null;
homeCampusId?: string | null;
createdAt?: string | null;
/** @description Campuses they're limited to */
@@ -28972,6 +29062,9 @@ export interface operations {
role: "admin" | "supervisor" | "staff" | "user";
isActive?: boolean | null;
notificationPreference?: ("email" | "whatsapp" | "both") | null;
twoFactorEnabled?: boolean | null;
/** @description How their sign-in codes come (2.3.0: authenticator = an app) */
twoFactorMethod?: ("email" | "whatsapp" | "authenticator") | null;
homeCampusId?: string | null;
createdAt?: string | null;
} & {