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:
@@ -12950,6 +12950,28 @@
|
||||
"type": "boolean",
|
||||
"description": "Their role must use two-step sign-in"
|
||||
},
|
||||
"twoFactorMethod": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"email",
|
||||
"whatsapp",
|
||||
"authenticator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "How their codes come (2.3.0: authenticator = an app)"
|
||||
},
|
||||
"recoveryCodesLeft": {
|
||||
"type": "integer",
|
||||
"minimum": -9007199254740991,
|
||||
"maximum": 9007199254740991,
|
||||
"description": "Unused recovery codes (0 with two-step sign-in off)"
|
||||
},
|
||||
"newsPromptPending": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -12995,6 +13017,8 @@
|
||||
"homeCampusId",
|
||||
"createdAt",
|
||||
"twoFactorRequired",
|
||||
"twoFactorMethod",
|
||||
"recoveryCodesLeft",
|
||||
"newsPromptPending",
|
||||
"noticePromptPending",
|
||||
"campusScope"
|
||||
@@ -47764,7 +47788,8 @@
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"email",
|
||||
"whatsapp"
|
||||
"whatsapp",
|
||||
"authenticator"
|
||||
]
|
||||
},
|
||||
"destination": {
|
||||
@@ -48395,7 +48420,7 @@
|
||||
"Me"
|
||||
],
|
||||
"summary": "Start turning on two-step sign-in",
|
||||
"description": "Sends a code to confirm with.\n\n**Who:** Any signed-in person.",
|
||||
"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.\n\n**Who:** Any signed-in person.",
|
||||
"operationId": "postMeTwo-factorEnable",
|
||||
"security": [
|
||||
{
|
||||
@@ -48414,7 +48439,8 @@
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"email",
|
||||
"whatsapp"
|
||||
"whatsapp",
|
||||
"authenticator"
|
||||
]
|
||||
},
|
||||
"password": {
|
||||
@@ -48448,12 +48474,27 @@
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"email",
|
||||
"whatsapp"
|
||||
"whatsapp",
|
||||
"authenticator"
|
||||
]
|
||||
},
|
||||
"destination": {
|
||||
"type": "string",
|
||||
"description": "Where the code went, partly hidden"
|
||||
},
|
||||
"secret": {
|
||||
"description": "authenticator: the key to type in by hand",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"otpauthUrl": {
|
||||
"description": "authenticator: show as a QR code",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -48549,11 +48590,107 @@
|
||||
},
|
||||
"twoFactorMethod": {
|
||||
"type": "string"
|
||||
},
|
||||
"recoveryCodes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Shown once: single-use codes for when the app or phone is lost"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"twoFactorEnabled",
|
||||
"twoFactorMethod"
|
||||
"twoFactorMethod",
|
||||
"recoveryCodes"
|
||||
],
|
||||
"additionalProperties": {}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Validation failed (VALIDATION_FAILED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/me/two-factor/recovery-codes": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Me"
|
||||
],
|
||||
"summary": "A new set of recovery codes",
|
||||
"description": "Needs the password. The old codes stop working; the new ones are shown once.\n\n**Who:** Any signed-in person.",
|
||||
"operationId": "postMeTwo-factorRecovery-codes",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"password"
|
||||
],
|
||||
"additionalProperties": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"recoveryCodes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"recoveryCodes"
|
||||
],
|
||||
"additionalProperties": {}
|
||||
}
|
||||
@@ -48975,6 +49112,28 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"twoFactorEnabled": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"twoFactorMethod": {
|
||||
"description": "How their sign-in codes come (2.3.0: authenticator = an app)",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"email",
|
||||
"whatsapp",
|
||||
"authenticator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"homeCampusId": {
|
||||
"type": [
|
||||
"string",
|
||||
@@ -49148,6 +49307,28 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"twoFactorEnabled": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"twoFactorMethod": {
|
||||
"description": "How their sign-in codes come (2.3.0: authenticator = an app)",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"email",
|
||||
"whatsapp",
|
||||
"authenticator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"homeCampusId": {
|
||||
"type": [
|
||||
"string",
|
||||
@@ -49385,6 +49566,28 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"twoFactorEnabled": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"twoFactorMethod": {
|
||||
"description": "How their sign-in codes come (2.3.0: authenticator = an app)",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"email",
|
||||
"whatsapp",
|
||||
"authenticator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"homeCampusId": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
+97
-4
@@ -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;
|
||||
} & {
|
||||
|
||||
@@ -26,7 +26,7 @@ export type AuthResponse = AuthUser & {
|
||||
deviceToken?: string;
|
||||
};
|
||||
|
||||
export type TwoFactorMethod = "email" | "whatsapp";
|
||||
export type TwoFactorMethod = "email" | "whatsapp" | "authenticator";
|
||||
|
||||
// What the login endpoint returns instead of a token when the account has 2FA on:
|
||||
// a code was sent to `destination` (masked) and must be exchanged for the token.
|
||||
@@ -37,6 +37,9 @@ export type TwoFactorChallenge = {
|
||||
destination: string;
|
||||
// The role requires 2FA and it wasn't on yet: verifying this code turns it on.
|
||||
enrolling?: boolean;
|
||||
// 2.3.0, setting up an authenticator app: the key and its otpauth:// link (shown as a QR code).
|
||||
secret?: string;
|
||||
otpauthUrl?: string;
|
||||
};
|
||||
|
||||
export function isTwoFactorChallenge(res: unknown): res is TwoFactorChallenge {
|
||||
|
||||
Reference in New Issue
Block a user