Skip to content

feat(passkeys): let the console sign in with passkeys - #14257

Merged
ChiragAgg5k merged 2 commits into
mainfrom
feat/console-passkeys
Oct 8, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
feat/console-passkeys

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

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 console project now carries a passkey relying party in its auths:

  • RP ID: the host of the console URL (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.
  • Origins: the console URL plus the new optional _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.
  • Enabled only when at least one origin is valid. A host that cannot be a relying party (an IP, a public suffix, plain HTTP on a domain) leaves console passkeys off.

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 is localhost.

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 the console.php change it fails at registration (501 user_auth_method_unsupported); with it it passes. PasskeysCustomClientTest still passes (24/24).

Console UI: appwrite/vibes follow-up to #489.

Related: appwrite-labs/cloud#5805

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.
@luxor-code-review

luxor-code-review Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 1 high

💬 Inline comments (1)

  • 🟠 Upgraded installs never re-merge passkey auths into console project — console.php:57

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.

Files Change
.env, docker-compose.yml, app/config/variables.php Introduce and document _APP_CONSOLE_PASSKEY_ORIGINS (introduction 2.4.0, default empty) and expose it on the appwrite service.
app/config/console.php Spreads PasskeyConsole::getAuths() output (passkey, passkeyRpId, passkeyOrigins) into the console project's auths, computed at config-load time from _APP_CONSOLE_URL and the new env var.
src/Appwrite/Auth/Passkey/Console.php New helper that derives the RP ID host from the console URL and normalizes each configured origin (HTTPS-enforcing, same-host/subdomain checks, empty entries filtered).
tests/unit/Auth/Passkey/ConsoleTest.php, tests/e2e/Services/Account/AccountConsolePasskeysTest.php Unit coverage of origin/RP-ID normalization edge cases (ports, localhost http, public suffixes, malformed URLs) and an e2e suite for console passkey enrollment/sign-in.
docker-compose.yml Passes the new variable to the main appwrite container; separate worker/scheduler profiles don't need it since passkey is HTTP-only.

Reviewed commit: b68519c

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 8, 2026
@ghost

ghost commented Oct 8, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Adds 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.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 7
File Change
.env Adds an empty default for the optional console passkey origins setting.
app/config/console.php Uses the derived passkey relying-party settings in the built-in console project.
app/config/variables.php Documents the optional console passkey origins environment variable.
docker-compose.yml Passes the console passkey origins setting to the Appwrite service.
src/Appwrite/Auth/Passkey/Console.php Derives the passkey RP ID and filters valid console and preview origins.
tests/e2e/Services/Account/AccountConsolePasskeysTest.php Covers console passkey registration, sign-in, and rejection cases through the API.
tests/unit/Auth/Passkey/ConsoleTest.php Covers origin derivation rules; the latest commit yields the cases and uses a snake_case test method.

Reviewed the commits since b68519c · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

32 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (17)
  • php.appwrite.permissive-write-permission (8)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread app/config/console.php
'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', '')),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/console-passkeys (after).

Metric Before After Change
🚀 Requests/sec 171.57 199.5 🟢 +16.3%
⏱️ Latency P50 99.05 ms 85.67 ms 🟢 -13.5%
⏱️ Latency P95 246.28 ms 211.55 ms 🟢 -14.1%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 85.67 211.55 12,540 199.5 -34.73
Account 168.8 352.63 660 11.02 -31.8
TablesDB 81.7 157.95 6,820 110.54 -25.59
Storage 79.01 175.4 3,300 55.56 -57.82
Functions 126.74 267.19 1,760 30.3 -33

Top API waits (after)

API request Max wait (ms)
account.name.update 499.6
account.prefs.update 475.64
functions.delete 458.23
functions.create 439.87
functions.variables.update 398.86

@ChiragAgg5k
ChiragAgg5k merged commit efc6f04 into main Oct 8, 2026
63 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat/console-passkeys branch October 8, 2026 11:36
AMRITESH240304 pushed a commit to AMRITESH240304/appwrite that referenced this pull request Oct 8, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant