Skip to content

feat(passkeys): take passkey origins from web platforms - #14310

Merged
ChiragAgg5k merged 6 commits into
mainfrom
feat/passkey-onboarding
Oct 9, 2026
Merged

ChiragAgg5k merged 6 commits into
mainfrom
feat/passkey-onboarding

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Passkeys only worked once the passkey policy had a relying party ID and a hand-typed list of origins, even though the project's web platforms already list the hostnames the app runs on. Of the providers we compared, only Ory asks for both by hand. Supabase, Hanko, Descope and Better Auth derive the relying party ID, and Auth0 and Stytch reuse their existing allowed-domains list for origins.

This PR is the server side. The Console side is #14313, which depends on it.

  • Origins come only from platforms. Allowed origins are the project's web platforms on the relying party ID or its subdomains (https://<hostname>). Wildcard platforms count too: *.example.com allows any subdomain, but not example.com itself. Every web origin that can call Appwrite is already a web platform, so a separate list only added a second source of truth that could bypass the first.
  • The policy API takes only rpId. PATCH /project/policies/passkey no longer accepts origins. The policy's origins is now read-only and computed from the platforms, so the Console and API users see exactly where passkeys work. Passkeys haven't shipped in any release or SDK yet, so this breaks no one.
  • Apple apps. A project with an Apple platform also allows https://<relying party ID>, which is the origin native iOS and macOS passkey ceremonies report.
  • localhost without setup. A localhost web platform gives local development its own localhost relying party, on any port. The request's origin is now passed into Ceremony::fromProject(), so a request from localhost uses it even when a production domain is configured, and local testing and production no longer compete for the one relying party ID. Requests without an origin (server-side) use the configured relying party.
  • The Console's own project has no platforms, so it keeps its origins from _APP_CONSOLE_PASSKEY_ORIGINS, which the API can't change.
  • utopia-php/auth. A portless http://localhost origin allows any port, a wildcard origin allows subdomains on the default port, and an empty allow-list now fails closed (the WebAuthn library otherwise falls back to matching the relying party ID alone). Origins with a path, query, fragment or credentials are rejected.

Out of scope, as follow-ups: Android native passkeys (android:apk-key-hash: origins need a signing certificate fingerprint on Android platforms), hosting apple-app-site-association / assetlinks.json / /.well-known/webauthn for domains on Appwrite Sites, and recording each passkey's relying party ID so local passkeys stop counting towards the relying party ID lock.

Demo

A real WebAuthn registration and sign-in from http://localhost:5173 against this branch (Chrome with a virtual authenticator). The project's relying party ID is example.com; the request from localhost got the localhost relying party automatically.

Demo app

Test Plan

  • tests/e2e/Services/Account/PasskeysCustomClientTest.php: 27 tests, including origins from web platforms (and what they reject: sibling subdomains, other ports, http, unrelated platforms), wildcard platforms, the Apple origin, the read-only origins in the policy, zero-config localhost, and localhost beside a production domain.
  • AccountConsolePasskeysTest, PoliciesCustomServerTest and tests/unit/Auth/Passkey pass.
  • packages/auth CeremonyTest covers a portless localhost origin across ports, wildcard origins (subdomains allowed; apex, lookalikes, http, ports and paths rejected), and that a portless origin outside localhost only allows the default port. The new tests fail without the change.
  • PHPStan, Pint, Rector and bin/monorepo check auth pass.

Related PRs and Issues

Follow-up to #13983. Console: #14313.

Related: appwrite-labs/cloud#5805

@luxor-code-review

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

Copy link
Copy Markdown

Review complete. 🟡 2 medium

💬 Inline comments (2)

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Console localhost-origin mirror drops https://localhost (passkey-policy.ts:59) — The doc comment says platformPasskeyOrigins() mirrors Appwrite\Auth\Passkey\Ceremony::getOrigins(), but for a localhost relying party the server derives both http://localhost and https://localhost (src/Appwrite/Auth/Passkey/Ceremony.php:73-74) while the client adds only http://localhost (apps/console/src/lib/passkey-policy.ts:59-61).

The PR implements platform-derived passkey relying parties: the ceremony computes allowed origins from the project's web platforms with a localhost any-port special case, and HTTP actions pass the request Origin to Ceremony::fromProject().

Files Change
packages/auth/src/Passkeys/Ceremony.php, src/Appwrite/Auth/Passkey/Ceremony.php, packages/auth/tests/Passkeys/CeremonyTest.php WebAuthn ceremony with dynamic origin sets, localhost handling, and unit tests
src/Appwrite/Platform/Modules/Account/Http/Account/Passkeys/*, Account/Tokens/Passkey/* Registration, verification, and token challenge endpoints wired to the request origin
src/Appwrite/Platform/Modules/Project/Http/Project/Policies/Passkey/Update.php, src/Appwrite/Utopia/Response/Model/PolicyPasskey.php Passkey policy update endpoint and response model
apps/console/src/lib/passkey-policy.ts, apps/console/src/components/pages/projects/$projectId/auth/* Console enablement dialog, policy card, and origin-mirroring helpers
tests/e2e/Services/Account/PasskeysCustomClientTest.php, apps/console/e2e/console.mocked.passkeys.spec.ts E2E and mocked-console coverage for platform-derived origins and localhost flows

Reviewed commit: 9ee9c60

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 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.

@ghost

ghost commented Oct 9, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Passkey ceremonies now derive allowed origins from a project's web and Apple platforms, with localhost support alongside a production relying party. The passkey policy exposes computed origins and accepts only an RP ID, while Console-configured origins remain supported; the added tests cover the new origin rules and flows.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 13
File Change
packages/auth/src/Passkeys/Ceremony.php Choose response origins per ceremony and match wildcard and portless-localhost origins.
packages/auth/tests/Passkeys/CeremonyTest.php Cover wildcard-origin and portless-localhost verification behavior.
src/Appwrite/Auth/Passkey/Ceremony.php Derive project relying parties and policy origins from configured platforms.
src/Appwrite/Platform/Modules/Account/Http/Account/Passkeys/Create.php Pass request origin into registration ceremony selection.
src/Appwrite/Platform/Modules/Account/Http/Account/Passkeys/Verification/Update.php Pass request origin into registration verification.
src/Appwrite/Platform/Modules/Account/Http/Account/Tokens/Passkey/Create.php Pass request origin into sign-in ceremony selection.
src/Appwrite/Platform/Modules/Account/Http/Account/Tokens/Passkey/Update.php Pass request origin into sign-in verification.
src/Appwrite/Platform/Modules/Project/Http/Project/Policies/Get.php Return computed passkey origins in the policy response.
src/Appwrite/Platform/Modules/Project/Http/Project/Policies/Passkey/Update.php Limit passkey policy updates to the relying party ID.
src/Appwrite/Platform/Modules/Project/Http/Project/Policies/XList.php Return computed passkey origins in policy listings.
src/Appwrite/Utopia/Response/Model/PolicyPasskey.php Describe passkey origins as read-only, platform-derived values.
tests/e2e/Services/Account/PasskeysCustomClientTest.php Exercise platform-derived origins, localhost behavior, and the RP ID policy contract.
tests/unit/Auth/Passkey/CeremonyTest.php Cover project relying-party selection and platform-derived origins.

Reviewed 0677f2b · 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

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

This PR adds passkey (WebAuthn) support: a ceremony library in packages/auth and src/Appwrite/Auth/Passkey, Account endpoints for passkey registration, sign-in and token challenges that derive allowed origins from the project's web platforms, a project passkey policy endpoint and response model, plus console UI and e2e coverage.

Key findings

Comment thread packages/auth/src/Passkeys/Ceremony.php Resolved
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/passkey-onboarding (after).

Metric Before After Change
🚀 Requests/sec 201.48 218.04 🟢 +8.2%
⏱️ Latency P50 84.99 ms 81.09 ms ⚪ -4.6%
⏱️ Latency P95 204.61 ms 181.35 ms 🟢 -11.4%
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 81.09 181.35 13,680 218.04 -23.26
Account 154.07 276.36 720 12.12 -48.56
TablesDB 78.02 135.76 7,440 120.93 -19.97
Storage 76.81 163.71 3,600 60.39 -0.43
Functions 111.7 213.31 1,920 32.87 -31.67

Top API waits (after)

API request Max wait (ms)
account.name.update 421.47
functions.create 411.49
account.prefs.update 362.3
functions.variables.update 344.54
storage.buckets.create 342.13

Development servers pick their own port, so a project that trusts localhost should not have to list every one.
Projects already list the hostnames their app runs on as web platforms, so asking for the same origins again in the passkey policy made passkeys the only auth method that needed setup before it could be enabled. Origins in the policy now override the platforms instead of being required, and a localhost web platform gives local development its own relying party without touching the policy.
Native iOS and macOS ceremonies report the relying party ID itself as their origin, which no web platform under it covers.
@ChiragAgg5k
ChiragAgg5k force-pushed the feat/passkey-onboarding branch from 8d751b7 to 09c30fb Compare October 9, 2026 13:36
@ChiragAgg5k ChiragAgg5k changed the title feat(passkeys): derive passkey origins from web platforms and enable passkeys in one step feat(passkeys): take passkey origins from web platforms Oct 9, 2026
ghost
ghost previously requested changes Oct 9, 2026

@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 B · 1 blocking finding to address. Summary

Comment thread src/Appwrite/Auth/Passkey/Ceremony.php Resolved
…low-list

Wildcard web platforms such as *.example.com have to work once platforms are the only source of origins. An empty list made the WebAuthn library fall back to matching the RP ID alone.
A second list that overrides the platforms could silently bypass them (a localhost platform still worked past an explicit list), and every web origin that can call Appwrite is already a platform. The policy now takes only the relying party ID; its origins are computed from the platforms so the console and API users see where passkeys work.
@ghost
ghost dismissed their stale review October 9, 2026 14:02

The findings that requested changes are resolved. See the summary comment for what is still open.

ghost
ghost previously requested changes Oct 9, 2026

@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 B · 1 blocking finding to address. Summary

Comment thread src/Appwrite/Auth/Passkey/Ceremony.php Resolved
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

@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 B · See the inline comments. Summary

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review — the remaining thread is resolved: the passkey code has never been in any release branch, tag or Cloud tag, so no project can have stored passkeyOrigins.

@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 B · See the inline comments. Summary

The console project's origins come from configuration, and any project that stored origins through the earlier policy API keeps working as it did. Saving the relying party ID no longer drops them.
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

@ghost
ghost dismissed their stale review October 9, 2026 14:34

The findings that requested changes are resolved. See the summary comment for what is still open.

@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

@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

@ChiragAgg5k
ChiragAgg5k merged commit e243531 into main Oct 9, 2026
69 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat/passkey-onboarding branch October 12, 2026 09:05
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