Repository navigation
feat: passkeys - #13983
feat: passkeys#13983
Conversation
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
🟢 Tier S · Ready to mergeAdds WebAuthn passkey enrollment, account and administrative management, and usernameless sign-in through the existing token-to-session flow. Introduces relying-party policies, encrypted ceremony storage, schema migrations, MFA integration, and concurrency coverage, and makes login-token exchanges single-use. Also updates OAuth2 state handling, migration cleanup, and deletion-worker iteration; the latest changes introduce an explicit secret-bearing token response model and filter sign-in credential fields. Latest changes: The newest commits register a TokenSecret response model, use it for completed passkey sign-in instead of temporarily exposing sensitive fields, and allowlist top-level WebAuthn credential fields before verification.
📂 Walkthrough · 33
Reviewed the commits since |
|
|
@greptile review |
… holds The column only carries passkey ceremony state, so `data` told a reader of the challenges table nothing. It stays JSON because it is read once by ID and deleted, never queried.
The passkey name is metadata the owner can already change; server keys get the same through PATCH /users/:userId/passkeys/:passkeyId, mirroring the account rename.
…dator The RP ID rule (lowercase, not an IP, below a public suffix) is a domain rule, not a passkey one, so it moves to utopia-php/domains as RegistrableDomain next to PublicDomain and ApexDomain. The passkey-only part, allowing localhost, stays at the call site.
Sign-in methods are switched through auth methods and no other policy mirrors one, so the passkey policy keeps only the relying party: rpId and origins. The method's state reads from project.authMethods, which shows passkey from the 2.4.0 response format.
updatePasskeyVerification took both the passkey ID and its challenge ID, though the pending passkey already identifies its ceremony. It now stores the challenge ID it was issued with and verification consumes that one, so clients pass only the passkey ID and credential, as with MFA authenticators. The stored ID also replaces the registration nonce: a restarted registration points to its own challenge.
# Conflicts: # composer.lock
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
…list the credential showSensitive() is reserved for event payloads, so updatePasskeyToken returns the new TokenSecret model, which exposes the secret the caller has just proven it may hold (as MFAChallengeSecret does for challenge codes). The guest-supplied credential is reduced to the members of PublicKeyCredential.toJSON() before it reaches the ceremony.
Adds passkeys (WebAuthn) as a usernameless sign-in method for existing accounts. Tracks appwrite-labs/cloud#5805. Console: appwrite/vibes#489.
Design
account.createSession(per the Linear thread). Cookies, limits, alerts, events and audits are reused with no session-issuance refactor.PATCH /v1/project/policies/passkey:rpId,origins). It's toggled withproject.updateAuthMethod('passkey'), off by default, and fails closed until configured.utopia-php/auth(packages/auth/src/Passkeys:Ceremony,RelyingParty,Origin,Counter, plus docs and unit tests). It wrapsweb-auth/webauthn-lib^5.3, which the package lists as a suggested dependency so it keeps no hard Composer dependencies. Appwrite keeps a thinCeremonysubclass (fromProject()and storage types) and the RP ID validator, which needsutopia-php/domains. User deletion now cleans up authenticators and challenges.updatePasskeyTokenreturns theTokenSecretmodel, aTokenwhose secret is not sensitive, since the caller has just proven possession (asMFAChallengeSecretdoes for challenge codes). The guest-supplied credential is reduced to the members ofPublicKeyCredential.toJSON()before the ceremony.PATCH /account/passkeys/:id(rename),GET/PATCH/DELETE /users/:userId/passkeys[/:id](admin, PATCH renames).[201,201,201,201,201]. It passes on PostgreSQL, MariaDB and MongoDB (replica set).createSession: the token was deleted after the session was created, so concurrent exchanges of one token could each create a session. The token is now claimed with an atomic delete before any session is issued. A regression test fires 5 concurrent exchanges and expects exactly one 201 and one stored session; it failed before the fix,[201,201,401,401,401]. This covers every token login (magic URL, OTP, phone, OAuth2, custom), not only passkeys.Schema
No new collections. Two existing project collections get new columns, added to existing projects by the V25 migration:
authenticatorsidentifierstring(64), nullable, unique index_key_identifierauthenticatorsnamestring(128), nullabledata, so renames are plain updates andlistPasskeyscan query it.authenticatorsaccessedAtdatetime, nullable, index_key_accessedAtchallengespasskeystring(16384), encrypted JSONauthenticatorsdocument withtype=passkey, reusing the existing columns:verified,userId/userInternalId, anddata(encrypted) for the WebAuthn credential record (public key, sign counter, backup flags) and, while a registration is pending, the ID of its challenge, which verification consumes. That is the same roledataalready plays for TOTP secrets.nameandaccessedAtare their own columns, solistPasskeysandusers.listPasskeysaccept queries on both. TOTP rows leave them null.identifiernull. PostgreSQL and MariaDB allow repeated nulls under a unique index, and the Mongo adapter builds unique indexes with a partial filter, so they don't collide.challenges.passkeystays JSON on purpose: it's read once by ID, then deleted, and never queried. Expired leftovers go through the existing challenge cleanup in the deletes worker. MFA challenges keep usingtoken/codeand leave it null.rpIdandoriginsare stored in the project's existingauthsJSON aspasskeyRpIdandpasskeyOrigins.Decisions, based on how other providers do it
mfaUpdatedAtuser_reauthentication_requiredexcludeCredentialsFollow-ups: conditional UI (autofill) helpers in the SDKs, AAGUID-based default names, passkey signup.
E2E
PasskeysCustomClientTesthas 24 tests: ownership, wrong origin/RP/project/challenge, forged and malformed credentials, replay, concurrency (exactly one of 5 parallel verifications wins), cap, toggle-off, RP lock, unverified/anonymous/blocked/deleted/recreated users, MFA, rename, and admin rename and delete. A software authenticator (packages/auth/tests/Passkeys/Authenticator.php) builds real CBOR/ES256 credentials and is shared with the package's 35 unit tests. Existing AuthMethods, Policies, Projects, MFA and token-session suites pass. The stale-session rejection has no e2e yet because it needs a 10-minute wait.Browser run: Chrome virtual authenticator against a demo app on
http://localhost:5173.The passkey suite passes on PostgreSQL, MariaDB and MongoDB. Upgrade path: I dropped the new column, index and metadata from a project that already had TOTP authenticators, ran
migrate, confirmed the unique index was recreated with null identifiers allowed, and re-ran the browser flow.