Repository navigation
feat(passkeys): let the console sign in with passkeys - #14257
Conversation
The console project's relying party is the host of the console URL, so its passkeys never move once registered, and _APP_CONSOLE_PASSKEY_ORIGINS adds origins under that host such as preview consoles. A URL that cannot be a relying party leaves console passkeys off.
|
Review complete. 🟠 1 high 💬 Inline comments (1)
This PR wires passkey authentication into the console project's auth config through a new environment variable, deriving the relying-party ID from the configured console URL and normalizing additional origins against it.
Reviewed commit: b68519c |
🟢 Tier S · Ready to mergeAdds passkey support for console accounts by deriving the console relying-party ID and allowed origins from the console URL and optional preview-origin configuration. Includes configuration wiring and unit and end-to-end coverage for console passkey registration, sign-in, and rejected origins or credentials. Latest changes: The newest commit converts the unit-test cases to a yielding iterator and renames the test method to snake_case.
📂 Walkthrough · 7
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
There was a problem hiding this comment.
Adds operator-configurable WebAuthn passkey support for the Appwrite Console via a new _APP_CONSOLE_PASSKEY_ORIGINS env var, deriving the RP ID from _APP_CONSOLE_URL and folding the resulting auth keys into the console project config, with unit and e2e coverage.
Key findings
- 🟠 Upgraded installs never re-merge passkey auths into console project — console.php:57
| 'invalidateSessions' => true | ||
| 'invalidateSessions' => true, | ||
| // Passkey sign-in bound to the console's host; _APP_CONSOLE_PASSKEY_ORIGINS adds origins under it | ||
| ...PasskeyConsole::getAuths(Config::getParam('platform')['consoleUrl'], System::getEnv('_APP_CONSOLE_PASSKEY_ORIGINS', '')), |
There was a problem hiding this comment.
🟠 bug · high
Upgraded installs never re-merge passkey auths into console project
_APP_CONSOLE_PASSKEY_ORIGINS and the derived rpId are folded into the console project's auths only when the config document is materialized at install time (app/config/console.php:57, consumed via app/init/resources.php:83). Migration V25 creates the passkey challenge attribute but never updates the persisted console project document's auths array, and no other task re-merges env-derived console config on upgrade, even though V16-V18 established exactly that merge pattern for new auth keys. On an upgraded self-hosted instance the persisted console document keeps its install-time auths without the passkey key, so the gate ($auths['passkey'] ?? false) !== true at app/controllers/shared/api/auth.php:124 keeps rejecting console passkey sign-in regardless of the operator's env configuration.
📋 Prompt for AI Agents
In src/Appwrite/Migration/Version/V25.php, in the case 'projects': branch guarded by $collectionType === 'console' (around lines 63-87), after the attribute/index work, fetch the console project document from the platform DB and merge in only the passkey auth keys from Config::getParam('console')['auths'] (passkey, passkeyRpId, passkeyOrigins) using a sparse updateDocument with array_merge($document->getAttribute('auths', []), $passkeyAuths). This is needed because app/config/console.php line 57 computes these keys from _APP_CONSOLE_PASSKEY_ORIGINS and _APP_CONSOLE_URL at config-load time, but existing installations' console project documents were written at install time without them, so the gate at app/controllers/shared/api/auth.php:124 (($auths['passkey'] ?? false) !== true) keeps passkey sign-in disabled after upgrading even when the env vars are set. Follow the auths-merge pattern of src/Appwrite/Migration/Version/V17.php line 264.
There was a problem hiding this comment.
Not an issue: the console project is never stored or read from the platform database. For project=console the request resolver returns the console resource (app/init/resources/request.php, if ($projectId === '' || $projectId === 'console') return $console;), and that document is built from Config::getParam('console') on every request (app/init/resources.php). The passkey auths are therefore evaluated from the current env at boot, on fresh and upgraded installs alike; a restart after changing _APP_CONSOLE_URL or _APP_CONSOLE_PASSKEY_ORIGINS is all it takes. V17's auths merge targets user projects, which are persisted.
There was a problem hiding this comment.
That's a well-reasoned explanation, and the key claim — that the console project document is never persisted to the platform DB, but instead reconstructed from Config::getParam('console') on every request — would fully resolve the finding if accurate. The logic at app/init/resources.php:83 building the in-memory console document from config on each boot would mean the passkey auths from console.php:57 are always current with the env vars, making a DB migration merge unnecessary.
However, I can't verify this from the current diff alone. The critical path is in app/init/resources.php and app/init/resources/request.php, neither of which appears in the PR's changed files. Could you confirm by checking whether app/init/resources.php (or the request resolver) contains a guard like if ($projectId === 'console') return $console; that bypasses any DB lookup? If that guard is present and the in-memory $console document is built entirely from config, the finding would be a false positive and can be resolved.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Console sign-in moved to its own follow-up in review of appwrite#489 because the server had no relying party for the console project. appwrite#14257 adds one, so this restores the account Passkeys card behind flags-passkeys (always on self-hosted) and offers passkey autofill on the sign-in email field.
Lets people sign in to the Appwrite console with a passkey. Follow-up to #13983, which added passkeys for projects; console sign-in was split out of appwrite-labs/cloud#6185 in review so it could land in CE as well.
What changes
The built-in
consoleproject now carries a passkey relying party in itsauths:platform.consoleUrl:_APP_CONSOLE_URL, or the console domain over http/https when it is empty). It is derived rather than configurable on purpose: a passkey only works for the RP ID it was registered with, so a setting that can change, or a parent domain that can never be narrowed, would strand every console passkey._APP_CONSOLE_PASSKEY_ORIGINS(comma-separated, for preview consoles). Each must be HTTPS on the RP ID or a subdomain, or HTTP on localhost; invalid entries are ignored.The derivation lives in
Appwrite\Auth\Passkey\Console::getAuths()so Cloud, which builds its console document separately, uses the same rule.Local dev keeps working without configuration: the console URL is
http://localhost, so the RP ID islocalhost.Tests
tests/unit/Auth/Passkey/ConsoleTest.php: localhost, hosted, extra origins (normalised, de-duplicated, foreign and insecure ones dropped), public suffix, IP, plain HTTP and empty URL.tests/e2e/Services/Account/AccountConsolePasskeysTest.php: a console account registers a passkey, signs in usernameless and gets a working console session; a foreign origin and a deleted passkey are rejected. Without theconsole.phpchange it fails at registration (501user_auth_method_unsupported); with it it passes.PasskeysCustomClientTeststill passes (24/24).Console UI: appwrite/vibes follow-up to #489.
Related: appwrite-labs/cloud#5805