From 55204c6583a65d39a43777b82540c7c0123d141b Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Thu, 15 Oct 2026 11:56:50 +0000 Subject: [PATCH] feat(auth): open Lens's other addresses signed in, to add a passkey there MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A passkey works only at the address it was made at, so one made at localhost or on the network didn't work at the Remote access or HTTPS address, and getting one there needed a sign-in link from email or an admin. Profile › Passkeys now lists Lens's other addresses (GET /auth/passkeys/elsewhere) with Open signed in (POST): a 15-minute, one-time sign-in link of your own at that address, for people signed in themselves only, leaving other links alone. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01CXpr1EWCfUD5tb1SmSwfDa --- CHANGELOG.md | 5 + README.md | 17 +-- docs/authentication.md | 13 ++- docs/remote-access.md | 5 +- docs/requirements.md | 1 + fastapi_backend/app/api/v1/routes/passkeys.py | 27 +++++ fastapi_backend/app/domain/passkeys.py | 19 +++- fastapi_backend/app/schemas/auth.py | 9 ++ fastapi_backend/tests/api/test_passkeys.py | 49 +++++++++ .../__tests__/passkeys-panel.test.tsx | 83 ++++++++++++++ nextjs-frontend/__tests__/webauthn.test.ts | 9 ++ nextjs-frontend/app/openapi-client/index.ts | 10 ++ nextjs-frontend/app/openapi-client/sdk.gen.ts | 40 +++++++ .../app/openapi-client/types.gen.ts | 74 +++++++++++++ .../components/account/passkeys.tsx | 46 +++++++- .../components/auth/passkey-button.tsx | 4 +- nextjs-frontend/lib/auth/webauthn.ts | 11 ++ nextjs-frontend/openapi.json | 103 ++++++++++++++++++ threat-model.json | 11 +- threat-model.md | 3 +- threat-model.yaml | 11 +- 21 files changed, 532 insertions(+), 18 deletions(-) create mode 100644 nextjs-frontend/__tests__/passkeys-panel.test.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 588ff02c0..ec696c6bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,11 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version every client signs in with a hub login, with too many wrong passwords from one address turned away for a while. It's the same broker as on port 1883. SMB, NFS and syslog stay on the local network, and Remote access now says why ([Sensors](docs/sensors.md#at-the-web-apps-address), [Remote access](docs/remote-access.md#what-it-reaches)). +- **Passkeys at your remote address in one step.** A passkey works only at the address it was made at, so one made at + `localhost` or on the network didn't work at the Remote access or HTTPS address, and getting one there took a + sign-in link from email or an admin. Now Profile and sign-in › Passkeys lists Lens's other addresses with **Open + signed in**, which opens one with a 15-minute sign-in link of your own, where one fingerprint adds a passkey for it + ([Authentication](docs/authentication.md#signing-in-passkeys)). - **Export a conversation.** `GET /api/v1/chats//export.md`, `.pdf` or `.json` gives the version showing, one message (`?message=`) or, as JSON, every version (`?all=true`). The Markdown has each question and answer, its citations as footnotes linking back to the moment in Lens and the tools it used; the PDF is that Markdown printed by diff --git a/README.md b/README.md index d042093fb..0381a5626 100644 --- a/README.md +++ b/README.md @@ -181,14 +181,15 @@ listed under [In progress](#in-progress), and what comes next under [Planned](#p machine; the same daily events can also go to a Google Analytics 4 property of your own (off unless you turn it on). ([Logging](docs/logging.md), [telemetry](docs/telemetry.md), [Prometheus](docs/prometheus.md), [usage analytics](docs/analytics.md); [checks](docs/requirements.md#watch-it-run)) -- **Stay private and safe.** Passkeys instead of passwords, encryption at rest with a key per namespace, roles per - namespace (viewer, editor, owner, or custom roles made of permissions), email invitations, removing someone for - good, and an audit log. Prompt injection meets several layers: what the assistant reads (recordings, - documents, web pages, tool results) reaches the model marked as data, not instructions, and text that reads like - instructions to an AI is flagged (by free patterns, or an optional classifier model that runs on your machine and is - fetched only when you pick it). Once an answer has read such text, sending anything out, or the browser opening or - typing what the assistant wrote, waits for your yes. Chat-room answers have links they built themselves broken up, - agents over MCP get the archive as data, and what Lens caught goes into the audit log. Serve Lens over HTTPS, set +- **Stay private and safe.** Passkeys instead of passwords (one at Lens's remote address added from a signed-in one with + Open signed in), encryption at rest with a key per namespace, roles per namespace (viewer, editor, owner, or custom + roles made of permissions), email invitations, removing someone for good, and an audit log. Prompt injection meets + several layers: what the assistant reads (recordings, documents, web pages, tool results) reaches the model marked as + data, not instructions, and text that reads like instructions to an AI is flagged (by free patterns, or an optional + classifier model that runs on your machine and is fetched only when you pick it). Once an answer has read such text, + sending anything out, or the browser opening or typing what the assistant wrote, waits for your yes. Chat-room answers + have links they built themselves broken up, agents over MCP get the archive as data, and what Lens caught goes into + the audit log. Serve Lens over HTTPS, set up in Settings, with certificates from Let's Encrypt or ZeroSSL that renew on their own, answering only for its own domains and, if you choose, only to devices holding a client certificate; or reach it from anywhere through a Cloudflare tunnel with nothing opened on your router. Either way, the S3 and WebDAV shares and the MQTT hub answer at diff --git a/docs/authentication.md b/docs/authentication.md index 9d917eb14..aab1e4d83 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -30,7 +30,17 @@ no passwords on a fresh install (`auth.passwords` is off), so there is nothing t A passkey belongs to the address it was made at (its host name): one made at `https://lens.example.com` doesn't work at `http://localhost:3000`. Browsers only use passkeys on `https://` addresses and on `localhost`. The API learns the address from the web app (`X-Forwarded-Host`), accepted only for host names Lens is served at (`FRONTEND_URL`, -`localhost`, `server.allowed_hosts`) or from `server.trusted_proxies`; anything else falls back to `FRONTEND_URL`. +`localhost`, `server.allowed_hosts`, the [Remote access](remote-access.md) and [HTTPS](https.md) addresses) or from +`server.trusted_proxies`; anything else falls back to `FRONTEND_URL`. + +When Lens opens at another address too (Remote access, HTTPS), Profile and sign-in › Passkeys lists it, with **Open +signed in** for one you have no passkey for yet: it opens that address with a sign-in link of your own, where one +fingerprint adds a passkey for it and signs you in. No email, admin or copied link is needed. The link lasts 15 minutes, +works once and leaves other links alone; only someone signed in themselves can make one, not an API token or app +(`GET` · `POST /api/v1/auth/passkeys/elsewhere`, audited as `passkey.elsewhere`). Remote access's quick address changes +each time the tunnel starts, and a passkey made there stops working with it: use your own domain to keep one. When a +passkey sign-in is cancelled or finds nothing, the sign-in page says that a passkey works only where it was made and +points to **Open signed in**. Passkeys must verify the person (fingerprint, face or PIN, not just a tap), and a key whose signature counter goes backwards (a clone) is refused. Failed passkey sign-ins are throttled per visitor address like passwords. @@ -121,6 +131,7 @@ Sign out ──► POST /api/v1/auth/logout (ends the session on the API too) | `POST /api/v1/auth/signin-link/use` | sign in with a sign-in link alone, without adding a passkey | | `POST /api/v1/auth/signin-link/lost` | email a sign-in link; answers the same for unknown addresses | | `GET` · `POST /api/v1/auth/passkeys` (and `/options`) · `PATCH` · `DELETE /api/v1/auth/passkeys/{id}` | your passkeys: list, add, rename, remove (not the last); audited as `passkey.add` and `passkey.remove` | +| `GET` · `POST /api/v1/auth/passkeys/elsewhere` | the other addresses Lens opens at, and whether you have a passkey for each; a 15-minute sign-in link of your own at one, to add a passkey there; audited as `passkey.elsewhere` | | `POST /api/v1/users/{id}/signin-link` · `DELETE /api/v1/users/{id}/passkeys` | admins: a sign-in link for someone (`?email=true` emails it to them when mail is set up); remove all their passkeys | | `DELETE /api/v1/users/{id}` | admins: [remove someone for good](#removing-someone) | | `GET /api/v1/auth/external` | the outside accounts people can sign in with (for the sign-in page) | diff --git a/docs/remote-access.md b/docs/remote-access.md index 928c2f2d1..1bc9307f1 100644 --- a/docs/remote-access.md +++ b/docs/remote-access.md @@ -42,7 +42,10 @@ command (the long string after `--token`). - When cloudflared stops, Lens starts it again after 5 s, 15 s, 1 min, then every 5 min; changing a setting starts it again at once. - The tunnel's address counts as one Lens is served at: passkeys and sign-in redirects use `https://`, - and email links use the fixed hostname unless Settings › Notifications sets another address. + and email links use the fixed hostname unless Settings › Notifications sets another address. A passkey works only + at the address it was made at, so Profile and sign-in › Passkeys offers **Open signed in** there, to add one for the + tunnel's address in one step ([Authentication](authentication.md#signing-in-passkeys)). The quick address changes + each time, and passkeys made there stop working with it. ## What it reaches diff --git a/docs/requirements.md b/docs/requirements.md index b7363be32..d91277df3 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -225,6 +225,7 @@ request, to another check that proves the same thing; loosening a requirement or | Requirement | Checks | |---|---| | Passkeys instead of passwords | [test_passkeys.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_passkeys.py) `test_first_admin_with_a_passkey_and_no_password`, `test_sign_in_with_a_passkey` | +| A passkey at another of Lens's addresses (remote access, HTTPS) added from a signed-in one: Open signed in, then one fingerprint | [test_passkeys.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_passkeys.py) `test_taking_your_sign_in_to_another_address`, `test_the_addresses_lens_opens_at`; [passkeys-panel.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/passkeys-panel.test.tsx) `opens an address you have no passkey for signed in, to add one there`; [webauthn.test.ts](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/webauthn.test.ts) `points a failed sign-in to the address the passkey was made at` | | Encryption at rest, with a key per namespace | [test_keyring.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/domain/test_keyring.py) `test_each_namespace_gets_its_own_key_kept_only_wrapped`; [test_encryption.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_encryption.py) `test_a_new_archive_encrypts_and_still_plays_seeks_and_processes` | | Roles per namespace: viewer, editor, owner, or custom roles made of permissions | [test_roles.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_roles.py) `test_builtin_roles_keep_their_meaning`, `test_custom_roles_allow_exactly_their_permissions`; [journeys.mjs](https://github.com/adeelahmad/lense/blob/main/ci/clicks/journeys.mjs) `person-add` | | Email invitations, and removing someone for good | [test_users.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_users.py) `test_invites_are_emailed_when_mail_is_set_up`, `test_admins_remove_people_for_good` | diff --git a/fastapi_backend/app/api/v1/routes/passkeys.py b/fastapi_backend/app/api/v1/routes/passkeys.py index 636c3d5b9..9d0fae9b9 100644 --- a/fastapi_backend/app/api/v1/routes/passkeys.py +++ b/fastapi_backend/app/api/v1/routes/passkeys.py @@ -8,6 +8,7 @@ from __future__ import annotations import secrets +import urllib.parse from fastapi import APIRouter, BackgroundTasks, HTTPException, Request @@ -20,6 +21,8 @@ ForgotPasswordRequest, LoginTicket, Passkey, + PasskeyAddress, + PasskeyAddressAsk, PasskeyAnswer, PasskeyOptions, PasskeyRename, @@ -277,6 +280,30 @@ def remove_passkey(pid: str, user: Writer, request: Request, db: Db, cfg: Cfg) - return Ok() +@router.get("/passkeys/elsewhere") +def passkey_addresses(user: CurrentUser, request: Request, db: Db, cfg: Cfg) -> list[PasskeyAddress]: + """The other https:// addresses Lens opens at (Settings › Remote access and HTTPS), and whether you have a passkey + for each: a passkey works only on the address it was made at.""" + here = web_origin(request).rstrip("/").lower() + mine = {p.get("rp_id") for p in passkeys.list_for(db, user.id)} + return [PasskeyAddress(url=u, passkey=urllib.parse.urlsplit(u).hostname in mine) for u in passkeys.addresses(db, cfg) if u != here] + + +@router.post("/passkeys/elsewhere") +def passkey_elsewhere(body: PasskeyAddressAsk, user: Writer, db: Db, cfg: Cfg) -> SigninLink: + """A sign-in link of your own at another address Lens opens at, to sign in there and add a passkey for it, with no + email and no admin. It lasts 15 minutes and works once; links others have are left alone. For people signed in + themselves, not API tokens or apps. Audited as `passkey.elsewhere`.""" + _signed_in(user) + url = body.url.strip().rstrip("/").lower() + if url not in passkeys.addresses(db, cfg): + raise HTTPException(400, "that isn't an address Lens opens at: see Settings › Remote access and Settings › HTTPS") + raw = passkeys.create_link(db, user.id, hours=passkeys.ELSEWHERE_MINUTES / 60, by=user.email, replace=False) + auth.audit(db, user.as_audit(), "passkey.elsewhere", f"account:{user.id}", [urllib.parse.urlsplit(url).netloc]) + row = db.one("SELECT expires_at FROM $r", r=auth.R("signin_link", auth.sha(raw))) + return SigninLink(url=passkeys.link_url(raw, url), expires_at=row["expires_at"]) + + # ---------- admins ---------- @people.post("/users/{uid}/signin-link") def make_signin_link( diff --git a/fastapi_backend/app/domain/passkeys.py b/fastapi_backend/app/domain/passkeys.py index 2056b38a0..688962e6d 100644 --- a/fastapi_backend/app/domain/passkeys.py +++ b/fastapi_backend/app/domain/passkeys.py @@ -8,7 +8,8 @@ A passkey belongs to the site it was made on (its RP ID, the host name): one made at https://lens.example.com doesn't work at http://localhost:3000, so the passkeys list shows each one's site. Browsers only offer passkeys on https:// -pages and on localhost. +pages and on localhost. Someone signed in at one address carries their sign-in to the others Lens opens at (Remote +access, HTTPS: addresses()) with a short sign-in link of their own (ELSEWHERE_MINUTES), and adds a passkey there. People without a passkey yet get one through a sign-in link (`signin_link`): an admin makes one for a new person or someone who lost theirs, `lens users link` prints one on the server, and "Lost your passkey?" emails one when mail is @@ -45,6 +46,7 @@ FLOW_MINUTES = 5 TICKET_SECONDS = 120 LINK_HOURS = 72 +ELSEWHERE_MINUTES = 15 # a sign-in link of your own, to take your sign-in to another address Lens opens at MAX_PER_ACCOUNT = 20 NAME_MAX = 60 TRANSPORTS = {t.value for t in AuthenticatorTransport} @@ -252,6 +254,21 @@ def create_link(db, uid, hours=LINK_HOURS, by=None, replace=True): return raw +def addresses(db, cfg): + """The https:// addresses Lens opens at besides the one it's set up at: the Cloudflare tunnel's (Settings › Remote + access) and HTTPS's domains (Settings › HTTPS), lower case, without a trailing slash.""" + from . import https, tunnel + + out = [] + if ((cfg.get("tunnel") or {}).get("mode") or "off") != "off": + url = tunnel.status(db, cfg).get("url") + if url: + out.append(url) + port = https.public_port() + out += [f"https://{h}" + ("" if port == 443 else f":{port}") for h in https.hosts(cfg)] + return list(dict.fromkeys(u.rstrip("/").lower() for u in out)) + + def link_url(raw, base=None): """The web app's page for a sign-in link.""" from app.config import settings as env diff --git a/fastapi_backend/app/schemas/auth.py b/fastapi_backend/app/schemas/auth.py index 50fd9be01..68cd999a7 100644 --- a/fastapi_backend/app/schemas/auth.py +++ b/fastapi_backend/app/schemas/auth.py @@ -167,6 +167,15 @@ class SigninLinkInfo(ResponseModel): name: str | None = None +class PasskeyAddress(ResponseModel): + url: str = Field(description="an https:// address Lens opens at besides this one (Remote access, HTTPS)") + passkey: bool = Field(description="whether you have a passkey for it: a passkey works only where it was made") + + +class PasskeyAddressAsk(RequestModel): + url: str = Field(description="one of GET /auth/passkeys/elsewhere's addresses", max_length=300) + + class SigninLink(ResponseModel): url: str = Field(description="open it on the device to sign in with; it works once") expires_at: str diff --git a/fastapi_backend/tests/api/test_passkeys.py b/fastapi_backend/tests/api/test_passkeys.py index 350df9215..709f4012b 100644 --- a/fastapi_backend/tests/api/test_passkeys.py +++ b/fastapi_backend/tests/api/test_passkeys.py @@ -2,6 +2,7 @@ from __future__ import annotations +import datetime as dt import threading from unittest import mock @@ -150,6 +151,54 @@ def test_api_tokens_cant_add_passkeys(app, client, db): assert client.post("/api/v1/auth/passkeys/options", headers={"Authorization": f"Bearer {raw}", **WEB}).status_code == 403 +def test_taking_your_sign_in_to_another_address(app, client, db): + laptop = Authenticator() + h = _session(client, _setup(app, client, laptop)) + here = {**h, **WEB} + assert client.get("/api/v1/auth/passkeys/elsewhere", headers=here).json() == [] + me = client.get("/api/v1/auth/me", headers=h).json()["user"]["id"] + invite = client.post(f"/api/v1/users/{me}/signin-link", headers=here).json()["url"].split("#", 1)[1] + settings.save(db, app.state.archive.base, "https", {"enabled": True, "domains": ["lens.example.com"]}) + there = {"x-forwarded-host": "lens.example.com", "x-forwarded-proto": "https"} + assert client.get("/api/v1/auth/passkeys/elsewhere", headers=here).json() == [{"url": "https://lens.example.com", "passkey": False}] + assert client.get("/api/v1/auth/passkeys/elsewhere", headers={**h, **there}).json() == [] # where you are already + + assert client.post("/api/v1/auth/passkeys/elsewhere", json={"url": "https://evil.example"}, headers=here).status_code == 400 + raw = client.post("/api/v1/tokens", json={"name": "t", "scope": "write"}, headers=h).json()["token"] + as_token = {"Authorization": f"Bearer {raw}", **WEB} + assert client.post("/api/v1/auth/passkeys/elsewhere", json={"url": "https://lens.example.com"}, headers=as_token).status_code == 403 + r = client.post("/api/v1/auth/passkeys/elsewhere", json={"url": "https://Lens.example.com/"}, headers=here) + assert r.status_code == 200, r.text + url = r.json()["url"] + assert url.startswith("https://lens.example.com/signin-link#") and r.json()["emailed"] is False + left = dt.datetime.fromisoformat(r.json()["expires_at"]) - dt.datetime.now(dt.UTC) + assert dt.timedelta(minutes=14) < left <= dt.timedelta(minutes=15) + assert client.post("/api/v1/auth/signin-link/info", json={"token": invite}).status_code == 200 # an admin's link stays + + # there: a passkey for that address, and signed in + token = url.split("#", 1)[1] + o = client.post("/api/v1/auth/signin-link/options", json={"token": token}, headers=there).json() + assert o["options"]["rp"]["id"] == "lens.example.com" + credential = laptop.create(o["options"], "https://lens.example.com") + r = client.post("/api/v1/auth/signin-link", json={"token": token, "flow": o["flow"], "credential": credential}, headers=there) + assert r.status_code == 200, r.text + assert _signin(client, laptop, headers=there, origin="https://lens.example.com").status_code == 200 + assert client.get("/api/v1/auth/passkeys/elsewhere", headers=here).json() == [{"url": "https://lens.example.com", "passkey": True}] + assert client.post("/api/v1/auth/signin-link/info", json={"token": token}).status_code == 404 # used up + assert "passkey.elsewhere" in db.values("SELECT VALUE action FROM audit_log") + + +def test_the_addresses_lens_opens_at(db, cfg, monkeypatch): + assert passkeys.addresses(db, cfg) == [] + cfg["tunnel"] = {"mode": "managed", "hostname": "Lens.Example.com"} + cfg["https"] = {"enabled": True, "domains": ["lens.example.com", "home.example.org", "*.example.org"]} + monkeypatch.setenv("LENS_HTTPS_PORT", "8443") + assert passkeys.addresses(db, cfg) == ["https://lens.example.com", "https://lens.example.com:8443", "https://home.example.org:8443"] + cfg["tunnel"]["mode"] = "off" + cfg["https"]["enabled"] = False + assert passkeys.addresses(db, cfg) == [] + + def test_sign_in_links_for_new_people(app, client, db): admin = _session(client, _setup(app, client, Authenticator())) settings.save(db, app.state.archive.base, "auth", {"passwords": False}) diff --git a/nextjs-frontend/__tests__/passkeys-panel.test.tsx b/nextjs-frontend/__tests__/passkeys-panel.test.tsx new file mode 100644 index 000000000..37c3b44bf --- /dev/null +++ b/nextjs-frontend/__tests__/passkeys-panel.test.tsx @@ -0,0 +1,83 @@ +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { fireEvent, render, screen, waitFor } from "@testing-library/react"; +import "@testing-library/jest-dom"; + +import { Auth } from "@/app/openapi-client"; +import { PasskeysPanel } from "@/components/account/passkeys"; +import { TooltipProvider } from "@/components/ui/tooltip"; +import { navigate } from "@/lib/navigate"; + +jest.mock("@/app/openapi-client", () => ({ + Auth: { + listPasskeys: jest.fn(), + listIdentities: jest.fn(), + passkeyAddresses: jest.fn(), + passkeyElsewhere: jest.fn(), + }, +})); +jest.mock("next-auth/react", () => ({ useSession: () => ({ data: { accessToken: "t" } }) })); +jest.mock("@/components/ui/toast", () => ({ useToast: () => jest.fn() })); +jest.mock("@/lib/navigate", () => ({ navigate: { assign: jest.fn(), replace: jest.fn() } })); + +const ok = (data: unknown) => Promise.resolve({ data, response: { ok: true, status: 200 } }); +const LAPTOP = { + id: "p1", + name: "Laptop", + rp_id: "localhost", + backed_up: false, + created_at: "2026-10-15T10:00:00Z", + last_used_at: null, +}; + +function show() { + const qc = new QueryClient({ defaultOptions: { queries: { retry: false }, mutations: { retry: false } } }); + return render( + + + + + , + ); +} + +describe("Passkeys at Lens's other addresses", () => { + const assign = navigate.assign as jest.Mock; + + beforeEach(() => { + assign.mockReset(); + (Auth.listPasskeys as jest.Mock).mockReset().mockImplementation(() => ok([LAPTOP])); + (Auth.listIdentities as jest.Mock).mockReset().mockImplementation(() => ok([])); + (Auth.passkeyElsewhere as jest.Mock).mockReset(); + }); + + it("opens an address you have no passkey for signed in, to add one there", async () => { + (Auth.passkeyAddresses as jest.Mock) + .mockReset() + .mockImplementation(() => ok([{ url: "https://lens.example.com", passkey: false }])); + (Auth.passkeyElsewhere as jest.Mock).mockImplementation(() => + ok({ url: "https://lens.example.com/signin-link#abc", expires_at: "2026-10-15T12:15:00Z", emailed: false }), + ); + show(); + expect(await screen.findByText("https://lens.example.com")).toBeInTheDocument(); + fireEvent.click(screen.getByRole("button", { name: "Open signed in" })); + await waitFor(() => expect(assign).toHaveBeenCalledWith("https://lens.example.com/signin-link#abc")); + expect((Auth.passkeyElsewhere as jest.Mock).mock.calls[0][0].body).toEqual({ url: "https://lens.example.com" }); + }); + + it("just links to an address you have a passkey for", async () => { + (Auth.passkeyAddresses as jest.Mock) + .mockReset() + .mockImplementation(() => ok([{ url: "https://lens.example.com", passkey: true }])); + show(); + const open = await screen.findByRole("link", { name: "Open" }); + expect(open).toHaveAttribute("href", "https://lens.example.com"); + expect(screen.queryByRole("button", { name: "Open signed in" })).not.toBeInTheDocument(); + }); + + it("says nothing when Lens opens nowhere else", async () => { + (Auth.passkeyAddresses as jest.Mock).mockReset().mockImplementation(() => ok([])); + show(); + expect(await screen.findByText("Laptop")).toBeInTheDocument(); + expect(screen.queryByText(/Lens also opens at/)).not.toBeInTheDocument(); + }); +}); diff --git a/nextjs-frontend/__tests__/webauthn.test.ts b/nextjs-frontend/__tests__/webauthn.test.ts index bac9dc8c9..48e77fc8d 100644 --- a/nextjs-frontend/__tests__/webauthn.test.ts +++ b/nextjs-frontend/__tests__/webauthn.test.ts @@ -3,6 +3,7 @@ import { deviceName, fromB64url, passkeyErrorMessage, + passkeySignInMessage, prfRequestOptions, requestOptions, signWithPasskeyPrf, @@ -42,6 +43,14 @@ describe("passkey helpers", () => { expect(passkeyErrorMessage(new DOMException("x", "InvalidStateError"), true)).toMatch(/already has a passkey/); }); + it("points a failed sign-in to the address the passkey was made at", () => { + expect(passkeySignInMessage(new DOMException("x", "NotAllowedError"))).toMatch( + /only at the address it was made at/, + ); + expect(passkeySignInMessage(new DOMException("x", "NotAllowedError"))).toMatch(/Open signed in/); + expect(passkeySignInMessage(new DOMException("x", "SecurityError"))).not.toMatch(/Open signed in/); + }); + it("suggests a name from the device", () => { expect(deviceName("Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)")).toBe("iPhone"); expect(deviceName("Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0)")).toBe("Mac"); diff --git a/nextjs-frontend/app/openapi-client/index.ts b/nextjs-frontend/app/openapi-client/index.ts index aca62b586..b1fe8e144 100644 --- a/nextjs-frontend/app/openapi-client/index.ts +++ b/nextjs-frontend/app/openapi-client/index.ts @@ -2381,7 +2381,17 @@ export type { PageVersionResponses, Passage, Passkey, + PasskeyAddress, + PasskeyAddressAsk, + PasskeyAddressesData, + PasskeyAddressesResponse, + PasskeyAddressesResponses, PasskeyAnswer, + PasskeyElsewhereData, + PasskeyElsewhereError, + PasskeyElsewhereErrors, + PasskeyElsewhereResponse, + PasskeyElsewhereResponses, PasskeyLoginData, PasskeyLoginError, PasskeyLoginErrors, diff --git a/nextjs-frontend/app/openapi-client/sdk.gen.ts b/nextjs-frontend/app/openapi-client/sdk.gen.ts index 938954b91..331eea1ff 100644 --- a/nextjs-frontend/app/openapi-client/sdk.gen.ts +++ b/nextjs-frontend/app/openapi-client/sdk.gen.ts @@ -1158,6 +1158,11 @@ import type { PageVersionData, PageVersionErrors, PageVersionResponses, + PasskeyAddressesData, + PasskeyAddressesResponses, + PasskeyElsewhereData, + PasskeyElsewhereErrors, + PasskeyElsewhereResponses, PasskeyLoginData, PasskeyLoginErrors, PasskeyLoginResponses, @@ -2281,6 +2286,41 @@ export class Auth { }); } + /** + * Passkey Addresses + * + * The other https:// addresses Lens opens at (Settings › Remote access and HTTPS), and whether you have a passkey + * for each: a passkey works only on the address it was made at. + */ + public static passkeyAddresses( + options?: Options, + ): RequestResult { + return (options?.client ?? client).get({ + url: "/api/v1/auth/passkeys/elsewhere", + ...options, + }); + } + + /** + * Passkey Elsewhere + * + * A sign-in link of your own at another address Lens opens at, to sign in there and add a passkey for it, with no + * email and no admin. It lasts 15 minutes and works once; links others have are left alone. For people signed in + * themselves, not API tokens or apps. Audited as `passkey.elsewhere`. + */ + public static passkeyElsewhere( + options: Options, + ): RequestResult { + return (options.client ?? client).post({ + url: "/api/v1/auth/passkeys/elsewhere", + ...options, + headers: { + "Content-Type": "application/json", + ...options.headers, + }, + }); + } + /** * External Providers * diff --git a/nextjs-frontend/app/openapi-client/types.gen.ts b/nextjs-frontend/app/openapi-client/types.gen.ts index 03f677cbf..86c0cf941 100644 --- a/nextjs-frontend/app/openapi-client/types.gen.ts +++ b/nextjs-frontend/app/openapi-client/types.gen.ts @@ -14733,6 +14733,37 @@ export type Passkey = { [key: string]: unknown; }; +/** + * PasskeyAddress + */ +export type PasskeyAddress = { + /** + * Url + * + * an https:// address Lens opens at besides this one (Remote access, HTTPS) + */ + url: string; + /** + * Passkey + * + * whether you have a passkey for it: a passkey works only where it was made + */ + passkey: boolean; + [key: string]: unknown; +}; + +/** + * PasskeyAddressAsk + */ +export type PasskeyAddressAsk = { + /** + * Url + * + * one of GET /auth/passkeys/elsewhere's addresses + */ + url: string; +}; + /** * PasskeyAnswer */ @@ -25725,6 +25756,49 @@ export type RenamePasskeyResponses = { export type RenamePasskeyResponse = RenamePasskeyResponses[keyof RenamePasskeyResponses]; +export type PasskeyAddressesData = { + body?: never; + path?: never; + query?: never; + url: "/api/v1/auth/passkeys/elsewhere"; +}; + +export type PasskeyAddressesResponses = { + /** + * Response Auth-Passkey Addresses + * + * Successful Response + */ + 200: Array; +}; + +export type PasskeyAddressesResponse = PasskeyAddressesResponses[keyof PasskeyAddressesResponses]; + +export type PasskeyElsewhereData = { + body: PasskeyAddressAsk; + path?: never; + query?: never; + url: "/api/v1/auth/passkeys/elsewhere"; +}; + +export type PasskeyElsewhereErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type PasskeyElsewhereError = PasskeyElsewhereErrors[keyof PasskeyElsewhereErrors]; + +export type PasskeyElsewhereResponses = { + /** + * Successful Response + */ + 200: SigninLink; +}; + +export type PasskeyElsewhereResponse = PasskeyElsewhereResponses[keyof PasskeyElsewhereResponses]; + export type ExternalProvidersData = { body?: never; path?: never; diff --git a/nextjs-frontend/components/account/passkeys.tsx b/nextjs-frontend/components/account/passkeys.tsx index 237091550..4f22de6e6 100644 --- a/nextjs-frontend/components/account/passkeys.tsx +++ b/nextjs-frontend/components/account/passkeys.tsx @@ -1,10 +1,10 @@ "use client"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { Fingerprint, Pencil, Trash2 } from "lucide-react"; +import { Fingerprint, Globe, Pencil, Trash2 } from "lucide-react"; import { useEffect, useState } from "react"; -import { Auth, type Passkey } from "@/app/openapi-client"; +import { Auth, type Passkey, type PasskeyAddress } from "@/app/openapi-client"; import { Banner } from "@/components/ui/banner"; import { Button, IconButton } from "@/components/ui/button"; import { Input } from "@/components/ui/field"; @@ -13,6 +13,7 @@ import { DateTime, Skeleton } from "@/components/ui/states"; import { useToast } from "@/components/ui/toast"; import { data, useApiClient } from "@/lib/api/browser"; import { createPasskey, deviceName, passkeyErrorMessage, passkeysUnavailableReason } from "@/lib/auth/webauthn"; +import { navigate } from "@/lib/navigate"; /** Your passkeys: add one on this device (or a phone), rename them, remove ones you no longer use (never the last). */ export function PasskeysPanel() { @@ -26,6 +27,11 @@ export function PasskeysPanel() { // an outside account (Google, GitHub, ...) is another way in, so then the last passkey can go too const identities = useQuery({ queryKey: ["identities"], queryFn: () => data(Auth.listIdentities({ client })) }); const refresh = () => void qc.invalidateQueries({ queryKey: ["passkeys"] }); + // the other https:// addresses Lens opens at (Remote access, HTTPS): a passkey works only on the one it was made at + const elsewhere = useQuery({ + queryKey: ["passkeys", "elsewhere"], + queryFn: () => data(Auth.passkeyAddresses({ client })), + }); const add = useMutation({ mutationFn: async () => { @@ -86,11 +92,47 @@ export function PasskeysPanel() { No passkeys yet. Add one so you can sign in without a password.

)} + {elsewhere.data?.length ? : null} ); } +/** Opens another address Lens is at signed in (a sign-in link of your own, 15 minutes), to add a passkey there. */ +function OtherAddresses({ addresses, onError }: { addresses: PasskeyAddress[]; onError: (e: string) => void }) { + const client = useApiClient(); + const go = useMutation({ + mutationFn: (url: string) => data(Auth.passkeyElsewhere({ client, body: { url } })), + onSuccess: (link) => navigate.assign(link.url), + onError: (e) => onError(e.message), + }); + return ( +
+

+ Lens also opens at {addresses.length === 1 ? "this address" : "these addresses"}. Open one signed in and add a + passkey there, with no sign-in link to ask for. +

+
    + {addresses.map((a) => ( +
  • + + {a.url} + {a.passkey ? ( + + ) : ( + + )} +
  • + ))} +
+
+ ); +} + function PasskeyRow({ passkey: p, last, diff --git a/nextjs-frontend/components/auth/passkey-button.tsx b/nextjs-frontend/components/auth/passkey-button.tsx index 62b9c7f5a..6dffdba2a 100644 --- a/nextjs-frontend/components/auth/passkey-button.tsx +++ b/nextjs-frontend/components/auth/passkey-button.tsx @@ -7,7 +7,7 @@ import { useEffect, useState } from "react"; import { AuthAlert } from "@/components/auth/auth-card"; import { finishSignIn, passkeyTicket } from "@/components/auth/passkey-flows"; import { Button } from "@/components/ui/button"; -import { passkeyErrorMessage, passkeysUnavailableReason } from "@/lib/auth/webauthn"; +import { passkeySignInMessage, passkeysUnavailableReason } from "@/lib/auth/webauthn"; /** * "Sign in with a passkey": the browser lists the passkeys made for this site (or offers a phone nearby), and a @@ -35,7 +35,7 @@ export function PasskeySignIn({ try { await finishSignIn(await passkeyTicket(), callbackUrl); } catch (err) { - setError(passkeyErrorMessage(err)); + setError(passkeySignInMessage(err)); setBusy(false); } } diff --git a/nextjs-frontend/lib/auth/webauthn.ts b/nextjs-frontend/lib/auth/webauthn.ts index 69892c8c1..32b8c838e 100644 --- a/nextjs-frontend/lib/auth/webauthn.ts +++ b/nextjs-frontend/lib/auth/webauthn.ts @@ -179,6 +179,17 @@ export function passkeyErrorMessage(err: unknown, making = false): string { return err instanceof Error && err.message ? err.message : "Something went wrong with the passkey."; } +/** + * What to tell someone whose passkey sign-in failed. A passkey belongs to the address it was made at, so a closed + * prompt at a new address (a tunnel or domain) usually means their passkey lives at the other one. + */ +export function passkeySignInMessage(err: unknown): string { + const name = err instanceof DOMException || err instanceof Error ? err.name : ""; + const text = passkeyErrorMessage(err); + if (name !== "NotAllowedError" && name !== "AbortError") return text; + return `${text} A passkey works only at the address it was made at. Made yours at another address? Sign in there, then choose Open signed in under Profile › Passkeys.`; +} + /** A suggested name for a new passkey: the kind of device it's made on. */ export function deviceName(ua = typeof navigator === "undefined" ? "" : navigator.userAgent): string { if (/iPhone/.test(ua)) return "iPhone"; diff --git a/nextjs-frontend/openapi.json b/nextjs-frontend/openapi.json index 208c512d6..a3aedb1ef 100644 --- a/nextjs-frontend/openapi.json +++ b/nextjs-frontend/openapi.json @@ -1204,6 +1204,72 @@ } } }, + "/api/v1/auth/passkeys/elsewhere": { + "get": { + "tags": [ + "auth" + ], + "summary": "Passkey Addresses", + "description": "The other https:// addresses Lens opens at (Settings \u203a Remote access and HTTPS), and whether you have a passkey\nfor each: a passkey works only on the address it was made at.", + "operationId": "passkey_addresses", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/PasskeyAddress" + }, + "type": "array", + "title": "Response Auth-Passkey Addresses" + } + } + } + } + } + }, + "post": { + "tags": [ + "auth" + ], + "summary": "Passkey Elsewhere", + "description": "A sign-in link of your own at another address Lens opens at, to sign in there and add a passkey for it, with no\nemail and no admin. It lasts 15 minutes and works once; links others have are left alone. For people signed in\nthemselves, not API tokens or apps. Audited as `passkey.elsewhere`.", + "operationId": "passkey_elsewhere", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PasskeyAddressAsk" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SigninLink" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, "/api/v1/auth/external": { "get": { "tags": [ @@ -56781,6 +56847,43 @@ ], "title": "Passkey" }, + "PasskeyAddress": { + "properties": { + "url": { + "type": "string", + "title": "Url", + "description": "an https:// address Lens opens at besides this one (Remote access, HTTPS)" + }, + "passkey": { + "type": "boolean", + "title": "Passkey", + "description": "whether you have a passkey for it: a passkey works only where it was made" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "url", + "passkey" + ], + "title": "PasskeyAddress" + }, + "PasskeyAddressAsk": { + "properties": { + "url": { + "type": "string", + "maxLength": 300, + "title": "Url", + "description": "one of GET /auth/passkeys/elsewhere's addresses" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "url" + ], + "title": "PasskeyAddressAsk" + }, "PasskeyAnswer": { "properties": { "flow": { diff --git a/threat-model.json b/threat-model.json index cac7ce9f8..63f7a16b0 100644 --- a/threat-model.json +++ b/threat-model.json @@ -287,6 +287,15 @@ "provenance": "documented", "source": "docs/authentication.md \"A link lasts three days\"" }, + { + "entry_point": "POST /auth/passkeys/elsewhere", + "parameter": "an address to take your sign-in to", + "attacker_controllable": "yes", + "component": "identity", + "caller_must_enforce": "signed in themselves, not API tokens or apps; only an address Lens opens at; 15 minutes, once, other links left alone", + "provenance": "documented", + "source": "docs/authentication.md \"Lens opens at another address\"" + }, { "entry_point": "/oauth/register, /authorize, /token, /revoke", "parameter": "redirect URIs, client metadata, code, verifier, refresh token", @@ -1032,7 +1041,7 @@ "property": "P-LIFETIMES", "violation_symptom": "bad-data-accepted", "severity_tier": "correctness", - "conditions": "access JWT 900 s; sign-in link 72 h, emailed links 60 min; OAuth code 5 min; app tokens 60 min / 30 days; API tokens default 90 days, never past tokens.max_days", + "conditions": "access JWT 900 s; sign-in link 72 h, emailed links 60 min, your own link to another address 15 min; OAuth code 5 min; app tokens 60 min / 30 days; API tokens default 90 days, never past tokens.max_days", "provenance": "documented", "source": "docs/authentication.md \"A link lasts three days\"" }, diff --git a/threat-model.md b/threat-model.md index 402f27192..8775999ee 100644 --- a/threat-model.md +++ b/threat-model.md @@ -271,6 +271,7 @@ classified by gate only *(inferred, Q8)*; unread modules are listed in Q34. | `POST /auth/login`, `/iiif/auth/access` form | email, password | yes, anonymous | data, size/rate | none; passwords work only where `auth.passwords` is on | *(documented, docs/authentication.md "With passwords off, password sign-in")* | | `/auth/setup`, `/auth/passkey/setup*`, `/auth/setup/no-passkey` | setup code, email, name | yes, anonymous | data | keep the log private until the first admin exists | *(documented, docs/configuration.md "so a stranger who finds a new")* | | `/auth/refresh`, `/auth/ticket`, `/auth/signin-link/*`, `/auth/password/*`, WebAuthn flows | rotating and one-time secrets | yes | data | holder keeps them secret | *(documented, docs/authentication.md "A link lasts three days")* | +| `POST /auth/passkeys/elsewhere` | an address to take your sign-in to | yes, by someone signed in themselves (not API tokens or apps) | resource-name | only an address Lens opens at (the tunnel's, HTTPS's domains), so the link can't point elsewhere; it lasts 15 minutes, works once and leaves other links alone; a session could already add a passkey where it is | *(documented, docs/authentication.md "Lens opens at another address")* | | `/oauth/register`, `/authorize`, `/token`, `/revoke` | redirect URIs, client metadata, code, verifier, refresh token | yes; registration is anonymous, authorize runs in the victim's browser | data, resource-name | the app keeps `state` and its verifier; the person consents | *(documented, docs/authentication.md "Apps register themselves")* | | `/auth/external/{key}/*` | `next`, `state`, `code`, provider profile | yes; profile only as far as the provider allows | data, x-collaborator-data | admin chooses providers | *(documented, docs/authentication.md "when the provider vouches for the email")* | | `POST /sources/rclone-signin`, `/sources/rclone-signin/{id}` (signing a source in through rclone) | `type`, `params`, `address` (`state`, `code`, `error`), the token rclone prints | yes; admins start it; while it waits (ten minutes, one at a time) rclone listens on 127.0.0.1:53682 on the server, so anything running there can reach it, and the pasted address is passed on only to that port with only its state, code and error, when the state is this sign-in's | data, x-collaborator-data | the person pastes only the address their own sign-in ended on; the host keeps 127.0.0.1:53682 to itself | *(documented, docs/processing.md "Lens passes only that address's state, code and")* | @@ -523,7 +524,7 @@ Paths in the Voided by column are relative to `fastapi_backend/app/`. Searches c | P-SETUP-ONCE | No public sign-up. Only the one-time setup code makes the first admin, and it dies once an account exists. | integrity-bypass | security-critical | *(documented, docs/configuration.md "so a stranger who finds a new")* | Voided by: `LENS_ADMIN_EMAIL` makes an admin with no code — `domain/setup.py:75-77`; `LENS_SETUP_CODE` fixes the code — `core/runtime.py:62`; the code is logged — `core/runtime.py:64-68`; plain HTTP (§1.6). | | P-ONCE | Sign-in links, WebAuthn flows, sign-in tickets, OAuth codes and external-login states work once. A refused or failed attempt consumes nothing. | integrity-bypass | security-critical | *(documented, docs/authentication.md "works once")* | Voided by: nothing. Search: `grep -rnE 'RETURN BEFORE' fastapi_backend/app/domain/passkeys.py fastapi_backend/app/domain/oauth.py fastapi_backend/app/domain/external_login.py` — every consumer deletes the row before trusting it. A new admin-issued sign-in link replaces older ones by design. | | P-REUSE | A rotated web refresh token replayed after 60 s ends the whole session. A rotated OAuth refresh token replayed within 60 s is refused and changes nothing; after that it ends the grant. A spent OAuth code replayed ends the grant. | integrity-bypass | security-critical | *(documented, docs/authentication.md "A swapped one that comes back within 60 seconds is refused")* | Voided by: The 60 s grace window — `domain/auth.py:25`, `domain/oauth.py:318`. | -| P-LIFETIMES | Access JWT 900 s; sign-in link 72 h, emailed links 60 min; OAuth code 5 min; app tokens 60 min / 30 days; API tokens default 90 days, never past `tokens.max_days`. | bad-data-accepted | correctness-only | *(documented, docs/authentication.md "A link lasts three days")* | Voided by: Admin token settings; the API-key cap check — `domain/auth.py:282`. | +| P-LIFETIMES | Access JWT 900 s; sign-in link 72 h, emailed links 60 min, your own link to another address 15 min; OAuth code 5 min; app tokens 60 min / 30 days; API tokens default 90 days, never past `tokens.max_days`. | bad-data-accepted | correctness-only | *(documented, docs/authentication.md "A link lasts three days")* | Voided by: Admin token settings; the API-key cap check — `domain/auth.py:282`. | | P-OAUTH | PKCE (S256) is required. Redirects must match a registered URI; addresses with a user name or backslash are refused. The consent page cannot be framed. App tokens act as the person and never administer. `/mcp` refuses a token issued for another server, caps bodies at 1 MB and batches at 20. A namespace's own MCP server (`/mcp/`) sees that namespace alone, and a token issued for it (its RFC 8707 resource) opens that server and nothing else, the API included. | integrity-bypass | security-critical | *(documented, docs/authentication.md "PKCE is required")* | Voided by: `tokens.oauth_enabled` off — `domain/oauth.py:54`. Loopback redirects may change the port — `domain/oauth.py:114`. Tokens naming no server pass `/mcp` — `api/mcp.py:228-229` (Q13). PKCE has no switch: `grep -n "code_challenge" fastapi_backend/app/domain/oauth.py` — enforced on every authorize and token path. | | P-PASSWORDS-OFF | With passwords off, password sign-in, changes and resets answer 403. | integrity-bypass | security-critical | *(documented, docs/authentication.md "With passwords off, password sign-in")* | Voided by: `auth.passwords` on; gate `auth.passwords_on` — `domain/auth.py:85`; `grep -rn "passwords_on" fastapi_backend/app` — `auth.py`, `users.py`, `passkeys.py`, `external.py`. | | P-THROTTLE | Failed password sign-ins are throttled per email and address (8 per 15 minutes). Unknown emails take as long to reject as wrong passwords. In both compose files each visitor gets their own throttle. | x-brute-force | correctness-only | *(documented, docs/authentication.md "throttled per email and address")* | Voided by: Per-process counters — `domain/auth.py:24`; visitor address from trusted proxies — `api/deps.py:339-346`. | diff --git a/threat-model.yaml b/threat-model.yaml index 0568ca938..7b13b2250 100644 --- a/threat-model.yaml +++ b/threat-model.yaml @@ -205,6 +205,15 @@ entry_points: obligation_id: keep-one-time-secrets caller_must_enforce: "holder keeps them secret" provenance: {kind: documented, source: 'docs/authentication.md "A link lasts three days"'} + - id: "POST /auth/passkeys/elsewhere" + component: identity + parameters: + - name: "an address to take your sign-in to" + attacker_controllable: true + x-condition: "signed in themselves; not API tokens or apps" + control_kinds: [resource-name] + caller_must_enforce: "only an address Lens opens at (tunnel, HTTPS domains); 15 minutes, once, other links left alone" + provenance: {kind: documented, source: 'docs/authentication.md "Lens opens at another address"'} - id: "/oauth/register, /authorize, /token, /revoke" component: identity parameters: @@ -1476,7 +1485,7 @@ properties_claimed: components: [identity] tier: correctness-only x-tier-question: Q37 - conditions: "access JWT 900 s; sign-in link 72 h, emailed links 60 min; OAuth code 5 min; app tokens 60 min / 30 days; API tokens default 90 days, never past tokens.max_days" + conditions: "access JWT 900 s; sign-in link 72 h, emailed links 60 min, your own link to another address 15 min; OAuth code 5 min; app tokens 60 min / 30 days; API tokens default 90 days, never past tokens.max_days" violation_symptoms: [bad-data-accepted] x-voided-by: "admin token settings; the API-key cap check (domain/auth.py:282)" provenance: {kind: documented, source: 'docs/authentication.md "A link lasts three days"'}