Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Removing a passkey or the password asks for the same proof as adding one, and a password kept from before proves nothing while password sign-in is off (#95, #118)

Duarte Santos6c0407e1877b
diff --git a/SECURITY.md b/SECURITY.md
index 07d74b141..fe45a1086 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -104,15 +104,20 @@ Read this before hosting openGym for anyone other than yourself.
with no password is checked against a dummy hash, so answer and timing are the same whether or
not it exists. At most two hashes run at once with a short queue behind them. A first password
needs a fresh passkey assertion by that profile, a change needs the current password (or that
- assertion), and either ends every other session of the account. It cannot be removed while it
- is the profile's only way in. Password routes keep the origin check below (no login CSRF).
+ assertion), and either ends every other session of the account. Removing it needs the same
+ proof — the password itself or a fresh assertion — and it cannot be removed while it is the
+ profile's only way in. Password routes keep the origin check below (no login CSRF).
An admin can issue a one-time reset code — 60 random bits, stored as a SHA-256, 24 hours, single
use — which also removes the old password and ends every session; admin accounts cannot be
reset that way (`api/password.js`, the password block in `api/server.js`).
- **More than one passkey, and one-time device codes.** A profile can hold up to 20 passkeys.
- Adding one from Settings, or making the code that lets another device add its own, needs the
- same proof as a first password — a fresh assertion by one of that profile's passkeys, or its
- current password — because each is a way in that outlives "sign out everywhere". The code is
+ Adding one from Settings, removing one, or making the code that lets another device add its
+ own, needs proof that the owner is there right now — a fresh assertion by one of that
+ profile's passkeys, made for that one request, or its current password — because an addition
+ is a way in that outlives "sign out everywhere", and a removal would let a stolen session
+ choose which of the owner's ways in is left. The password counts as proof only while
+ `PASSWORD_LOGIN=1`: with the flag off, a password kept from before is not checked at all, so
+ an old or reused one cannot be guessed into a new passkey. The code is
12 characters (60 bits), shown once, stored as a SHA-256, good for ten minutes and one passkey;
a newer code, signing out everywhere, a new password, an admin reset or a disable voids it. It
never opens a session by itself: redeeming it registers a passkey on that profile (bound to
diff --git a/api/openapi.yaml b/api/openapi.yaml
index bd1a26567..eb7a60fc1 100644
--- a/api/openapi.yaml
+++ b/api/openapi.yaml
@@ -36,10 +36,10 @@ info:
`Retry-After` header. Passkey sign-up and sign-in and the pairing routes are not
throttled. The two routes that redeem a one-time device link (tag `passkeys`) share
the per-address budget, and wrong codes pause the address for link redemption only,
- after 20, the way wrong reset codes do. Adding a passkey in Settings
- (`POST /api/account/passkeys/options`) and making a device code
- (`POST /api/account/device-link`) spend the per-address budget too, and a current
- password given there as proof counts like one given at sign-in.
+ after 20, the way wrong reset codes do. Adding or removing a passkey in Settings
+ (`POST /api/account/passkeys/options`, `DELETE /api/account/passkeys`) and making a
+ device code (`POST /api/account/device-link`) spend the per-address budget too, and a
+ current password given there as proof counts like one given at sign-in.
The address is the socket's, or with `TRUST_PROXY=1` the one a trusted proxy put in
`CF-Connecting-IP` / the last `X-Forwarded-For` entry / `X-Real-IP`; IPv6 clients are
counted by /64. Counters live in memory and reset on restart.
@@ -811,8 +811,20 @@ paths:
summary: Remove this profile's password
description: >-
Refused while the profile has no passkey: the password would be its last way in.
- Existing sessions are left alone (`POST /api/logout/all` ends them). A profile
- without a password gets 200 as well.
+ Otherwise the body carries the same proof setting one takes — `current`, the
+ password itself, or a passkey assertion made for this request (`cid` from
+ `POST /api/login/options`, `credential` signed by one of *this* profile's
+ passkeys). A session alone is never enough: a stolen cookie must not take away
+ the owner's way in where passkeys do not work. The last-way-in refusal comes before
+ the proof is checked, and is checked again after it. Wrong `current` values count
+ toward the same pause as wrong sign-ins. Existing sessions are left alone
+ (`POST /api/logout/all` ends them). A profile without a password gets 200 as well,
+ with no proof asked. Audited as `auth.password.remove`.
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema: { $ref: '#/components/schemas/OwnerProof' }
responses:
'200':
description: Removed (or there was none).
@@ -820,6 +832,7 @@ paths:
application/json:
schema: { $ref: '#/components/schemas/Ok' }
'401': { $ref: '#/components/responses/Unauthorized' }
+ '403': { $ref: '#/components/responses/ProofRefused' }
'409':
description: The password is the profile's only way in.
content:
@@ -827,6 +840,7 @@ paths:
schema: { $ref: '#/components/schemas/Error' }
example: { error: "the password is the only way into this profile", code: "last-way-in" }
'429': { $ref: '#/components/responses/TooManyRequests' }
+ '503': { $ref: '#/components/responses/Busy' }
/api/admin/user/password-reset:
post:
@@ -900,10 +914,14 @@ paths:
summary: Remove one passkey
description: |
Refused while it is the profile's last way in: its only passkey, and no password
- that can sign in (a password counts only while `PASSWORD_LOGIN` is on). No proof is
- asked — removing takes a way in away. Audited as `auth.passkey.remove`. An unused
- device code of the profile is dropped too, so one made with the removed passkey
- cannot add another afterwards.
+ that can sign in (a password counts only while `PASSWORD_LOGIN` is on). Otherwise
+ the body carries the same proof adding one takes (`OwnerProof`): a session alone is
+ never enough, since a stolen cookie could otherwise choose which of the owner's
+ passkeys is left. Any of the profile's passkeys may confirm, the one being removed
+ included. The 404 and 409 refusals come before the proof is checked, and the
+ last-way-in rule is checked again after it. Audited as `auth.passkey.remove`. An
+ unused device code of the profile is dropped too, so one made with the removed
+ passkey cannot add another afterwards.
Sessions are not tied to the passkey that opened them, so a session it already
opened carries on; `POST /api/logout/all` ends those.
@@ -913,6 +931,11 @@ paths:
required: true
description: The passkey's `id` from the list (its WebAuthn credential id).
schema: { type: string }
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema: { $ref: '#/components/schemas/OwnerProof' }
responses:
'200':
description: Removed. The list as it is now.
@@ -925,6 +948,7 @@ paths:
properties:
ok: { type: boolean, const: true }
'401': { $ref: '#/components/responses/Unauthorized' }
+ '403': { $ref: '#/components/responses/ProofRefused' }
'404':
description: No passkey of this profile has that id.
content:
@@ -937,6 +961,8 @@ paths:
application/json:
schema: { $ref: '#/components/schemas/Error' }
example: { error: "this passkey is the only way into this profile", code: "last-way-in" }
+ '429': { $ref: '#/components/responses/TooManyRequests' }
+ '503': { $ref: '#/components/responses/Busy' }
/api/account/passkeys/options:
post:
@@ -948,9 +974,10 @@ paths:
everywhere". The body carries the same proof `POST /api/account/password` takes:
a passkey assertion made for this request (`cid` from `POST /api/login/options`,
`credential` signed by one of *this* profile's passkeys), or `current`, the
- profile's password — accepted even on an instance that has since switched password
- sign-in off, so a password-only profile can move onto a passkey. Wrong passwords
- count toward the sign-in pause.
+ profile's password — only while `PASSWORD_LOGIN` is on. With it off, a password
+ kept from before is not checked at all and the answer is `passkey-required`, so a
+ password-only profile has to move onto a passkey while the flag is still on. Wrong
+ passwords count toward the sign-in pause.
The options use the profile's own user handle and list its passkeys in
`excludeCredentials`, so an authenticator that already holds one refuses. The
@@ -2497,9 +2524,11 @@ components:
ProofRefused:
description: >-
- No acceptable proof that the owner is here: `passkey-required` (no password, so a
- passkey has to confirm), `passkey` (the assertion did not verify or belongs to
- another profile), `current-required` or `current-wrong`.
+ No acceptable proof that the owner is here: `passkey-required` (no password that
+ counts — none is set, or `PASSWORD_LOGIN` is off — so a passkey has to confirm),
+ `passkey` (the assertion did not verify, belongs to another profile, or was made
+ for another challenge, one handed out for another ceremony or one already used),
+ `current-required` or `current-wrong`.
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
@@ -2556,7 +2585,9 @@ components:
transports: { type: array, items: { type: string } }
password:
type: boolean
- description: The profile has a password, so `current` can prove an addition.
+ description: >-
+ The profile has a password and `PASSWORD_LOGIN` is on, so `current` can prove
+ an addition or a removal.
lastWayIn:
type: boolean
description: Removing any one passkey would be refused (409 `last-way-in`).
@@ -2569,7 +2600,8 @@ components:
type: object
description: >-
Either a passkey assertion made for this request (`cid` + `credential`), or the
- profile's current password (`current`).
+ profile's current password (`current`) — which counts only while `PASSWORD_LOGIN`
+ is on. Each assertion is good for one request: its challenge is spent by it.
properties:
cid: { type: string, description: 'From POST /api/login/options.' }
credential: { $ref: '#/components/schemas/WebAuthnAuthenticationCredential' }
diff --git a/api/passkeys-store.js b/api/passkeys-store.js
index cbfe85857..10604b0cf 100644
--- a/api/passkeys-store.js
+++ b/api/passkeys-store.js
@@ -72,14 +72,22 @@ export function renamePasskeyRecord(db, userId, credId, name) {
return { ok: true, row };
}
-// Refused when it would leave the profile with no way in at all: its last passkey goes only while
-// something else (`otherWays`) can still sign it in.
+// Why removing `credId` would be refused, or null when it could go: not this profile's, or its
+// last way in — the last passkey goes only while something else (`otherWays`) can still sign it
+// in. On its own so server.js can ask before it asks the owner for proof, and again, through
+// removePasskeyRecord, once the proof is in.
+export function passkeyRemovalRefused(db, userId, credId, otherWays = 0) {
+ const creds = db.creds || [];
+ if (!creds.some(c => c.id === credId && c.userId === userId)) return { error: 'passkey not found', code: 'not-found' };
+ const mine = creds.filter(c => c.userId === userId).length;
+ if (mine - 1 + otherWays < 1) return { error: 'this passkey is the only way into this profile', code: 'last-way-in' };
+ return null;
+}
+
export function removePasskeyRecord(db, userId, credId, otherWays = 0) {
- db.creds = db.creds || [];
+ const refused = passkeyRemovalRefused(db, userId, credId, otherWays);
+ if (refused) return refused;
const i = db.creds.findIndex(c => c.id === credId && c.userId === userId);
- if (i < 0) return { error: 'passkey not found', code: 'not-found' };
- const mine = db.creds.filter(c => c.userId === userId).length;
- if (mine - 1 + otherWays < 1) return { error: 'this passkey is the only way into this profile', code: 'last-way-in' };
const [row] = db.creds.splice(i, 1);
return { ok: true, row };
}
diff --git a/api/server.js b/api/server.js
index 645ec29fa..a72a0bcb0 100644
--- a/api/server.js
+++ b/api/server.js
@@ -25,7 +25,7 @@ import {
} from './password.js';
import { createBackoff, createWindow } from './rate-limit.js';
import {
- listPasskeys, addPasskeyRecord, renamePasskeyRecord, removePasskeyRecord, MAX_PASSKEYS
+ listPasskeys, addPasskeyRecord, renamePasskeyRecord, removePasskeyRecord, passkeyRemovalRefused, MAX_PASSKEYS
} from './passkeys-store.js';
import { createDeviceLink, findDeviceLink, burnDeviceLink, dropDeviceLinks } from './device-link.js';
@@ -791,10 +791,11 @@ const THROTTLED = {
'POST /api/login/password': 'password', 'POST /api/login/password-reset': 'password',
'POST /api/register/password': 'signup',
'POST /api/account/password': 'password', 'DELETE /api/account/password': null,
- // Redeeming a device link (#95). Adding a passkey and making a link only spend the budget: the
- // password that may prove them counts its own failures (passwordAttempt).
+ // Redeeming a device link (#95). Adding or removing a passkey and making a link only spend the
+ // budget: the password that may prove them counts its own failures (passwordAttempt).
'POST /api/device-link/options': 'link', 'POST /api/device-link/verify': 'link',
- 'POST /api/account/passkeys/options': null, 'POST /api/account/device-link': null
+ 'POST /api/account/passkeys/options': null, 'POST /api/account/device-link': null,
+ 'DELETE /api/account/passkeys': null
};
// Which address the throttle counts against. Unlike clientIp() above, which only labels a log
@@ -854,6 +855,10 @@ function strikeAddress(req, kind) {
// redeem — there is no rename — and leave that profile locked out. Sign-in itself only ever
// looks at profiles that have a password (passwordHolder).
const hasPassword = u => !!(u && u.pw && typeof u.pw.h === 'string');
+// A password that counts for anything: one the instance still lets people sign in with. With
+// PASSWORD_LOGIN off, a password kept from when it was on neither signs in nor proves anything
+// (proveOwner), and does not keep a profile's last passkey in place.
+const passwordWayIn = u => PASSWORD_LOGIN && hasPassword(u);
const passwordHolder = k => db.users.find(u => hasPassword(u) && nameKey(u.name) === k) || null;
const holdsName = u => hasPassword(u) || !!(u.pwReset && u.pwReset.exp > Date.now());
const nameTaken = (name, exceptId) => {
@@ -938,14 +943,21 @@ function passwordAttempt(req, res, k) {
}
// Proof that whoever holds this session is the account's owner right now, for the changes that
-// add a lasting way in — a password, another passkey, a device link. A session on its own is not
-// enough for those: it may be a cookie someone walked off with, and each of them would outlive
-// "sign out everywhere". Either a passkey assertion made for this request (`cid` from
-// /api/login/options, `credential` signed by one of this account's passkeys), or the current
-// password when there is one. The password counts here even on an instance that has since
-// switched password sign-in off: it is still the owner's secret, and it is how a profile that only
-// ever had a password gets onto a passkey. Answers the refusal itself and returns null, or says
-// which proof it was ('passkey' | 'password'). Wrong passwords count toward the sign-in pause.
+// add or take away a lasting way in — setting a password, adding a passkey, making a device link,
+// removing a passkey or the password. A session on its own is not enough for those: it may be a
+// cookie someone walked off with. An addition would outlive "sign out everywhere"; a removal
+// would let whoever holds the cookie choose which of the owner's ways in is left — an old
+// security key rather than the phone the owner carries — or take away the password that signs
+// them in where passkeys do not work.
+//
+// Either a passkey assertion made for this request (`cid` from /api/login/options, `credential`
+// signed by one of this account's passkeys), or the current password — only while the instance
+// offers password sign-in. With PASSWORD_LOGIN off, a password kept from when it was on is a
+// secret nothing else checks any more, possibly an old or reused one, so it proves nothing either:
+// a stolen cookie and a guessed password must not add a passkey on an instance that switched
+// passwords off. A profile that only ever had a password is moved onto a passkey while the flag
+// is still on (docs/SELF_HOSTING.md). Answers the refusal itself and returns null, or says which
+// proof it was ('passkey' | 'password'). Wrong passwords count toward the sign-in pause.
async function proveOwner(req, res, user, body, failEv) {
if (body.credential) {
if (await passkeyStepUp(user, body)) return 'passkey';
@@ -953,7 +965,7 @@ async function proveOwner(req, res, user, body, failEv) {
json(res, 403, { error: 'the passkey could not be verified', code: 'passkey' });
return null;
}
- if (!hasPassword(user)) {
+ if (!passwordWayIn(user)) {
json(res, 403, { error: 'confirm with your passkey first', code: 'passkey-required' });
return null;
}
@@ -1099,12 +1111,25 @@ const passwordRoutes = {
},
// Never the last way in: a profile with no passkey keeps its password, because nothing else
- // could sign it in again. Existing sessions are left alone; "sign out everywhere" ends them.
+ // could sign it in again. Same proof as setting one (proveOwner) — the password itself, or a
+ // passkey assertion made for this request — asked only once the removal could go ahead, so a
+ // refusal the profile's state already decides spends no passkey prompt and no password check.
+ // Existing sessions are left alone; "sign out everywhere" ends them.
'DELETE /api/account/password': async (req, res) => {
const user = readSession(req);
if (!user) return json(res, 401, { error: 'not signed in' });
+ const body = await readBody(req);
+ const lastWayIn = () => json(res, 409, { error: 'the password is the only way into this profile', code: 'last-way-in' });
+ if (!hasPassword(user)) return json(res, 200, { ok: true });
+ if (!passkeyCount(user)) return lastWayIn();
+ const proof = await proveOwner(req, res, user, body, 'auth.password.fail');
+ if (!proof) return;
+ // Everything above awaited: the session may have ended, and the profile's last passkey may
+ // have been removed by a request that ran alongside this one.
+ if (readSession(req) !== user) return json(res, 401, { error: 'not signed in' });
+ if (proof === 'passkey') saveDb(); // the confirming passkey's counter and last use
if (!hasPassword(user)) return json(res, 200, { ok: true });
- if (!passkeyCount(user)) return json(res, 409, { error: 'the password is the only way into this profile', code: 'last-way-in' });
+ if (!passkeyCount(user)) return lastWayIn();
delete user.pw;
saveDb();
audit(req, 'auth.password.remove', { user });
@@ -1189,18 +1214,18 @@ const passwordRoutes = {
// in Settings where the owner sees it and can remove it.
//
// Either way the new passkey is a way into the profile that outlives "sign out everywhere", so
-// both ask for the proof a first password does (proveOwner). Removing one never leaves a profile
-// without a way in: its last passkey stays unless a password can sign in instead.
+// both ask for the proof a first password does (proveOwner). So does removing one: a stolen
+// cookie must not choose which of the owner's passkeys is left. Removing one never leaves a
+// profile without a way in: its last passkey stays unless a password can sign in instead.
//
// Sessions are not tied to the passkey that opened them — a session is `uid:expiry:version`,
// nothing more — so removing a passkey stops it signing in again but does not end a session it
// already opened. "Sign out everywhere" does that, and Settings says so where a passkey is removed.
-const passwordWayIn = u => PASSWORD_LOGIN && hasPassword(u);
const passkeyState = u => {
const passkeys = listPasskeys(db, u.id);
- // `password`: whether a password can confirm an addition (proveOwner). `lastWayIn`: whether
- // removing any one passkey would be refused.
- return { passkeys, password: hasPassword(u), lastWayIn: passkeys.length + (passwordWayIn(u) ? 1 : 0) <= 1 };
+ // `password`: whether the password can confirm an addition or a removal (proveOwner) — only
+ // while password sign-in is on. `lastWayIn`: whether removing any one passkey would be refused.
+ return { passkeys, password: passwordWayIn(u), lastWayIn: passkeys.length + (passwordWayIn(u) ? 1 : 0) <= 1 };
};
const LIMIT = { error: `a profile can have at most ${MAX_PASSKEYS} passkeys`, code: 'passkey-limit' };
const LINK_INVALID = { error: 'that code is wrong, used or expired', code: 'link-invalid' };
@@ -1305,16 +1330,27 @@ const passkeyRoutes = {
json(res, 200, { ok: true, ...passkeyState(user) });
},
- // `?id=` — the credential id from the list. No proof: removing takes a way in away rather than
- // adding one, and the last one is never removed (removePasskeyRecord). An unused device code
- // goes with it: a passkey is removed because it is lost or not trusted, and a code made with it
- // just before — by whoever holds it — would otherwise add a fresh one right after.
+ // `?id=` — the credential id from the list; the body carries the same proof adding one takes
+ // (proveOwner), asked only once the removal could go ahead, so a refusal the list already
+ // decides spends no passkey prompt and no password check. The last one is never removed
+ // (removePasskeyRecord), checked again after the proof, since a request running alongside may
+ // have removed another passkey or the password meanwhile. An unused device code goes with it: a
+ // passkey is removed because it is lost or not trusted, and a code made with it just before — by
+ // whoever holds it — would otherwise add a fresh one right after.
'DELETE /api/account/passkeys': async (req, res) => {
const user = readSession(req);
if (!user) return notSignedIn(res);
const id = new URL(req.url, 'http://x').searchParams.get('id') || '';
+ const body = await readBody(req);
+ const refuse = r => json(res, r.code === 'last-way-in' ? 409 : 404, { error: r.error, code: r.code });
+ const refused = passkeyRemovalRefused(db, user.id, id, passwordWayIn(user) ? 1 : 0);
+ if (refused) return refuse(refused);
+ const proof = await proveOwner(req, res, user, body, 'auth.passkey.fail');
+ if (!proof) return;
+ if (readSession(req) !== user) return notSignedIn(res);
+ if (proof === 'passkey') saveDb(); // the confirming passkey's counter and last use
const r = removePasskeyRecord(db, user.id, id, passwordWayIn(user) ? 1 : 0);
- if (r.error) return json(res, r.code === 'last-way-in' ? 409 : 404, { error: r.error, code: r.code });
+ if (r.error) return refuse(r);
dropDeviceLinks(db, user.id);
saveDb();
audit(req, 'auth.passkey.remove', { user, msg: r.row.name || null });
diff --git a/api/test/passkeys-store.test.js b/api/test/passkeys-store.test.js
index 7c51154b9..854f15a62 100644
--- a/api/test/passkeys-store.test.js
+++ b/api/test/passkeys-store.test.js
@@ -3,7 +3,7 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import {
- addPasskeyRecord, listPasskeys, removePasskeyRecord, renamePasskeyRecord, passkeyName, MAX_PASSKEYS
+ addPasskeyRecord, listPasskeys, removePasskeyRecord, passkeyRemovalRefused, renamePasskeyRecord, passkeyName, MAX_PASSKEYS
} from '../passkeys-store.js';
const cred = (id, userId = 'u1') => ({
@@ -119,3 +119,17 @@ describe('removePasskeyRecord', () => {
assert.equal(db.creds.length, 2);
});
});
+
+describe('passkeyRemovalRefused', () => {
+ // Asked before the route asks the owner for proof, so it must answer as the removal would —
+ // and change nothing.
+ it('answers what removePasskeyRecord would, without removing anything', () => {
+ const db = { creds: [cred('hello', 'u1'), cred('phone', 'u1'), cred('other', 'u2')] };
+ assert.equal(passkeyRemovalRefused(db, 'u1', 'hello'), null);
+ assert.deepEqual(passkeyRemovalRefused(db, 'u1', 'other'), { error: 'passkey not found', code: 'not-found' });
+ assert.deepEqual(passkeyRemovalRefused(db, 'u2', 'other'), { error: 'this passkey is the only way into this profile', code: 'last-way-in' });
+ assert.equal(passkeyRemovalRefused(db, 'u2', 'other', 1), null);
+ assert.equal(passkeyRemovalRefused({}, 'u1', 'hello').code, 'not-found');
+ assert.equal(db.creds.length, 3);
+ });
+});
diff --git a/api/test/server-passkeys.test.js b/api/test/server-passkeys.test.js
index e633225ee..d6170111a 100644
--- a/api/test/server-passkeys.test.js
+++ b/api/test/server-passkeys.test.js
@@ -1,10 +1,11 @@
/* More than one passkey per profile, and one-time device links (#95): the routes, the proof they
- ask for, the last-way-in rule, the throttle in front of link redemption and the audit trail.
+ ask for — to add a passkey and to remove one — the last-way-in rule, the throttle in front of
+ link redemption and the audit trail.
Real server.js in a child, the same harness as server-password.test.js; every test talks from
its own X-Forwarded-For address (TRUST_PROXY=1), so one test's failures never pause another's.
The authenticator is software: a P-256 key that makes attestations ("none") and assertions the
way a browser's would. */
-import { test } from 'node:test';
+import { test, before } from 'node:test';
import assert from 'node:assert/strict';
import crypto from 'node:crypto';
import fs from 'node:fs';
@@ -76,6 +77,9 @@ function softPasskey() {
const GOOD = 'correct horse battery staple';
let pwHash;
+// Made before any test runs: withPassword() reads it while a test's arguments to startServer are
+// still being built, so a test run on its own would otherwise give its user no hash at all.
+before(async () => { pwHash ??= await hashPassword(GOOD); });
async function startServer(t, { env = {}, users = [], creds = [], deviceLinks } = {}) {
pwHash ??= await hashPassword(GOOD);
@@ -213,24 +217,53 @@ test('signing out everywhere between the proof and the new passkey ends the cere
assert.equal(h.db().creds.length, 1);
});
-test('the current password proves an addition too — also after the instance switched password sign-in off', async t => {
- for (const flag of ['1', '']) {
- const fresh = softPasskey();
- const h = await startServer(t, { env: { PASSWORD_LOGIN: flag }, users: [withPassword('u1', 'Ana')] });
- const ip = flag ? '198.51.100.23' : '198.51.100.24', cookie = mintSession('u1');
- const missing = await h.req('POST', '/api/account/passkeys/options', { body: {}, cookie, ip });
- assert.equal(missing.body.code, 'current-required');
- const wrong = await h.req('POST', '/api/account/passkeys/options', { body: { current: 'not it at all' }, cookie, ip });
- assert.equal(wrong.status, 403);
- assert.equal(wrong.body.code, 'current-wrong');
- assert.ok(h.audit().some(e => e.ev === 'auth.password.fail' && e.msg === 'bad-current'));
- const opt = await h.req('POST', '/api/account/passkeys/options', { body: { current: GOOD }, cookie, ip });
- assert.equal(opt.status, 200, flag);
- assert.deepEqual(opt.body.options.excludeCredentials, []);
- const ver = await h.req('POST', '/api/account/passkeys/verify', { body: { cid: opt.body.cid, credential: fresh.attestation(opt.body.options.challenge) }, cookie, ip });
- assert.equal(ver.status, 200);
- assert.ok(h.audit().some(e => e.ev === 'auth.passkey.add' && e.msg === 'password'));
+test('the current password proves an addition while the instance offers password sign-in', async t => {
+ const fresh = softPasskey();
+ const h = await startServer(t, { users: [withPassword('u1', 'Ana')] });
+ const ip = '198.51.100.23', cookie = mintSession('u1');
+ assert.equal((await h.req('GET', '/api/account/passkeys', { cookie, ip })).body.password, true);
+ const missing = await h.req('POST', '/api/account/passkeys/options', { body: {}, cookie, ip });
+ assert.equal(missing.body.code, 'current-required');
+ const wrong = await h.req('POST', '/api/account/passkeys/options', { body: { current: 'not it at all' }, cookie, ip });
+ assert.equal(wrong.status, 403);
+ assert.equal(wrong.body.code, 'current-wrong');
+ assert.ok(h.audit().some(e => e.ev === 'auth.password.fail' && e.msg === 'bad-current'));
+ const opt = await h.req('POST', '/api/account/passkeys/options', { body: { current: GOOD }, cookie, ip });
+ assert.equal(opt.status, 200);
+ assert.deepEqual(opt.body.options.excludeCredentials, []);
+ const ver = await h.req('POST', '/api/account/passkeys/verify', { body: { cid: opt.body.cid, credential: fresh.attestation(opt.body.options.challenge) }, cookie, ip });
+ assert.equal(ver.status, 200);
+ assert.ok(h.audit().some(e => e.ev === 'auth.passkey.add' && e.msg === 'password'));
+});
+
+// A password kept from when the flag was on is a secret nothing checks any more — possibly an old
+// or reused one. With the flag off it proves nothing, is never even compared (so wrong guesses are
+// neither answered differently nor counted), and the list does not offer it; a passkey still does.
+test('with PASSWORD_LOGIN off only a passkey proves anything; a stored password is ignored', async t => {
+ const key = softPasskey(), other = softPasskey();
+ const h = await startServer(t, { env: { PASSWORD_LOGIN: '' }, users: [withPassword('u1', 'Ana'), withPassword('u2', 'Bea')], creds: [key.row('u1'), other.row('u1')] });
+ const ip = '198.51.100.24', cookie = mintSession('u1');
+ assert.equal((await h.req('GET', '/api/account/passkeys', { cookie, ip })).body.password, false);
+ for (let i = 0; i < 7; i++) {
+ for (const [method, p] of [['POST', '/api/account/passkeys/options'], ['POST', '/api/account/device-link'], ['DELETE', '/api/account/passkeys?id=' + encodeURIComponent(other.id)]]) {
+ for (const current of [GOOD, 'not it at all ' + i]) {
+ const r = await h.req(method, p, { body: { current }, cookie, ip });
+ assert.equal(r.status, 403, `${method} ${p}`);
+ assert.equal(r.body.code, 'passkey-required', `${method} ${p}`);
+ }
+ }
}
+ assert.ok(!h.audit().some(e => e.ev === 'auth.password.fail' || e.ev === 'auth.password.locked'));
+ assert.equal(h.db().creds.length, 2);
+ assert.deepEqual(h.db().deviceLinks || [], []);
+ // A profile with only a password cannot confirm anything at all.
+ assert.equal((await h.req('POST', '/api/account/passkeys/options', { body: { current: GOOD }, cookie: mintSession('u2'), ip })).body.code, 'passkey-required');
+ // The passkey does, for all three.
+ assert.equal((await h.req('POST', '/api/account/passkeys/options', { body: await h.stepUp(key, ip), cookie, ip })).status, 200);
+ assert.equal((await h.req('POST', '/api/account/device-link', { body: await h.stepUp(key, ip), cookie, ip })).status, 200);
+ const removed = await h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(other.id), { body: await h.stepUp(key, ip), cookie, ip });
+ assert.equal(removed.status, 200);
+ assert.deepEqual(removed.body.passkeys.map(p => p.id), [key.id]);
});
test('wrong current passwords on the way to a passkey count toward the sign-in pause', async t => {
@@ -269,15 +302,16 @@ test('renaming touches only the caller’s own passkey', async t => {
test('removing: never the last way in, never someone else’s, audited, and it stops that passkey signing in', async t => {
const a = softPasskey(), b = softPasskey(), bea = softPasskey();
const h = await startServer(t, { users: [user('u1', 'Ana'), user('u2', 'Bea')], creds: [a.row('u1', { name: 'Old phone' }), b.row('u1'), bea.row('u2')] });
- const cookie = mintSession('u1');
- const del = id => h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(id), { cookie });
- assert.equal((await del(bea.id)).status, 404);
- const first = await del(a.id);
+ const ip = '198.51.100.29', cookie = mintSession('u1');
+ const del = async (id, proof) => h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(id), { body: await h.stepUp(proof, ip), cookie, ip });
+ assert.equal((await del(bea.id, a)).status, 404);
+ // A passkey may confirm its own removal: whoever uses it holds it.
+ const first = await del(a.id, a);
assert.equal(first.status, 200);
assert.deepEqual(first.body.passkeys.map(p => p.id), [b.id]);
assert.equal(first.body.lastWayIn, true);
assert.ok(h.audit().some(e => e.ev === 'auth.passkey.remove' && e.uid === 'u1' && e.msg === 'Old phone'));
- const last = await del(b.id);
+ const last = await del(b.id, b);
assert.equal(last.status, 409);
assert.equal(last.body.code, 'last-way-in');
assert.equal(h.db().creds.filter(c => c.userId === 'u1').length, 1);
@@ -288,13 +322,123 @@ test('removing: never the last way in, never someone else’s, audited, and it s
assert.equal((await h.req('GET', '/api/me', { cookie })).status, 200);
});
+// A stolen cookie must not choose which of the owner's ways in is left, so removing takes the
+// proof adding does. Every refusal below leaves both passkeys in place.
+test('removing a passkey needs proof made for it: none, another profile’s passkey, another ceremony’s challenge or a spent one remove nothing', async t => {
+ const a = softPasskey(), b = softPasskey(), bea = softPasskey();
+ const h = await startServer(t, { users: [user('u1', 'Ana'), user('u2', 'Bea')], creds: [a.row('u1'), b.row('u1'), bea.row('u2')] });
+ const ip = '198.51.100.30', cookie = mintSession('u1');
+ const url = '/api/account/passkeys?id=' + encodeURIComponent(a.id);
+ const refused = async (body, code) => {
+ const r = await h.req('DELETE', url, { body, cookie, ip });
+ assert.equal(r.status, 403, JSON.stringify(body)?.slice(0, 60));
+ assert.equal(r.body.code, code);
+ assert.deepEqual(h.db().creds.filter(c => c.userId === 'u1').map(c => c.id), [a.id, b.id]);
+ };
+ // A session on its own — with no body at all, or an empty one.
+ await refused(undefined, 'passkey-required');
+ await refused({}, 'passkey-required');
+ // A password where the profile has none.
+ await refused({ current: GOOD }, 'passkey-required');
+ // Bea's passkey says nothing about Ana.
+ await refused(await h.stepUp(bea, ip), 'passkey');
+ assert.ok(h.audit().some(e => e.ev === 'auth.passkey.fail' && e.uid === 'u1' && e.msg === 'step-up-failed'));
+ // Challenges handed out for another ceremony, signed as if they were a sign-in's: adding a
+ // passkey in Settings, a sign-up, redeeming a device link.
+ const add = (await h.req('POST', '/api/account/passkeys/options', { body: await h.stepUp(b, ip), cookie, ip })).body;
+ await refused({ cid: add.cid, credential: b.assertion(add.options.challenge) }, 'passkey');
+ const reg = (await h.req('POST', '/api/register/options', { body: { name: 'Mallory' }, ip })).body;
+ await refused({ cid: reg.cid, credential: b.assertion(reg.options.challenge) }, 'passkey');
+ const { code } = (await h.req('POST', '/api/account/device-link', { body: await h.stepUp(b, ip), cookie, ip })).body;
+ const link = (await h.req('POST', '/api/device-link/options', { body: { code }, ip })).body;
+ await refused({ cid: link.cid, credential: b.assertion(link.options.challenge) }, 'passkey');
+ // A sign-in challenge signed for another one, and one that finished a sign-in already.
+ const lo1 = (await h.req('POST', '/api/login/options', { body: {}, ip })).body;
+ const lo2 = (await h.req('POST', '/api/login/options', { body: {}, ip })).body;
+ await refused({ cid: lo1.cid, credential: b.assertion(lo2.options.challenge) }, 'passkey');
+ const signedIn = await h.req('POST', '/api/login/verify', { body: { cid: lo2.cid, credential: b.assertion(lo2.options.challenge) }, ip });
+ assert.equal(signedIn.status, 200);
+ await refused({ cid: lo2.cid, credential: b.assertion(lo2.options.challenge) }, 'passkey');
+ // A proof works once: the one that removed a passkey removes nothing else afterwards.
+ const proof = await h.stepUp(b, ip);
+ assert.equal((await h.req('DELETE', url, { body: proof, cookie, ip })).status, 200);
+ const again = await h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(b.id), { body: proof, cookie, ip });
+ assert.equal(again.status, 409); // b is the last way in now, which is answered before any proof
+ assert.deepEqual(h.db().creds.filter(c => c.userId === 'u1').map(c => c.id), [b.id]);
+ assert.equal(h.audit().filter(e => e.ev === 'auth.passkey.remove').length, 1);
+});
+
+test('a proof is spent by the removal it was made for, and a replayed one removes nothing', async t => {
+ const a = softPasskey(), b = softPasskey(), c = softPasskey();
+ const h = await startServer(t, { users: [user('u1', 'Ana')], creds: [a.row('u1'), b.row('u1'), c.row('u1')] });
+ const ip = '198.51.100.31', cookie = mintSession('u1');
+ const proof = await h.stepUp(c, ip);
+ assert.equal((await h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(a.id), { body: proof, cookie, ip })).status, 200);
+ const replay = await h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(b.id), { body: proof, cookie, ip });
+ assert.equal(replay.status, 403);
+ assert.equal(replay.body.code, 'passkey');
+ assert.deepEqual(h.db().creds.map(x => x.id), [b.id, c.id]);
+ // The confirming passkey's use is recorded like any other.
+ assert.ok(h.db().creds.find(x => x.id === c.id).lastUsed);
+});
+
+test('wrong current passwords given to remove a passkey count toward the sign-in pause, and are audited as such', async t => {
+ const key = softPasskey(), other = softPasskey();
+ const h = await startServer(t, { users: [withPassword('u1', 'Ana')], creds: [key.row('u1'), other.row('u1')] });
+ const ip = '198.51.100.32', cookie = mintSession('u1');
+ const url = '/api/account/passkeys?id=' + encodeURIComponent(other.id);
+ assert.equal((await h.req('DELETE', url, { body: {}, cookie, ip })).body.code, 'current-required');
+ const answers = [];
+ for (let i = 0; i < 7; i++) answers.push(await h.req('DELETE', url, { body: { current: 'wrong password ' + i }, cookie, ip }));
+ assert.deepEqual(answers.map(r => r.status), [403, 403, 403, 403, 403, 403, 429]);
+ assert.equal(answers[0].body.code, 'current-wrong');
+ assert.ok(h.audit().some(e => e.ev === 'auth.password.fail' && e.uid === 'u1' && e.msg === 'bad-current'));
+ assert.ok(h.audit().some(e => e.ev === 'auth.password.locked' && e.uid === 'u1'));
+ // The name is paused: the right password waits too, from anywhere, and so does a sign-in.
+ assert.equal((await h.req('DELETE', url, { body: { current: GOOD }, cookie, ip: '198.51.100.33' })).status, 429);
+ assert.equal((await h.req('POST', '/api/login/password', { body: { name: 'Ana', password: GOOD }, ip: '198.51.100.33' })).status, 429);
+ assert.equal(h.db().creds.length, 2);
+ // A passkey is never paused by it.
+ assert.equal((await h.req('DELETE', url, { body: await h.stepUp(key, ip), cookie, ip })).status, 200);
+});
+
+test('the current password proves a removal too, while password sign-in is on', async t => {
+ const key = softPasskey(), other = softPasskey();
+ const h = await startServer(t, { users: [withPassword('u1', 'Ana')], creds: [key.row('u1'), other.row('u1', { name: 'Tablet' })] });
+ const ip = '198.51.100.34', cookie = mintSession('u1');
+ const r = await h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(other.id), { body: { current: GOOD }, cookie, ip });
+ assert.equal(r.status, 200);
+ assert.deepEqual(r.body.passkeys.map(p => p.id), [key.id]);
+ assert.ok(h.audit().some(e => e.ev === 'auth.passkey.remove' && e.msg === 'Tablet'));
+});
+
+// Both of a profile's two ways in removed at once, each request with its own good proof: the
+// checks before the proof pass for both, so the one that finishes second has to find out after
+// its proof that it would now leave the profile with no way in.
+test('removing the password and the last passkey at the same time leaves one of them', async t => {
+ const key = softPasskey();
+ const h = await startServer(t, { users: [withPassword('u1', 'Ana')], creds: [key.row('u1')] });
+ const ip = '198.51.100.35', cookie = mintSession('u1');
+ const [pw, pk] = await Promise.all([
+ // The password's proof runs scrypt, so the passkey removal overtakes it.
+ h.req('DELETE', '/api/account/password', { body: { current: GOOD }, cookie, ip }),
+ (async () => h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(key.id), { body: await h.stepUp(key, ip), cookie, ip }))()
+ ]);
+ assert.deepEqual([pw.status, pk.status].filter(s => s === 200).length, 1, `${pw.status} ${JSON.stringify(pw.body)} / ${pk.status} ${JSON.stringify(pk.body)}`);
+ assert.ok([403, 409].includes(pw.status === 200 ? pk.status : pw.status));
+ const u = h.db().users[0];
+ assert.equal(h.db().creds.length + (u.pw ? 1 : 0), 1, 'the profile kept exactly one way in');
+});
+
test('a password is a way in only while the instance offers password sign-in', async t => {
for (const [flag, status] of [['1', 200], ['', 409]]) {
const key = softPasskey();
const h = await startServer(t, { env: { PASSWORD_LOGIN: flag }, users: [withPassword('u1', 'Ana')], creds: [key.row('u1')] });
- const list = await h.req('GET', '/api/account/passkeys', { cookie: mintSession('u1') });
+ const ip = flag ? '198.51.100.36' : '198.51.100.37';
+ const list = await h.req('GET', '/api/account/passkeys', { cookie: mintSession('u1'), ip });
assert.equal(list.body.lastWayIn, !flag);
- const r = await h.req('DELETE', '/api/account/passkeys?id=' + key.id, { cookie: mintSession('u1') });
+ assert.equal(list.body.password, !!flag);
+ const r = await h.req('DELETE', '/api/account/passkeys?id=' + key.id, { body: await h.stepUp(key, ip), cookie: mintSession('u1'), ip });
assert.equal(r.status, status, `PASSWORD_LOGIN=${flag}`);
}
});
@@ -303,12 +447,14 @@ test('a password-only profile keeps its password until a passkey is added, and t
const fresh = softPasskey();
const h = await startServer(t, { users: [withPassword('u1', 'Ana')] });
const ip = '198.51.100.28', cookie = mintSession('u1');
- assert.equal((await h.req('DELETE', '/api/account/password', { cookie, ip })).body.code, 'last-way-in');
+ // Refused before any proof is asked for: the answer would be the same with one.
+ assert.equal((await h.req('DELETE', '/api/account/password', { body: {}, cookie, ip })).body.code, 'last-way-in');
const opt = await h.req('POST', '/api/account/passkeys/options', { body: { current: GOOD }, cookie, ip });
await h.req('POST', '/api/account/passkeys/verify', { body: { cid: opt.body.cid, credential: fresh.attestation(opt.body.options.challenge) }, cookie, ip });
- assert.equal((await h.req('DELETE', '/api/account/password', { cookie, ip })).status, 200);
+ assert.equal((await h.req('DELETE', '/api/account/password', { body: {}, cookie, ip })).body.code, 'current-required');
+ assert.equal((await h.req('DELETE', '/api/account/password', { body: { current: GOOD }, cookie, ip })).status, 200);
// And now the passkey is the last way in.
- assert.equal((await h.req('DELETE', '/api/account/passkeys?id=' + fresh.id, { cookie, ip })).body.code, 'last-way-in');
+ assert.equal((await h.req('DELETE', '/api/account/passkeys?id=' + fresh.id, { body: await h.stepUp(fresh, ip), cookie, ip })).body.code, 'last-way-in');
});
/* ------------------------------------------------------------------ device links ---------- */
@@ -406,7 +552,7 @@ test('removing a passkey drops an unused code, so one made with it just before a
const { code } = (await makeLink(h, stolen, 'u1', ip)).body;
assert.equal(h.db().deviceLinks.length, 1);
// …the owner removes that passkey…
- assert.equal((await h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(stolen.id), { cookie: mintSession('u1'), ip })).status, 200);
+ assert.equal((await h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(stolen.id), { body: await h.stepUp(key, ip), cookie: mintSession('u1'), ip })).status, 200);
assert.deepEqual(h.db().deviceLinks, []);
// …and the code no longer adds a new one.
const r = await redeem(h, code, thief, '203.0.113.54');
@@ -415,7 +561,7 @@ test('removing a passkey drops an unused code, so one made with it just before a
assert.deepEqual(h.db().creds.map(c => c.id), [key.id]);
// A refused removal leaves the owner's own code alone.
const mine = (await makeLink(h, key, 'u1', ip)).body.code;
- assert.equal((await h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(key.id), { cookie: mintSession('u1'), ip })).status, 409);
+ assert.equal((await h.req('DELETE', '/api/account/passkeys?id=' + encodeURIComponent(key.id), { body: await h.stepUp(key, ip), cookie: mintSession('u1'), ip })).status, 409);
assert.equal((await h.req('POST', '/api/device-link/options', { body: { code: mine }, ip })).status, 200);
});
diff --git a/api/test/server-password.test.js b/api/test/server-password.test.js
index 0039d8b9a..e32d317e0 100644
--- a/api/test/server-password.test.js
+++ b/api/test/server-password.test.js
@@ -2,7 +2,7 @@
rules that make a second way into an account safe to offer. Real server.js in a child, the
same harness as server-pairing.test.js. Every test talks from its own X-Forwarded-For address
(TRUST_PROXY=1), so one test's failures never pause another's. */
-import { test } from 'node:test';
+import { test, before } from 'node:test';
import assert from 'node:assert/strict';
import crypto from 'node:crypto';
import http from 'node:http';
@@ -54,6 +54,9 @@ function softPasskey() {
const GOOD = 'correct horse battery staple';
let pwHash; // one real hash of GOOD, made once — every user below that "has a password" shares it
let oldHash; // GOOD at N = 2^14, as an instance with older parameters would have stored it
+// Made before any test runs: withPassword() reads it while a test's arguments to startServer are
+// still being built, so a test run on its own would otherwise give its user no hash at all.
+before(async () => { pwHash ??= await hashPassword(GOOD); });
// A hash in password.js's own format at a cost other than today's, so a sign-in rehashes it.
const hashAt = (pw, ln) => new Promise((resolve, reject) => {
@@ -421,14 +424,77 @@ test('the last way in is never removed', async t => {
const key = softPasskey();
const h = await startServer(t, { users: [withPassword('u1', 'Ana'), withPassword('u2', 'Bea')], creds: [key.row('u2')] });
const ip = '198.51.100.130';
- const only = await h.req('DELETE', '/api/account/password', { cookie: `gymsid=${mintSession('u1')}`, ip });
+ // Refused before any proof is asked for: with the right password the answer is the same.
+ const only = await h.req('DELETE', '/api/account/password', { body: { current: GOOD }, cookie: `gymsid=${mintSession('u1')}`, ip });
assert.equal(only.status, 409);
assert.equal(only.body.code, 'last-way-in');
assert.equal((await login(h, 'Ana', GOOD, ip)).status, 200);
- const both = await h.req('DELETE', '/api/account/password', { cookie: `gymsid=${mintSession('u2')}`, ip });
+ const both = await h.req('DELETE', '/api/account/password', { body: { current: GOOD }, cookie: `gymsid=${mintSession('u2')}`, ip });
assert.equal(both.status, 200);
assert.equal((await login(h, 'Bea', GOOD, ip)).status, 401);
assert.equal(h.db().users.find(u => u.id === 'u2').pw, undefined);
+ assert.ok(h.audit().some(e => e.ev === 'auth.password.remove' && e.uid === 'u2'));
+ // Nothing left to remove: the same answer, no proof needed.
+ assert.equal((await h.req('DELETE', '/api/account/password', { body: {}, cookie: `gymsid=${mintSession('u2')}`, ip })).status, 200);
+});
+
+// A stolen cookie must not take away the password that signs the owner in where passkeys do not
+// work, so removing it takes the proof setting one does. Every refusal below leaves it working.
+test('removing the password needs proof made for it: the password itself or a passkey assertion, nothing less', async t => {
+ const key = softPasskey(), other = softPasskey();
+ const h = await startServer(t, { users: [withPassword('u1', 'Ana'), user('u2', 'Bea')], creds: [key.row('u1'), other.row('u2')] });
+ const cookie = `gymsid=${mintSession('u1')}`;
+ const ip = '198.51.100.131';
+ const stepUp = async (pk, challenge) => {
+ const { cid, options } = (await h.req('POST', '/api/login/options', { body: {}, ip })).body;
+ return { cid, credential: pk.assertion(challenge ?? options.challenge) };
+ };
+ const refused = async (body, code) => {
+ const r = await h.req('DELETE', '/api/account/password', { body, cookie, ip });
+ assert.equal(r.status, 403, JSON.stringify(body)?.slice(0, 60));
+ assert.equal(r.body.code, code);
+ assert.ok(h.db().users[0].pw?.h, 'the password is still set');
+ };
+ await refused(undefined, 'current-required');
+ await refused({}, 'current-required');
+ await refused({ current: 'not the password at all' }, 'current-wrong');
+ assert.ok(h.audit().some(e => e.ev === 'auth.password.fail' && e.uid === 'u1' && e.msg === 'bad-current'));
+ // Bea's passkey, and an assertion over some other challenge than the one handed out.
+ await refused(await stepUp(other), 'passkey');
+ assert.ok(h.audit().some(e => e.ev === 'auth.password.fail' && e.uid === 'u1' && e.msg === 'step-up-failed'));
+ await refused(await stepUp(key, b64u(crypto.randomBytes(32))), 'passkey');
+ // A sign-up's challenge, signed as if it were a sign-in's.
+ const reg = (await h.req('POST', '/api/register/options', { body: { name: 'Mallory' }, ip })).body;
+ await refused({ cid: reg.cid, credential: key.assertion(reg.options.challenge) }, 'passkey');
+ // A proof that already signed someone in.
+ const spent = await stepUp(key);
+ assert.equal((await h.req('POST', '/api/login/verify', { body: spent, ip })).status, 200);
+ await refused(spent, 'passkey');
+ assert.equal((await login(h, 'Ana', GOOD, ip)).status, 200);
+ assert.ok(!h.audit().some(e => e.ev === 'auth.password.remove'));
+
+ const r = await h.req('DELETE', '/api/account/password', { body: await stepUp(key), cookie, ip });
+ assert.equal(r.status, 200);
+ assert.equal(h.db().users[0].pw, undefined);
+ assert.equal((await login(h, 'Ana', GOOD, ip)).status, 401);
+ assert.ok(h.audit().some(e => e.ev === 'auth.password.remove' && e.uid === 'u1'));
+ // Existing sessions are left alone.
+ assert.equal((await h.req('GET', '/api/me', { cookie, ip })).status, 200);
+});
+
+test('wrong passwords given to remove the password count toward the same pause as wrong sign-ins', async t => {
+ const key = softPasskey();
+ const h = await startServer(t, { users: [withPassword('u1', 'Ana')], creds: [key.row('u1')] });
+ const cookie = `gymsid=${mintSession('u1')}`;
+ const answers = [];
+ for (let i = 0; i < 7; i++) {
+ answers.push(await h.req('DELETE', '/api/account/password', { body: { current: 'guess number ' + i }, cookie, ip: `198.51.100.${140 + i}` }));
+ }
+ assert.deepEqual(answers.map(r => r.status), [403, 403, 403, 403, 403, 403, 429]);
+ assert.ok(h.audit().some(e => e.ev === 'auth.password.locked' && e.uid === 'u1'));
+ assert.equal((await login(h, 'Ana', GOOD, '198.51.100.150')).status, 429);
+ assert.equal((await h.req('DELETE', '/api/account/password', { body: { current: GOOD }, cookie, ip: '198.51.100.151' })).status, 429);
+ assert.ok(h.db().users[0].pw?.h);
});
test('an admin reset: a one-time code that ends the old password, works once, and expires', async t => {
diff --git a/docs/SELF_HOSTING.md b/docs/SELF_HOSTING.md
index 87561973b..5a0079346 100644
--- a/docs/SELF_HOSTING.md
+++ b/docs/SELF_HOSTING.md
@@ -196,12 +196,22 @@ What changes when it is on:
- Settings → Account gets a **Password** row. Nobody has a password until they set one there.
Setting a first password asks for the profile's passkey; changing it asks for the current
password (or the passkey, if it was forgotten). Either signs the profile out everywhere else,
- and paired phones have to be paired again.
+ and paired phones have to be paired again. Removing it asks for the password or the passkey
+ too — a session on its own may be a copied cookie.
- People sign in with their **profile name** — case and surrounding spaces do not matter — and the
password. Two profiles with a password cannot share a name; Settings says so when a name is
already taken that way.
- A password cannot be removed while it is the profile's only way in (a profile made with a
password has no passkey).
+- The password also confirms the changes that need proof — adding or removing a passkey, making
+ a code for another device — but only while `PASSWORD_LOGIN=1`.
+
+**Switching it off again** turns every password route off, and a password kept from before no
+longer confirms anything either: an old or reused one must not be enough to add a passkey. A
+profile that only has a password can then neither sign in nor add a passkey, even from a
+browser that is still signed in. Before you switch it off, have those profiles add a passkey
+(**Settings → Account → Passkeys → Add a passkey**, confirmed with their password); the admin
+dashboard marks every profile that has a password.
**Resetting a password.** There is no e-mail. In the admin dashboard open the user and choose
**Reset password**. You get a one-time code such as `K7WQ-2MZP-4HXA` to hand over in person or
@@ -486,8 +496,10 @@ then creates a passkey of its own and is signed in by it. So a Windows Hello pas
the phone's own passkey can sign in to the same profile, instead of the phone ending up with a
second, empty one. (#95)
-Both ways ask you to confirm first — with a passkey the profile already has, or its password —
-because each adds a lasting way in: a session on its own may be a copied cookie. The code works
+Both ways ask you to confirm first — with a passkey the profile already has, or its password
+while `PASSWORD_LOGIN=1` — because each adds a lasting way in: a session on its own may be a
+copied cookie. Removing a passkey asks for the same, since a copied cookie could otherwise pick
+which of your passkeys is left. The code works
once, for ten minutes, and is stored only as a hash; making a new one, signing out everywhere or
changing the password voids it. Wrong codes count toward a per-address pause of code redemption,
like wrong reset codes, and every passkey added or removed and every code made or used is in the
@@ -504,9 +516,10 @@ Keychain to your Apple devices, a password manager to every device it runs on. A
only on one phone (or on a hardware key) goes with that phone.
**I lost my passkey.** If the profile has another passkey, sign in with that one and remove the
-lost one under **Settings → Account → Passkeys** (then **Sign out everywhere**). A browser that
-is still signed in can give a new device a passkey with **Add another device** only if the
-profile also has a password: making the code asks for a passkey or the current password first,
+lost one under **Settings → Account → Passkeys**, confirming with the passkey you signed in
+with (then **Sign out everywhere**). A browser that is still signed in can give a new device a
+passkey with **Add another device** only if the profile also has a password and
+`PASSWORD_LOGIN=1`: making the code asks for a passkey or the current password first,
because a session on its own may be a stolen cookie. Otherwise there is no self-service recovery: with `PASSWORD_LOGIN=1` an admin can issue a reset code, and without
it the only way back is a backup (**Settings → Export backup (JSON)**, from any device still
signed in) imported into a new profile. When you ask your admin for help, the id under
diff --git a/frontend/src/components/Passkeys.jsx b/frontend/src/components/Passkeys.jsx
index 2c06c830a..cf110620a 100644
--- a/frontend/src/components/Passkeys.jsx
+++ b/frontend/src/components/Passkeys.jsx
@@ -8,11 +8,11 @@ import { useStore } from '../store/useStore.js'
import { useUI } from '../store/useUI.js'
import { t } from '../lib/i18n.js'
import { dateLocale } from '../lib/i18n-core.js'
-import { api, webauthnOK, passkeyAssertion, createPasskey } from '../lib/api.js'
+import { api, webauthnOK, createPasskey } from '../lib/api.js'
import { copyText } from '../lib/clipboard.js'
import { deviceLinkUrl, deviceLabel } from '../lib/device-link.js'
-import { askAddDeviceData, confirmSheet } from '../sheets.jsx'
-import { passwordError, notReached, useAgainOnceReached } from './PasswordAuth.jsx'
+import { askAddDeviceData } from '../sheets.jsx'
+import { passwordError, notReached, useAgainOnceReached, ProveOwner } from './PasswordAuth.jsx'
import QrCanvas from './QrCanvas.jsx'
import { Row, Button } from './ui.jsx'
@@ -66,43 +66,6 @@ export function usePasskeys(on) {
return { st, load, set: setSt }
}
-/* "Confirm it is you" — what the server asks before anything that adds a way in (proveOwner in
- api/server.js): a passkey this profile already has, or its current password. Hands the body
- the server takes to `onProof`, and shows the refusal when that throws. */
-function ProveOwner({ state, onProof }) {
- const name = useStore(s => s.user?.name) || ''
- const [pw, setPw] = useState('')
- const [busy, setBusy] = useState(false)
- const [err, setErr] = useState(null)
- const run = async proof => {
- if (busy) return
- setBusy(true); setErr(null)
- try { await onProof(await proof()) }
- catch (e) { if (!dismissed(e)) setErr(passkeyError(e)) }
- finally { setBusy(false) }
- }
- const withPasskey = state.passkeys.length > 0 && webauthnOK()
- const withPassword = ev => {
- ev.preventDefault()
- if (!pw) { setErr(t('Enter your password.')); return }
- run(async () => ({ current: pw }))
- }
- return <>
- {withPasskey && <Button variant="primary" icon="lock" disabled={busy} onClick={() => run(passkeyAssertion)}>{t('Confirm with a passkey')}</Button>}
- {state.password && <form onSubmit={withPassword} noValidate>
- {withPasskey && <div className="dim small" style={{ margin: '14px 0 8px', textAlign: 'center' }}>{t('or with your password')}</div>}
- {/* Tells a password manager which account the password belongs to. */}
- <input type="text" name="username" autoComplete="username" value={name} readOnly hidden />
- <input className="input" type="password" name="current-password" autoComplete="current-password" placeholder={t('Current password')}
- value={pw} onChange={e => setPw(e.target.value)} />
- <div style={{ height: 10 }} />
- <Button type="submit" variant={withPasskey ? 'plain' : 'primary'} disabled={busy}>{t('Continue')}</Button>
- </form>}
- {!withPasskey && !state.password && <div className="dim small">{t('This browser cannot confirm with your passkey. Do this on a device that holds one.')}</div>}
- {err && <div className="small" role="alert" style={errStyle}>{err}</div>}
- </>
-}
-
/* ------------------------------------------------------------------- Settings -------------
Settings → Account: the passkeys, and a code for another device. `changed` tells Settings to
read the list again, and the password row with it — whether a password may be removed depends
@@ -126,7 +89,7 @@ export function PasskeysSheet({ close, changed }) {
const { st, set } = usePasskeys(true)
const done = r => { set(listOf(r) || st); changed?.() }
if (!st) return <><h3>{t('Passkeys')}</h3><div className="muted small">…</div></>
- const edit = (p, i) => ui().openSheet(c => <PasskeySheet passkey={p} title={label(p, i)} lastWayIn={st.lastWayIn} close={c} done={done} />)
+ const edit = (p, i) => ui().openSheet(c => <PasskeySheet passkey={p} title={label(p, i)} state={st} close={c} done={done} />)
const add = () => ui().openSheet(c => <AddPasskeySheet state={st} close={c} done={done} />)
return <>
<h3>{t('Passkeys')}</h3>
@@ -145,9 +108,8 @@ export function PasskeysSheet({ close, changed }) {
</>
}
-// One passkey: its name, and removing it. Removing does not end a session the passkey opened —
-// sessions are not tied to one (api/server.js) — which the confirm says, with the way to do that.
-function PasskeySheet({ passkey, title, lastWayIn, close, done }) {
+// One passkey: its name, and removing it (RemovePasskeySheet).
+function PasskeySheet({ passkey, title, state, close, done }) {
const [name, setName] = useState(passkey.name || '')
const [busy, setBusy] = useState(false)
const [err, setErr] = useState(null)
@@ -159,14 +121,7 @@ function PasskeySheet({ passkey, title, lastWayIn, close, done }) {
catch (e) { setErr(passkeyError(e)) }
finally { setBusy(false) }
}
- const remove = () => confirmSheet({
- title: t('Remove this passkey?'),
- message: t('It can no longer sign in to this profile. A device already signed in with it stays signed in — use Sign out everywhere if it was lost.'),
- confirmText: t('Remove'), danger: true,
- onConfirm: () => api('/api/account/passkeys?id=' + encodeURIComponent(passkey.id), { method: 'DELETE' })
- .then(r => { done(r); close(); toast(t('Passkey removed')) })
- .catch(e => toast(passkeyError(e))),
- })
+ const remove = () => ui().openSheet(c => <RemovePasskeySheet passkey={passkey} title={title} state={state} close={c} done={r => { done(r); close() }} />)
const info = meta(passkey)
return <>
<h3>{title}</h3>
@@ -178,12 +133,36 @@ function PasskeySheet({ passkey, title, lastWayIn, close, done }) {
<Button type="submit" variant="primary" disabled={busy}>{t('Save')}</Button>
</form>
<div style={{ height: 8 }} />
- {lastWayIn
+ {state.lastWayIn
? <div className="dim small">{t('It is your only way in, so it cannot be removed until there is another.')}</div>
: <button type="button" className="btn danger" disabled={busy} onClick={remove}>{t('Remove passkey')}</button>}
</>
}
+/* Removing one asks for the proof adding one does (proveOwner in api/server.js): a copied
+ session must not choose which of the owner's passkeys is left. The proof is the confirmation,
+ so it is asked on the sheet that says what removing means; any passkey of the profile may give
+ it, this one included. Removing does not end a session the passkey opened — sessions are not
+ tied to one (api/server.js) — which the sheet says, with the way to do that. */
+function RemovePasskeySheet({ passkey, title, state, close, done }) {
+ const remove = async proof => {
+ const r = await api('/api/account/passkeys?id=' + encodeURIComponent(passkey.id), { method: 'DELETE', body: JSON.stringify(proof) })
+ close(); done(r)
+ toast(t('Passkey removed'))
+ }
+ return <>
+ <h3>{t('Remove this passkey?')}</h3>
+ <div className="small" style={{ fontWeight: 600, marginBottom: 6 }}>{title}</div>
+ <div className="muted small" style={{ marginBottom: 6 }}>
+ {t('It can no longer sign in to this profile. A device already signed in with it stays signed in — use Sign out everywhere if it was lost.')}
+ </div>
+ <div className="dim small" style={{ marginBottom: 14 }}>{t('First confirm that it is you.')}</div>
+ <ProveOwner passkey password={state.password} explain={passkeyError} danger submitText={t('Remove')} onProof={remove} />
+ <div style={{ height: 8 }} />
+ <Button type="button" variant="ghost" className="dim" onClick={close}>{t('Cancel')}</Button>
+ </>
+}
+
/* Adding one from Settings: the proof first, then the passkey prompt — two taps rather than one,
because each prompt wants a tap of its own (Safari refuses a second prompt opened from the same
one), and a password, where that is the proof, is typed before either. What it is for: a
@@ -218,7 +197,8 @@ function AddPasskeySheet({ state, close, done }) {
<input className="input" placeholder={t('Name, e.g. Work laptop')} maxLength={40} value={name} onChange={e => setName(e.target.value)} />
<div style={{ height: 12 }} />
{ready ? <Button variant="primary" icon="plus" disabled={busy} onClick={create}>{t('Create passkey')}</Button>
- : <ProveOwner state={state} onProof={async proof => setReady(await post('/api/account/passkeys/options', proof))} />}
+ : <ProveOwner passkey={state.passkeys.length > 0} password={state.password} explain={passkeyError}
+ onProof={async proof => setReady(await post('/api/account/passkeys/options', proof))} />}
{err && <div className="small" role="alert" style={errStyle}>{err}</div>}
</>
}
@@ -244,7 +224,8 @@ export function DeviceLinkSheet({ close }) {
<div className="muted small" style={{ marginBottom: 14 }}>
{t('You get a code that lets your phone or another computer create a passkey for this profile. First confirm that it is you.')}
</div>
- <ProveOwner state={st} onProof={async proof => setLink(await post('/api/account/device-link', proof))} />
+ <ProveOwner passkey={st.passkeys.length > 0} password={st.password} explain={passkeyError}
+ onProof={async proof => setLink(await post('/api/account/device-link', proof))} />
</> : expired ? <>
<div className="muted small" style={{ marginBottom: 14 }}>{t('This code has expired.')}</div>
<Button variant="primary" onClick={() => setLink(null)}>{t('Make a new code')}</Button>
diff --git a/frontend/src/components/Passkeys.test.jsx b/frontend/src/components/Passkeys.test.jsx
index 5307c1e95..c63644138 100644
--- a/frontend/src/components/Passkeys.test.jsx
+++ b/frontend/src/components/Passkeys.test.jsx
@@ -7,8 +7,8 @@ import { passkeyError, PasskeysRow, PasskeysSheet, DeviceLinkSheet, DeviceLinkRe
globalThis.IS_REACT_ACT_ENVIRONMENT = true
/* More passkeys and one-time codes for another device, on screen (#95): the Settings list and
- what editing, removing and adding send; the code sheet with its proof, QR and expiry; and the
- other device's redeem sheet. The API and the passkey prompts are stand-ins; what each step
+ what editing, removing and adding send — removing and adding both behind the proof step; the
+ code sheet with its proof, QR and expiry; and the other device's redeem sheet. The API and the passkey prompts are stand-ins; what each step
sends, and what it says back in the UI language, is the point. */
const mocks = vi.hoisted(() => {
const state = { webauthn: true, sheets: [], answers: {}, calls: [], store: {} }
@@ -18,7 +18,6 @@ const mocks = vi.hoisted(() => {
state.passkeyAssertion = vi.fn(async () => ({ cid: 'login-cid', credential: { id: 'k1' } }))
state.createPasskey = vi.fn(async () => ({ id: 'new-key', response: {} }))
state.copyText = vi.fn(async () => true)
- state.confirmSheet = vi.fn()
state.askAddDeviceData = vi.fn()
state.api = vi.fn(async (path, init) => {
const method = init?.method || 'GET'
@@ -51,7 +50,7 @@ vi.mock('../lib/api.js', () => ({
passwordLogin: vi.fn(), passwordRegister: vi.fn(), passwordResetRedeem: vi.fn(),
}))
vi.mock('../lib/clipboard.js', () => ({ copyText: (...a) => mocks.copyText(...a) }))
-vi.mock('../sheets.jsx', () => ({ askAddDeviceData: mocks.askAddDeviceData, confirmSheet: (...a) => mocks.confirmSheet(...a) }))
+vi.mock('../sheets.jsx', () => ({ askAddDeviceData: mocks.askAddDeviceData }))
// lean-qr loads on demand; what matters here is what the QR code carries.
vi.mock('./QrCanvas.jsx', () => ({ default: ({ value }) => <canvas data-qr={value} /> }))
@@ -81,6 +80,18 @@ const submit = async host => { act(() => { host.querySelector('form').dispatchEv
const alertText = host => host.querySelector('[role="alert"]')?.textContent || null
// The sheet a tap opened, mounted on its own.
const openedSheet = (i = mocks.sheets.length - 1) => { const close = vi.fn(); return { host: mount(mocks.sheets[i].render(close)), close } }
+// The last sheet mounted goes away, as when it is closed.
+const unmountLast = () => act(() => { const m = mounted.pop(); m.root.unmount(); m.host.remove() })
+// A passkey prompt that stays open until the test answers it, and says whether it was called off.
+function openPrompt() {
+ const p = {}
+ mocks.passkeyAssertion.mockImplementationOnce(({ signal } = {}) => new Promise((resolve, reject) => {
+ p.signal = signal
+ p.answer = () => resolve({ cid: 'login-cid', credential: { id: 'k1' } })
+ p.fail = e => reject(e)
+ }))
+ return p
+}
const LIST = {
passkeys: [
@@ -96,7 +107,7 @@ beforeEach(() => {
mocks.answers = {}
mocks.calls.length = 0
mocks.store = { user: { id: 'u1', name: 'Ana' }, linkCode: null }
- for (const f of [mocks.toast, mocks.setUser, mocks.adoptProfile, mocks.passkeyAssertion, mocks.createPasskey, mocks.copyText, mocks.confirmSheet, mocks.askAddDeviceData]) f.mockClear()
+ for (const f of [mocks.toast, mocks.setUser, mocks.adoptProfile, mocks.passkeyAssertion, mocks.createPasskey, mocks.copyText, mocks.askAddDeviceData]) f.mockClear()
})
afterEach(() => { vi.useRealTimers(); act(() => { mounted.splice(0).forEach(({ root, host }) => { root.unmount(); host.remove() }) }) })
@@ -142,7 +153,7 @@ describe('Settings: the passkey list', () => {
expect(edit.textContent).toMatch(/only way in/)
})
- it('renames one, and removes one only after the confirm that says sessions stay', async () => {
+ it('renames one', async () => {
mocks.answers['GET /api/account/passkeys'] = LIST
const changed = vi.fn()
const host = mount(<PasskeysSheet close={() => {}} changed={changed} />)
@@ -156,27 +167,106 @@ describe('Settings: the passkey list', () => {
expect(mocks.calls.at(-1)).toEqual({ path: '/api/account/passkeys/rename', method: 'POST', body: { id: 'k/1+', name: 'Work laptop' } })
expect(close).toHaveBeenCalled()
expect(changed).toHaveBeenCalledTimes(1)
+ })
+})
+
+/* Removing asks for the proof adding does (proveOwner in api/server.js), on the sheet that says
+ what removing means: the tap that confirms it is the proof, and the proof goes with the removal
+ and nothing else. */
+describe('Settings: removing a passkey', () => {
+ async function openRemove(list = LIST) {
+ mocks.answers['GET /api/account/passkeys'] = list
+ const changed = vi.fn()
+ const host = mount(<PasskeysSheet close={() => {}} changed={changed} />)
+ await settle()
+ act(() => host.querySelector('.lrow').click())
+ const edit = openedSheet()
+ act(() => button(edit.host, 'Remove passkey').click())
+ return { ...openedSheet(), edit, changed }
+ }
+ const deletes = () => mocks.calls.filter(c => c.method === 'DELETE')
+
+ it('says sessions stay, sends nothing until the passkey confirms, then removes with that proof', async () => {
+ const { host, close, edit, changed } = await openRemove()
+ expect(host.querySelector('h3').textContent).toBe('Remove this passkey?')
+ expect(host.textContent).toContain('Laptop')
+ expect(host.textContent).toMatch(/stays signed in — use Sign out everywhere/)
+ expect(host.textContent).toContain('First confirm that it is you.')
+ // No password on this profile, or none that counts: the passkey is the only proof offered.
+ expect(byPlaceholder(host, 'Current password')).toBeNull()
+ expect(deletes()).toEqual([])
+ expect(button(host, 'Confirm with a passkey').className).toMatch(/\bdanger\b/)
- act(() => button(edit, 'Remove passkey').click())
- const confirm = mocks.confirmSheet.mock.calls[0][0]
- expect(confirm.message).toMatch(/stays signed in — use Sign out everywhere/)
mocks.answers['DELETE /api/account/passkeys'] = { ...LIST, passkeys: [LIST.passkeys[1]], lastWayIn: true }
- await act(() => confirm.onConfirm())
- expect(mocks.calls.at(-1)).toEqual({ path: '/api/account/passkeys?id=k%2F1%2B', method: 'DELETE', body: null })
+ await click(host, 'Confirm with a passkey')
+ expect(mocks.passkeyAssertion).toHaveBeenCalledTimes(1)
+ expect(deletes()).toEqual([{ path: '/api/account/passkeys?id=k%2F1%2B', method: 'DELETE', body: { cid: 'login-cid', credential: { id: 'k1' } } }])
+ expect(close).toHaveBeenCalled()
+ expect(edit.close).toHaveBeenCalled()
+ expect(changed).toHaveBeenCalledTimes(1)
expect(mocks.toast).toHaveBeenCalledWith('Passkey removed')
- expect(changed).toHaveBeenCalledTimes(2)
})
- it('a refused removal says why', async () => {
- mocks.answers['GET /api/account/passkeys'] = LIST
- const host = mount(<PasskeysSheet close={() => {}} changed={() => {}} />)
- await settle()
- act(() => host.querySelector('.lrow').click())
- const { host: edit } = openedSheet()
- act(() => button(edit, 'Remove passkey').click())
+ it('takes the password where it counts, and says when it is missing or wrong', async () => {
+ const { host, close } = await openRemove({ ...LIST, password: true })
+ const pw = byPlaceholder(host, 'Current password')
+ expect(pw.getAttribute('autocomplete')).toBe('current-password')
+ // Either way it removes, so both say so in red.
+ expect(button(host, 'Confirm with a passkey').className).toMatch(/\bdanger\b/)
+ expect(button(host, 'Remove').className).toMatch(/\bdanger\b/)
+ await submit(host)
+ expect(alertText(host)).toBe('Enter your password.')
+ expect(deletes()).toEqual([])
+ mocks.answers['DELETE /api/account/passkeys'] = fail(403, { code: 'current-wrong' })
+ type(pw, 'not it')
+ await submit(host)
+ expect(deletes().at(-1).body).toEqual({ current: 'not it' })
+ expect(alertText(host)).toBe('Your current password is not right.')
+ expect(close).not.toHaveBeenCalled()
+ mocks.answers['DELETE /api/account/passkeys'] = { ...LIST, passkeys: [LIST.passkeys[1]] }
+ type(pw, 'correct horse battery')
+ await click(host, 'Remove')
+ expect(deletes().at(-1).body).toEqual({ current: 'correct horse battery' })
+ expect(close).toHaveBeenCalled()
+ })
+
+ it('a refusal stays on the sheet and says why; nothing is removed', async () => {
+ const { host, close, changed } = await openRemove()
+ mocks.answers['DELETE /api/account/passkeys'] = fail(403, { code: 'passkey' })
+ await click(host, 'Confirm with a passkey')
+ expect(alertText(host)).toBe('Your passkey could not be confirmed.')
+ // Another device took the other passkey away meanwhile: this one is the last way in now.
mocks.answers['DELETE /api/account/passkeys'] = fail(409, { code: 'last-way-in' })
- await act(() => mocks.confirmSheet.mock.calls[0][0].onConfirm())
- expect(mocks.toast).toHaveBeenCalledWith('It is your only way in, so it cannot be removed until there is another.')
+ await click(host, 'Confirm with a passkey')
+ expect(alertText(host)).toBe('It is your only way in, so it cannot be removed until there is another.')
+ expect(close).not.toHaveBeenCalled()
+ expect(changed).not.toHaveBeenCalled()
+ expect(mocks.toast).not.toHaveBeenCalled()
+ })
+
+ it('a dismissed prompt removes nothing and is no error; Cancel just closes', async () => {
+ const { host, close } = await openRemove()
+ mocks.passkeyAssertion.mockRejectedValueOnce(named('NotAllowedError'))
+ await click(host, 'Confirm with a passkey')
+ expect(deletes()).toEqual([])
+ expect(alertText(host)).toBeNull()
+ await click(host, 'Cancel')
+ expect(close).toHaveBeenCalled()
+ expect(deletes()).toEqual([])
+ })
+
+ it('a prompt still open when the sheet goes is called off, and an answer after that removes nothing', async () => {
+ const { host } = await openRemove()
+ const prompt = openPrompt()
+ await click(host, 'Confirm with a passkey')
+ expect(prompt.signal.aborted).toBe(false)
+ unmountLast()
+ expect(prompt.signal.aborted).toBe(true)
+ // A browser that answers anyway: the answer is for a sheet that is gone.
+ await act(async () => { prompt.answer() })
+ await settle()
+ expect(deletes()).toEqual([])
+ expect(mocks.toast).not.toHaveBeenCalled()
})
})
@@ -235,6 +325,23 @@ describe('Settings: adding a passkey', () => {
})
describe('Settings: a code for another device', () => {
+ it('says plainly when nothing here can confirm it is the owner', async () => {
+ // A profile that only has a password, on an instance that switched passwords off.
+ mocks.answers['GET /api/account/passkeys'] = { passkeys: [], password: false, lastWayIn: true }
+ const host = mount(<DeviceLinkSheet close={() => {}} />)
+ await settle()
+ expect(button(host, 'Confirm with a passkey')).toBeUndefined()
+ expect(byPlaceholder(host, 'Current password')).toBeNull()
+ expect(host.textContent).toMatch(/has no passkey, and this server does not take passwords/)
+ // A passkey this browser cannot use is another matter: another device can.
+ mocks.webauthn = false
+ mocks.answers['GET /api/account/passkeys'] = LIST
+ const other = mount(<DeviceLinkSheet close={() => {}} />)
+ await settle()
+ expect(other.textContent).toMatch(/This browser cannot confirm with your passkey/)
+ expect(mocks.calls.filter(c => c.method !== 'GET')).toEqual([])
+ })
+
it('after the proof shows the code, a QR code of the link, and copies the link', async () => {
mocks.answers['GET /api/account/passkeys'] = LIST
mocks.answers['POST /api/account/device-link'] = { code: 'K7WQ-2MZP-4HXA', expires: Date.now() + 600000 }
diff --git a/frontend/src/components/PasswordAuth.jsx b/frontend/src/components/PasswordAuth.jsx
index e559324a3..ea49a397d 100644
--- a/frontend/src/components/PasswordAuth.jsx
+++ b/frontend/src/components/PasswordAuth.jsx
@@ -1,16 +1,18 @@
// Name-and-password sign-in next to passkeys (#118), on an instance that offers it
// (GET /api/config → `password_login`). Everything a password needs on screen lives here:
// signing in, redeeming the one-time code an admin hands out, creating a profile with a
-// password, and the Settings row that sets, changes or removes one. Passkeys stay the default
-// wherever this appears; the rules themselves are the server's (api/password.js and the
-// password block in api/server.js), this only words them.
+// password, and the Settings row that sets, changes or removes one — and the "confirm it is you"
+// step (ProveOwner) that Settings asks for before a way in is added or removed, where the
+// password is one of the two answers. Passkeys stay the default wherever this appears; the rules
+// themselves are the server's (api/password.js and the password block in api/server.js), this
+// only words them.
import { useEffect, useRef, useState } from 'react'
import { useStore, hasData } from '../store/useStore.js'
import { useUI } from '../store/useUI.js'
import { t } from '../lib/i18n.js'
import { dateLocale } from '../lib/i18n-core.js'
import { api, webauthnOK, passkeyAssertion, passwordLogin, passwordRegister, passwordResetRedeem } from '../lib/api.js'
-import { askAddDeviceData, confirmSheet } from '../sheets.jsx'
+import { askAddDeviceData } from '../sheets.jsx'
import { Row, Button } from './ui.jsx'
// The server's floor (api/password.js MIN_LENGTH), checked here first so the common mistake is
@@ -197,6 +199,74 @@ function PasswordRegisterSheet({ close }) {
}
export const openPasswordRegister = () => ui().openSheet(close => <PasswordRegisterSheet close={close} />)
+/* "Confirm it is you" — what the server asks before anything that adds or takes away a way in
+ (proveOwner in api/server.js): a passkey this profile already has, or its current password
+ where that counts. `passkey`: the profile has one. `password`: its password counts as proof —
+ set, and the instance takes passwords (GET /api/account/passkeys → `password`). Hands the body
+ the server takes to `onProof` — for a removal, the removal itself — and shows the refusal,
+ worded by `explain`, when that throws. For a removal this step is the confirmation too, so
+ `danger` colours it and `submitText` names the action on the password's button.
+
+ A proof is made on the tap, for the one request it goes with, and never kept. A passkey prompt
+ still open when the sheet closes is called off, and whatever a prompt answers after that is
+ dropped: someone who backed out of removing a passkey must not have it removed by a prompt
+ they no longer see. */
+export function ProveOwner({ passkey, password, onProof, explain = passwordError, danger = false, submitText }) {
+ const name = useStore(s => s.user?.name) || ''
+ const [pw, setPw] = useState('')
+ const [busy, setBusy] = useState(false)
+ const [err, setErr] = useState(null)
+ const live = useRef(true)
+ const prompt = useRef(null) // the AbortController of a passkey prompt still open
+ useEffect(() => {
+ // Set here, not only initially: StrictMode unmounts and mounts again, and the first cleanup
+ // must not leave the sheet thinking it is gone.
+ live.current = true
+ return () => { live.current = false; prompt.current?.abort() }
+ }, [])
+ const run = async proof => {
+ if (busy) return
+ setBusy(true); setErr(null)
+ const ctl = new AbortController()
+ prompt.current = ctl
+ try {
+ const body = await proof(ctl.signal)
+ if (!live.current) return
+ await onProof(body)
+ } catch (e) { if (live.current && !dismissed(e)) setErr(explain(e)) }
+ finally {
+ if (prompt.current === ctl) prompt.current = null
+ if (live.current) setBusy(false)
+ }
+ }
+ const withPasskey = !!passkey && webauthnOK()
+ const withPassword = ev => {
+ ev.preventDefault()
+ if (!pw) { setErr(t('Enter your password.')); return }
+ run(async () => ({ current: pw }))
+ }
+ // A removal's buttons are red whichever proof carries it: each of them removes.
+ const main = danger ? 'danger' : 'primary'
+ return <>
+ {withPasskey && <Button variant={main} icon="lock" disabled={busy} onClick={() => run(signal => passkeyAssertion({ signal }))}>{t('Confirm with a passkey')}</Button>}
+ {password && <form onSubmit={withPassword} noValidate>
+ {withPasskey && <div className="dim small" style={{ margin: '14px 0 8px', textAlign: 'center' }}>{t('or with your password')}</div>}
+ {/* Tells a password manager which account the password belongs to. */}
+ <input type="text" name="username" autoComplete="username" value={name} readOnly hidden />
+ <input className="input" type="password" name="current-password" autoComplete="current-password" placeholder={t('Current password')}
+ value={pw} onChange={e => setPw(e.target.value)} />
+ <div style={{ height: 10 }} />
+ <Button type="submit" variant={withPasskey && !danger ? 'plain' : main} disabled={busy}>{submitText || t('Continue')}</Button>
+ </form>}
+ {/* A profile with no passkey whose password no longer counts — the instance switched
+ passwords off — has nothing left to answer with (docs/SELF_HOSTING.md). */}
+ {!withPasskey && !password && <div className="dim small">{passkey
+ ? t('This browser cannot confirm with your passkey. Do this on a device that holds one.')
+ : t('This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.')}</div>}
+ {err && <div className="small" role="alert" style={errStyle}>{err}</div>}
+ </>
+}
+
/* Settings' account rows read the server as the screen opens. One that found the server down
has nothing to show, and stayed missing until Settings was left and opened again, while the
block above it already said "All synced". It asks again whenever the store hears from the
@@ -255,14 +325,7 @@ export function PasswordSheet({ status, close, done }) {
} catch (e) { if (!dismissed(e)) setErr(passwordError(e)) }
finally { setBusy(false) }
}
- const remove = () => confirmSheet({
- title: t('Remove your password?'),
- message: t('Only your passkeys sign in to this profile afterwards.'),
- confirmText: t('Remove'), danger: true,
- onConfirm: () => api('/api/account/password', { method: 'DELETE' })
- .then(() => { close(); done(); toast(t('Password removed')) })
- .catch(e => toast(passwordError(e))),
- })
+ const remove = () => ui().openSheet(c => <RemovePasswordSheet status={status} close={c} done={() => { close(); done() }} />)
return <>
<h3>{status.set ? t('Change password') : t('Set a password')}</h3>
<div className="muted small" style={{ marginBottom: 14 }}>
@@ -296,3 +359,24 @@ export function PasswordSheet({ status, close, done }) {
</>}
</>
}
+
+/* Removing the password asks for the proof setting one does (proveOwner in api/server.js): a
+ copied session must not take away the owner's way in where passkeys do not work. The proof is
+ the confirmation, so it is asked on the sheet that says what removing means — the password
+ itself, or a passkey of this profile. Only offered while a passkey remains (the last way in
+ stays), and the password counts here: this row exists only while the instance takes them. */
+function RemovePasswordSheet({ status, close, done }) {
+ const remove = async proof => {
+ await api('/api/account/password', { method: 'DELETE', body: JSON.stringify(proof) })
+ close(); done()
+ toast(t('Password removed'))
+ }
+ return <>
+ <h3>{t('Remove your password?')}</h3>
+ <div className="muted small" style={{ marginBottom: 6 }}>{t('Only your passkeys sign in to this profile afterwards.')}</div>
+ <div className="dim small" style={{ marginBottom: 14 }}>{t('First confirm that it is you.')}</div>
+ <ProveOwner passkey={status.passkeys > 0} password danger submitText={t('Remove')} onProof={remove} />
+ <div style={{ height: 8 }} />
+ <Button type="button" variant="ghost" className="dim" onClick={close}>{t('Cancel')}</Button>
+ </>
+}
diff --git a/frontend/src/components/PasswordAuth.test.jsx b/frontend/src/components/PasswordAuth.test.jsx
index 4f6b27c54..0ccf5e0ca 100644
--- a/frontend/src/components/PasswordAuth.test.jsx
+++ b/frontend/src/components/PasswordAuth.test.jsx
@@ -7,8 +7,9 @@ import { passwordError, PasswordSignInSheet, PasswordRegisterForm, PasswordRow,
globalThis.IS_REACT_ACT_ENVIRONMENT = true
/* Password sign-in on screen (#118): the sign-in sheet and its reset-code half, creating a profile
- with a password, and the Settings row that sets, changes or removes one. The API is a
- stand-in; what each form sends, and what it says back in the UI language, is the point. */
+ with a password, and the Settings row that sets, changes or removes one — removing behind the
+ same proof step adding a passkey uses. The API is a stand-in; what each form sends, and what it
+ says back in the UI language, is the point. */
const mocks = vi.hoisted(() => {
const state = { webauthn: true, hasData: false, sheets: [], answers: {}, calls: [] }
state.toast = vi.fn()
@@ -20,7 +21,6 @@ const mocks = vi.hoisted(() => {
state.passwordRegister = vi.fn()
state.passwordResetRedeem = vi.fn()
state.passkeyAssertion = vi.fn(async () => ({ cid: 'c1', credential: { id: 'k1' } }))
- state.confirmSheet = vi.fn()
state.api = vi.fn(async (path, init) => {
state.calls.push({ path, method: init?.method || 'GET', body: init?.body ? JSON.parse(init.body) : null })
const a = state.answers[(init?.method || 'GET') + ' ' + path]
@@ -52,7 +52,7 @@ vi.mock('../lib/api.js', () => ({
passwordRegister: (...a) => mocks.passwordRegister(...a),
passwordResetRedeem: (...a) => mocks.passwordResetRedeem(...a),
}))
-vi.mock('../sheets.jsx', () => ({ askAddDeviceData: vi.fn(), confirmSheet: (...a) => mocks.confirmSheet(...a) }))
+vi.mock('../sheets.jsx', () => ({ askAddDeviceData: vi.fn() }))
const fail = (status, data) => Object.assign(new Error(data?.error || 'HTTP ' + status), { status, data })
@@ -76,6 +76,7 @@ const byPlaceholder = (host, p) => host.querySelector(`input[placeholder="${p}"]
const button = (host, text) => [...host.querySelectorAll('button')].find(b => b.textContent === text)
const submit = async host => { act(() => { host.querySelector('form').dispatchEvent(new Event('submit', { bubbles: true, cancelable: true })) }); await settle() }
const alertText = host => host.querySelector('[role="alert"]')?.textContent || null
+const click = async (host, text) => { act(() => button(host, text).click()); await settle() }
beforeEach(() => {
mocks.webauthn = true
@@ -84,7 +85,7 @@ beforeEach(() => {
mocks.answers = {}
mocks.calls.length = 0
for (const f of [mocks.toast, mocks.setUser, mocks.adoptProfile, mocks.pushState, mocks.pullState, mocks.passwordLogin,
- mocks.passwordRegister, mocks.passwordResetRedeem, mocks.passkeyAssertion, mocks.confirmSheet]) f.mockClear()
+ mocks.passwordRegister, mocks.passwordResetRedeem, mocks.passkeyAssertion]) f.mockClear()
})
afterEach(() => { act(() => { mounted.splice(0).forEach(({ root, host }) => { root.unmount(); host.remove() }) }) })
@@ -257,17 +258,105 @@ describe('Settings → Password', () => {
expect(button(host, 'Forgot it? Confirm with your passkey instead')).toBeUndefined()
})
- it('removing asks first and then deletes; only offered while a passkey remains', async () => {
- const done = vi.fn()
- const host = mount(<PasswordSheet status={{ set: true, passkeys: 2, name: 'Ana' }} close={() => {}} done={done} />)
+})
+
+/* Removing the password asks for the proof setting one does (proveOwner in api/server.js): the
+ password itself or a passkey of this profile, on the sheet that says what removing means. */
+describe('Settings → Password → Remove', () => {
+ const named = name => Object.assign(new Error(name), { name })
+ const deletes = () => mocks.calls.filter(c => c.method === 'DELETE')
+ function openRemove(status = { set: true, passkeys: 2, name: 'Ana' }) {
+ const done = vi.fn(), close = vi.fn()
+ const host = mount(<PasswordSheet status={status} close={close} done={done} />)
act(() => button(host, 'Remove password').click())
- expect(mocks.confirmSheet).toHaveBeenCalledTimes(1)
- const opts = mocks.confirmSheet.mock.calls[0][0]
- expect(opts.title).toBe('Remove your password?')
- await act(async () => { opts.onConfirm() })
- await settle()
- expect(mocks.calls.at(-1)).toEqual({ path: '/api/account/password', method: 'DELETE', body: null })
+ const removeClose = vi.fn()
+ const sheet = mount(mocks.sheets.at(-1).render(removeClose))
+ return { sheet, close: removeClose, sheetClose: close, done }
+ }
+
+ it('asks for proof before anything is sent, then removes with the password as proof', async () => {
+ mocks.answers['DELETE /api/account/password'] = { ok: true }
+ const { sheet, close, sheetClose, done } = openRemove()
+ expect(sheet.querySelector('h3').textContent).toBe('Remove your password?')
+ expect(sheet.textContent).toContain('Only your passkeys sign in to this profile afterwards.')
+ expect(sheet.textContent).toContain('First confirm that it is you.')
+ expect(deletes()).toEqual([])
+ await submit(sheet)
+ expect(alertText(sheet)).toBe('Enter your password.')
+ expect(deletes()).toEqual([])
+ type(byPlaceholder(sheet, 'Current password'), 'correct horse battery')
+ await click(sheet, 'Remove')
+ expect(deletes()).toEqual([{ path: '/api/account/password', method: 'DELETE', body: { current: 'correct horse battery' } }])
+ expect(close).toHaveBeenCalled()
+ expect(sheetClose).toHaveBeenCalled()
expect(done).toHaveBeenCalled()
expect(mocks.toast).toHaveBeenCalledWith('Password removed')
})
+
+ it('or with a passkey of the profile, whose assertion goes with the removal', async () => {
+ mocks.answers['DELETE /api/account/password'] = { ok: true }
+ const { sheet, close } = openRemove()
+ expect(button(sheet, 'Confirm with a passkey').className).toMatch(/\bdanger\b/)
+ await click(sheet, 'Confirm with a passkey')
+ expect(mocks.passkeyAssertion).toHaveBeenCalledTimes(1)
+ expect(deletes()).toEqual([{ path: '/api/account/password', method: 'DELETE', body: { cid: 'c1', credential: { id: 'k1' } } }])
+ expect(close).toHaveBeenCalled()
+ })
+
+ it('a wrong password, a passkey the server refuses, or a removal that became the last way in stay on the sheet', async () => {
+ const { sheet, close, done } = openRemove()
+ mocks.answers['DELETE /api/account/password'] = fail(403, { code: 'current-wrong' })
+ type(byPlaceholder(sheet, 'Current password'), 'not it')
+ await submit(sheet)
+ expect(alertText(sheet)).toBe('Your current password is not right.')
+ mocks.answers['DELETE /api/account/password'] = fail(403, { code: 'passkey' })
+ await click(sheet, 'Confirm with a passkey')
+ expect(alertText(sheet)).toBe('Your passkey could not be confirmed.')
+ mocks.answers['DELETE /api/account/password'] = fail(409, { code: 'last-way-in' })
+ await click(sheet, 'Confirm with a passkey')
+ expect(alertText(sheet)).toBe('This password is the only way into your profile, so it cannot be removed.')
+ mocks.answers['DELETE /api/account/password'] = fail(429, { code: 'locked', retryAfter: 60 })
+ await submit(sheet)
+ expect(alertText(sheet)).toMatch(/^Too many attempts — try again /)
+ expect(close).not.toHaveBeenCalled()
+ expect(done).not.toHaveBeenCalled()
+ expect(mocks.toast).not.toHaveBeenCalled()
+ })
+
+ it('a dismissed passkey prompt removes nothing and is no error; Cancel just closes', async () => {
+ const { sheet, close } = openRemove()
+ mocks.passkeyAssertion.mockRejectedValueOnce(named('NotAllowedError'))
+ await click(sheet, 'Confirm with a passkey')
+ expect(deletes()).toEqual([])
+ expect(alertText(sheet)).toBeNull()
+ await click(sheet, 'Cancel')
+ expect(close).toHaveBeenCalled()
+ expect(deletes()).toEqual([])
+ })
+
+ it('a passkey prompt still open when the sheet goes removes nothing when it answers', async () => {
+ let answer, signal
+ mocks.passkeyAssertion.mockImplementationOnce(opts => new Promise(resolve => { signal = opts?.signal; answer = resolve }))
+ const { sheet } = openRemove()
+ await click(sheet, 'Confirm with a passkey')
+ act(() => { const m = mounted.pop(); m.root.unmount(); m.host.remove() })
+ expect(signal.aborted).toBe(true)
+ await act(async () => { answer({ cid: 'c1', credential: { id: 'k1' } }) })
+ await settle()
+ expect(deletes()).toEqual([])
+ expect(mocks.toast).not.toHaveBeenCalled()
+ })
+
+ it('without passkey support in this browser the password is the proof', async () => {
+ mocks.webauthn = false
+ const { sheet } = openRemove()
+ expect(button(sheet, 'Confirm with a passkey')).toBeUndefined()
+ expect(button(sheet, 'Remove').className).toMatch(/\bdanger\b/)
+ expect(byPlaceholder(sheet, 'Current password')).not.toBeNull()
+ })
+
+ it('only offered while a passkey remains', () => {
+ const host = mount(<PasswordSheet status={{ set: true, passkeys: 0, name: 'Ana' }} close={() => {}} done={() => {}} />)
+ expect(button(host, 'Remove password')).toBeUndefined()
+ })
})
diff --git a/frontend/src/lib/api.js b/frontend/src/lib/api.js
index c9d7bfa9e..7b98751cd 100644
--- a/frontend/src/lib/api.js
+++ b/frontend/src/lib/api.js
@@ -133,10 +133,12 @@ export async function passkeyRegister(name, code) {
return res.user
}
// One passkey ceremony, not yet sent anywhere: /api/login/verify turns it into a sign-in, and
-// POST /api/account/password takes it as proof before a first password is set (#118).
-export async function passkeyAssertion() {
+// the account routes take it as proof that the owner is here (#118, #95). `signal` calls the
+// prompt off — a sheet that asked for it and was closed meanwhile (components/PasswordAuth.jsx,
+// ProveOwner) — which then rejects with an AbortError.
+export async function passkeyAssertion({ signal } = {}) {
const { cid, options } = await api('/api/login/options', { method: 'POST', body: '{}' })
- const cred = await navigator.credentials.get({ publicKey: toRequestOptions(options) })
+ const cred = await navigator.credentials.get({ publicKey: toRequestOptions(options), ...(signal ? { signal } : {}) })
return { cid, credential: credToJSON(cred) }
}
export async function passkeyLogin() {
diff --git a/frontend/src/lib/api.test.js b/frontend/src/lib/api.test.js
index ab0a8c41d..e8e33cc7f 100644
--- a/frontend/src/lib/api.test.js
+++ b/frontend/src/lib/api.test.js
@@ -133,3 +133,41 @@ describe('api() gives up on a request that never answers', () => {
await expect(p).rejects.toMatchObject({ code: 'timeout' })
})
})
+
+// Settings asks for a passkey as proof before a way in is added or removed (components/
+// PasswordAuth.jsx, ProveOwner), and calls the prompt off when its sheet closes: the signal has
+// to reach the browser's prompt, or a prompt nobody sees any more could still answer.
+describe('passkeyAssertion', () => {
+ const originalCredentials = navigator.credentials
+ afterEach(() => { vi.unstubAllGlobals(); setCapability(navigator, 'credentials', originalCredentials) })
+ const options = () => new Response(JSON.stringify({ cid: 'c1', options: { challenge: 'AAAA', allowCredentials: [] } }), { status: 200, headers: { 'content-type': 'application/json' } })
+ const assertion = { id: 'k1', rawId: new Uint8Array([1]).buffer, type: 'public-key', response: { clientDataJSON: new Uint8Array([2]).buffer, authenticatorData: new Uint8Array([3]).buffer, signature: new Uint8Array([4]).buffer, userHandle: null } }
+
+ it('hands the signal to the prompt, and answers with the challenge id and the assertion', async () => {
+ const { passkeyAssertion } = await import('./api.js')
+ vi.stubGlobal('fetch', async () => options())
+ const get = vi.fn(async () => assertion)
+ setCapability(navigator, 'credentials', { get })
+ const ctl = new AbortController()
+ const r = await passkeyAssertion({ signal: ctl.signal })
+ expect(get.mock.calls[0][0].signal).toBe(ctl.signal)
+ expect(r.cid).toBe('c1')
+ expect(r.credential.id).toBe('k1')
+ // Without one, the prompt is asked for exactly as before.
+ await passkeyAssertion()
+ expect('signal' in get.mock.calls[1][0]).toBe(false)
+ })
+
+ it('a prompt called off rejects as an AbortError', async () => {
+ const { passkeyAssertion } = await import('./api.js')
+ vi.stubGlobal('fetch', async () => options())
+ setCapability(navigator, 'credentials', {
+ get: ({ signal }) => new Promise((resolve, reject) => signal.addEventListener('abort', () => reject(Object.assign(new Error('aborted'), { name: 'AbortError' }))))
+ })
+ const ctl = new AbortController()
+ const p = passkeyAssertion({ signal: ctl.signal })
+ await new Promise(r => setTimeout(r, 0))
+ ctl.abort()
+ await expect(p).rejects.toMatchObject({ name: 'AbortError' })
+ })
+})
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index dac9b3762..47042e72b 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -1585,6 +1585,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'امسح هذا بالجهاز الآخر، أو افتح openGym هناك وأدخل الرمز في شاشة تسجيل الدخول. يعمل مرة واحدة، لمدة {0} دقائق.',
'That code is wrong, used or expired — make a new one on your other device.': 'هذا الرمز خاطئ أو مستخدَم أو منتهي الصلاحية — أنشئ رمزًا جديدًا على جهازك الآخر.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'لا يستطيع هذا المتصفح التأكيد بمفتاح المرور الخاص بك. افعل ذلك على جهاز يحفظ مفتاحًا.',
+ 'First confirm that it is you.': 'أكّد أولًا أنك أنت.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'لا يملك هذا الملف الشخصي مفتاح مرور، ولا يقبل هذا الخادم كلمات المرور، لذا لا يمكن لأي شيء هنا تأكيد أنك أنت. تواصل مع المسؤول.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'لا يستطيع هذا المتصفح إنشاء مفاتيح مرور، لذا لا يمكن إضافته برمز. افتح الرابط في متصفح يستطيع ذلك.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'هذا المتصفح مسجّل الدخول باسم «{0}». إضافته إلى «{1}» تُخرج «{0}» من هنا.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'هذا الرمز لملف شخصي آخر اسمه أيضًا «{0}»، وليس للملف الذي سجّل هذا المتصفح الدخول به. إضافة المتصفح إلى هناك تُخرج ملفك الشخصي من هنا.',
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index 4a908b80a..589cba38e 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -384,6 +384,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Scanne das mit dem anderen Gerät, oder öffne dort openGym und gib den Code auf dem Anmeldebildschirm ein. Er funktioniert einmal, {0} Minuten lang.',
'That code is wrong, used or expired — make a new one on your other device.': 'Dieser Code ist falsch, schon benutzt oder abgelaufen — erstelle auf deinem anderen Gerät einen neuen.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Dieser Browser kann nicht mit deinem Passkey bestätigen. Mach das auf einem Gerät, auf dem einer gespeichert ist.',
+ 'First confirm that it is you.': 'Bestätige zuerst, dass du es bist.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'Dieses Profil hat keinen Passkey, und dieser Server nimmt keine Passwörter an. Damit kann hier nichts bestätigen, dass du es bist. Frag deinen Admin.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Dieser Browser kann keine Passkeys erstellen und lässt sich deshalb nicht per Code hinzufügen. Öffne den Link in einem Browser, der das kann.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'Dieser Browser ist als „{0}“ angemeldet. Wenn du ihn zu „{1}“ hinzufügst, wird „{0}“ hier abgemeldet.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Dieser Code gehört zu einem anderen Profil, das ebenfalls „{0}“ heißt, nicht zu dem, mit dem dieser Browser angemeldet ist. Fügst du den Browser dort hinzu, wird dein Profil hier abgemeldet.',
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index 1950c5525..c7eb2a87e 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Escanea esto con el otro dispositivo, o abre openGym allí e introduce el código en la pantalla de inicio de sesión. Funciona una vez, durante {0} minutos.',
'That code is wrong, used or expired — make a new one on your other device.': 'Ese código es incorrecto, ya se usó o ha caducado — crea uno nuevo en tu otro dispositivo.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Este navegador no puede confirmar con tu passkey. Hazlo en un dispositivo que tenga una.',
+ 'First confirm that it is you.': 'Primero confirma que eres tú.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'Este perfil no tiene ninguna passkey y este servidor no acepta contraseñas, así que aquí nada puede confirmar que eres tú. Pregunta a tu administrador.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Este navegador no puede crear passkeys, así que no se puede añadir con un código. Abre el enlace en un navegador que pueda.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'Este navegador tiene la sesión iniciada como «{0}». Añadirlo a «{1}» cierra aquí la sesión de «{0}».',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Este código es de otro perfil que también se llama «{0}», no del perfil con el que este navegador tiene la sesión iniciada. Añadir allí el navegador cierra aquí la sesión de tu perfil.',
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 378e8580d..9a0502828 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Scanne ceci avec l’autre appareil, ou ouvre openGym dessus et saisis le code sur l’écran de connexion. Il fonctionne une fois, pendant {0} minutes.',
'That code is wrong, used or expired — make a new one on your other device.': 'Ce code est faux, déjà utilisé ou expiré — crées-en un nouveau sur ton autre appareil.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Ce navigateur ne peut pas confirmer avec ta passkey. Fais-le sur un appareil qui en garde une.',
+ 'First confirm that it is you.': 'Confirme d’abord que c’est bien toi.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'Ce profil n’a aucune passkey et ce serveur n’accepte pas les mots de passe, donc rien ici ne peut confirmer que c’est bien toi. Demande à ton administrateur.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Ce navigateur ne peut pas créer de passkeys, il ne peut donc pas être ajouté avec un code. Ouvre le lien dans un navigateur qui le peut.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'Ce navigateur est connecté en tant que « {0} ». L’ajouter à « {1} » déconnecte « {0} » ici.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Ce code appartient à un autre profil qui s’appelle aussi « {0} », pas à celui avec lequel ce navigateur est connecté. Y ajouter ce navigateur déconnecte ici ton profil.',
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index b5da08470..01b7be428 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'इसे दूसरे डिवाइस से स्कैन करें, या वहाँ openGym खोलकर साइन-इन स्क्रीन पर कोड दर्ज करें। यह एक बार, {0} मिनट तक काम करता है।',
'That code is wrong, used or expired — make a new one on your other device.': 'यह कोड गलत है, इस्तेमाल हो चुका है या समाप्त हो गया है — अपने दूसरे डिवाइस पर नया बनाएँ।',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'यह ब्राउज़र आपकी पासकी से पुष्टि नहीं कर सकता। यह काम उस डिवाइस पर करें जिसमें पासकी रखी है।',
+ 'First confirm that it is you.': 'पहले पुष्टि करें कि यह आप ही हैं।',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'इस प्रोफ़ाइल में कोई पासकी नहीं है, और यह सर्वर पासवर्ड स्वीकार नहीं करता, इसलिए यहाँ कुछ भी पुष्टि नहीं कर सकता कि यह आप ही हैं। अपने एडमिन से संपर्क करें।',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'यह ब्राउज़र पासकी नहीं बना सकता, इसलिए इसे कोड से नहीं जोड़ा जा सकता। लिंक ऐसे ब्राउज़र में खोलें जो पासकी बना सके।',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'यह ब्राउज़र "{0}" के रूप में साइन इन है। इसे "{1}" में जोड़ने से यहाँ "{0}" साइन आउट हो जाएगा।',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'यह कोड किसी दूसरी प्रोफ़ाइल का है जिसका नाम भी "{0}" है, उसका नहीं जिससे यह ब्राउज़र साइन इन है। ब्राउज़र को वहाँ जोड़ने से आपकी प्रोफ़ाइल यहाँ से साइन आउट हो जाएगी।',
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 73f877747..a49a3a9f4 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -376,6 +376,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Olvasd be a másik eszközzel, vagy nyisd meg ott az openGymet, és add meg a kódot a bejelentkezési képernyőn. Egyszer működik, {0} percig.',
'That code is wrong, used or expired — make a new one on your other device.': 'Ez a kód hibás, már felhasználták, vagy lejárt — hozz létre egy újat a másik eszközödön.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Ez a böngésző nem tud megerősíteni a jelszókulcsoddal. Tedd ezt egy olyan eszközön, amelyik tárol egyet.',
+ 'First confirm that it is you.': 'Előbb erősítsd meg, hogy te vagy az.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'Ennek a profilnak nincs jelszókulcsa, és ez a szerver nem fogad el jelszót, így itt semmi sem tudja megerősíteni, hogy te vagy az. Fordulj az adminisztrátorhoz.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Ez a böngésző nem tud jelszókulcsot létrehozni, ezért kóddal sem adható hozzá. Nyisd meg a linket egy olyan böngészőben, amelyik képes rá.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'Ez a böngésző „{0}” néven van bejelentkezve. Ha hozzáadod a(z) „{1}” profilhoz, „{0}” itt kijelentkezik.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Ez a kód egy másik profilé, amelynek szintén „{0}” a neve, nem azé, amellyel ez a böngésző be van jelentkezve. Ha ott adod hozzá a böngészőt, a te profilod itt kijelentkezik.',
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index a5c176744..5a5b8af3e 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Scansionalo con l’altro dispositivo, oppure apri openGym lì e inserisci il codice nella schermata di accesso. Funziona una volta, per {0} minuti.',
'That code is wrong, used or expired — make a new one on your other device.': 'Questo codice è sbagliato, già usato o scaduto — creane uno nuovo sull’altro dispositivo.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Questo browser non può confermare con la tua passkey. Fallo su un dispositivo che ne conserva una.',
+ 'First confirm that it is you.': 'Prima conferma che sei tu.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'Questo profilo non ha nessuna passkey e questo server non accetta password, quindi qui niente può confermare che sei tu. Chiedi al tuo amministratore.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Questo browser non può creare passkey, quindi non può essere aggiunto con un codice. Apri il link in un browser che ci riesce.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'Questo browser ha effettuato l’accesso come «{0}». Aggiungerlo a «{1}» fa uscire «{0}» da qui.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Questo codice è di un altro profilo che si chiama anch’esso «{0}», non di quello con cui questo browser ha effettuato l’accesso. Aggiungere lì il browser fa uscire da qui il tuo profilo.',
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 52c622640..1031c95e2 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': '다른 기기로 스캔하거나, 그 기기에서 openGym을 열고 로그인 화면에 코드를 입력하세요. 한 번만, {0}분 동안 사용할 수 있습니다.',
'That code is wrong, used or expired — make a new one on your other device.': '코드가 틀렸거나 이미 사용되었거나 만료되었습니다 — 다른 기기에서 새 코드를 만드세요.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': '이 브라우저에서는 패스키로 확인할 수 없습니다. 패스키가 있는 기기에서 진행하세요.',
+ 'First confirm that it is you.': '먼저 본인인지 확인하세요.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': '이 프로필에는 패스키가 없고 이 서버는 비밀번호를 받지 않으므로, 여기서는 본인임을 확인할 방법이 없습니다. 관리자에게 문의하세요.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': '이 브라우저는 패스키를 만들 수 없어 코드로 추가할 수 없습니다. 패스키를 만들 수 있는 브라우저에서 링크를 여세요.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': '이 브라우저는 "{0}"(으)로 로그인되어 있습니다. "{1}"에 추가하면 여기서 "{0}"은(는) 로그아웃됩니다.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': '이 코드는 이름이 똑같이 "{0}"인 다른 프로필의 것이며, 이 브라우저가 로그인한 프로필이 아닙니다. 브라우저를 그곳에 추가하면 지금 로그인된 프로필은 여기서 로그아웃됩니다.',
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index e32cdcb6d..a2e84942a 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Zeskanuj to drugim urządzeniem albo otwórz tam openGym i wpisz kod na ekranie logowania. Działa raz, przez {0} minut.',
'That code is wrong, used or expired — make a new one on your other device.': 'Ten kod jest błędny, już użyty albo wygasł — utwórz nowy na drugim urządzeniu.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Ta przeglądarka nie może potwierdzić twoim passkey. Zrób to na urządzeniu, na którym go masz.',
+ 'First confirm that it is you.': 'Najpierw potwierdź, że to ty.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'Ten profil nie ma żadnego passkey, a ten serwer nie przyjmuje haseł, więc nic tutaj nie potwierdzi, że to ty. Zwróć się do administratora.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Ta przeglądarka nie potrafi tworzyć passkey, więc nie można jej dodać kodem. Otwórz link w przeglądarce, która to potrafi.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'Ta przeglądarka jest zalogowana jako „{0}”. Dodanie jej do „{1}” wyloguje tu „{0}”.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Ten kod należy do innego profilu, który też nazywa się „{0}”, a nie do tego, na który zalogowana jest ta przeglądarka. Dodanie jej tam wyloguje tu Twój profil.',
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 87ff1a4b3..52f01c247 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -377,6 +377,8 @@ export const PT_BR_OVERRIDES = {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Escaneie isto com o outro dispositivo, ou abra o openGym nele e digite o código na tela de entrada. Funciona uma vez, por {0} minutos.',
'That code is wrong, used or expired — make a new one on your other device.': 'Esse código está errado, já foi usado ou expirou — crie um novo no seu outro dispositivo.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Este navegador não consegue confirmar com sua chave de acesso. Faça isso em um dispositivo que tenha uma.',
+ 'First confirm that it is you.': 'Primeiro confirme que é você.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'Este perfil não tem nenhuma chave de acesso e este servidor não aceita senhas, então nada aqui pode confirmar que é você. Fale com seu administrador.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Este navegador não consegue criar chaves de acesso, por isso não pode ser adicionado com um código. Abra o link em um navegador que consiga.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'Este navegador está conectado como “{0}”. Adicioná-lo a “{1}” desconecta “{0}” aqui.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Este código é de outro perfil que também se chama “{0}”, não daquele com que este navegador está conectado. Adicionar o navegador lá desconecta o seu perfil aqui.',
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index a24c3d453..bb334291b 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Digitaliza isto com o outro dispositivo, ou abre lá o openGym e introduz o código no ecrã de início de sessão. Funciona uma vez, durante {0} minutos.',
'That code is wrong, used or expired — make a new one on your other device.': 'Esse código está errado, já foi usado ou expirou — cria um novo no teu outro dispositivo.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Este navegador não consegue confirmar com a tua passkey. Faz isto num dispositivo que tenha uma.',
+ 'First confirm that it is you.': 'Primeiro confirma que és tu.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'Este perfil não tem nenhuma passkey e este servidor não aceita palavras-passe, por isso nada aqui pode confirmar que és tu. Pede ajuda ao teu administrador.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Este navegador não consegue criar passkeys, por isso não pode ser adicionado com um código. Abre a ligação num navegador que consiga.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'Este navegador tem sessão iniciada como «{0}». Adicioná-lo a «{1}» termina aqui a sessão de «{0}».',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Este código é de outro perfil que também se chama «{0}», não daquele com que este navegador tem sessão iniciada. Adicionar aí o navegador termina aqui a sessão do teu perfil.',
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 8509c6f6c..bdfb4f974 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Отсканируй это другим устройством или открой там openGym и введи код на экране входа. Код работает один раз в течение {0} минут.',
'That code is wrong, used or expired — make a new one on your other device.': 'Этот код неверный, уже использован или истёк — создай новый на другом устройстве.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Этот браузер не может подтвердить твоим ключом доступа. Сделай это на устройстве, где он хранится.',
+ 'First confirm that it is you.': 'Сначала подтверди, что это ты.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'У этого профиля нет ключа доступа, а этот сервер не принимает пароли, поэтому здесь нечем подтвердить, что это ты. Обратись к администратору.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Этот браузер не умеет создавать ключи доступа, поэтому его нельзя добавить по коду. Открой ссылку в браузере, который это умеет.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'В этом браузере выполнен вход как «{0}». Если добавить его к «{1}», «{0}» здесь выйдет из аккаунта.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Этот код от другого профиля, который тоже называется «{0}», а не от того, под которым выполнен вход в этом браузере. Если добавить браузер туда, твой профиль здесь выйдет из системы.',
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 113bc6195..223d94fa2 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -376,6 +376,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'สแกนด้วยอุปกรณ์อีกเครื่อง หรือเปิด openGym บนเครื่องนั้นแล้วกรอกรหัสในหน้าจอเข้าสู่ระบบ ใช้ได้ครั้งเดียวภายใน {0} นาที',
'That code is wrong, used or expired — make a new one on your other device.': 'รหัสนี้ไม่ถูกต้อง ถูกใช้ไปแล้ว หรือหมดอายุ — สร้างรหัสใหม่บนอุปกรณ์อีกเครื่องของคุณ',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'เบราว์เซอร์นี้ยืนยันด้วยพาสคีย์ของคุณไม่ได้ ทำขั้นตอนนี้บนอุปกรณ์ที่เก็บพาสคีย์ไว้',
+ 'First confirm that it is you.': 'ก่อนอื่นยืนยันว่าเป็นคุณ',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'โปรไฟล์นี้ไม่มีพาสคีย์ และเซิร์ฟเวอร์นี้ไม่รับรหัสผ่าน จึงไม่มีสิ่งใดที่นี่ยืนยันได้ว่าเป็นคุณ โปรดติดต่อผู้ดูแลระบบของคุณ',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'เบราว์เซอร์นี้สร้างพาสคีย์ไม่ได้ จึงเพิ่มด้วยรหัสไม่ได้ เปิดลิงก์ในเบราว์เซอร์ที่สร้างพาสคีย์ได้',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'เบราว์เซอร์นี้เข้าสู่ระบบในชื่อ “{0}” อยู่ การเพิ่มเบราว์เซอร์นี้ให้ “{1}” จะทำให้ “{0}” ออกจากระบบที่นี่',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'รหัสนี้เป็นของโปรไฟล์อื่นที่ชื่อ “{0}” เหมือนกัน ไม่ใช่โปรไฟล์ที่เบราว์เซอร์นี้เข้าสู่ระบบอยู่ การเพิ่มเบราว์เซอร์ไปที่นั่นจะทำให้โปรไฟล์ของคุณออกจากระบบที่นี่',
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 3551af1cb..96fd5685e 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Bunu diğer cihazla tara ya da orada openGym’i açıp kodu giriş ekranına gir. Bir kez ve {0} dakika boyunca çalışır.',
'That code is wrong, used or expired — make a new one on your other device.': 'Bu kod yanlış, kullanılmış ya da süresi dolmuş — diğer cihazında yeni bir tane oluştur.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Bu tarayıcı geçiş anahtarınla onaylayamaz. Bunu, anahtarın kayıtlı olduğu bir cihazda yap.',
+ 'First confirm that it is you.': 'Önce sen olduğunu onayla.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'Bu profilin geçiş anahtarı yok ve bu sunucu şifre kabul etmiyor, bu yüzden burada sen olduğunu hiçbir şey onaylayamaz. Yöneticine başvur.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Bu tarayıcı geçiş anahtarı oluşturamadığı için kodla eklenemez. Bağlantıyı bunu yapabilen bir tarayıcıda aç.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'Bu tarayıcıda “{0}” olarak oturum açık. Onu “{1}” profiline eklemek burada “{0}” oturumunu kapatır.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Bu kod, yine “{0}” adını taşıyan başka bir profile ait; bu tarayıcıda oturumu açık olan profile değil. Tarayıcıyı oraya eklemek buradaki kendi profilinin oturumunu kapatır.',
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index 2b7ae36d2..2904dadc7 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -1529,6 +1529,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': 'Відскануй це іншим пристроєм або відкрий там openGym і введи код на екрані входу. Код працює один раз протягом {0} хвилин.',
'That code is wrong, used or expired — make a new one on your other device.': 'Цей код неправильний, уже використаний або прострочений — створи новий на іншому пристрої.',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': 'Цей браузер не може підтвердити твоїм ключем доступу. Зроби це на пристрої, де він зберігається.',
+ 'First confirm that it is you.': 'Спершу підтверди, що це ти.',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': 'У цього профілю немає ключа доступу, а цей сервер не приймає паролі, тож тут нічим підтвердити, що це ти. Звернися до адміністратора.',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': 'Цей браузер не вміє створювати ключі доступу, тож його не можна додати за кодом. Відкрий посилання в браузері, який це вміє.',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': 'У цьому браузері виконано вхід як «{0}». Якщо додати його до «{1}», «{0}» тут вийде з акаунта.',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': 'Цей код належить іншому профілю, який теж називається «{0}», а не тому, під яким виконано вхід у цьому браузері. Якщо додати браузер туди, твій профіль тут вийде з системи.',
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index e3e097d6d..492300276 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -370,6 +370,8 @@ export default {
'Scan this with the other device, or open openGym there and enter the code on the sign-in screen. It works once, for {0} minutes.': '用另一台设备扫描,或在那台设备上打开 openGym,在登录界面输入代码。仅可使用一次,{0} 分钟内有效。',
'That code is wrong, used or expired — make a new one on your other device.': '代码错误、已被使用或已过期——请在你另一台设备上生成新的代码。',
'This browser cannot confirm with your passkey. Do this on a device that holds one.': '此浏览器无法用你的通行密钥确认。请在保存了通行密钥的设备上操作。',
+ 'First confirm that it is you.': '请先确认是你本人。',
+ 'This profile has no passkey, and this server does not take passwords, so nothing here can confirm that it is you. Ask your admin.': '此档案没有通行密钥,而此服务器不接受密码,所以这里无法确认是你本人。请联系管理员。',
'This browser cannot create passkeys, so it cannot be added with a code. Open the link in a browser that can.': '此浏览器无法创建通行密钥,因此不能通过代码添加。请在能创建通行密钥的浏览器中打开此链接。',
'This browser is signed in as “{0}”. Adding it to “{1}” signs “{0}” out here.': '此浏览器已以“{0}”登录。将它添加到“{1}”会让“{0}”在这里退出登录。',
'This code is for a different profile that is also called “{0}”, not the one this browser is signed in as. Adding it there signs yours out here.': '这个代码属于另一个同样名为“{0}”的档案,而不是此浏览器当前登录的那个。将浏览器添加到那里,会让你的档案在这里退出登录。',