Skip to content

Bug: Invite passkey registration uses internal hostname (localhost) instead of siteUrl #994

Closed

Description

@digi4care

Description

When a new user accepts an invite and tries to register a passkey, the WebAuthn registration fails with "Security error. Make sure you're on a secure connection."

Root Cause

packages/core/src/astro/routes/api/auth/invite/register-options.ts line 55 calls getPasskeyConfig(url, siteName) without passing the siteUrl parameter:

// BROKEN — missing siteUrl
const passkeyConfig = getPasskeyConfig(url, siteName);

This causes getPasskeyConfig to fall back to url.hostname, which is the internal hostname (localhost) when running behind a TLS-terminating reverse proxy (Traefik, nginx, etc.). The browser then rejects the WebAuthn registration because the RP ID (localhost) does not match the actual origin (staging.example.com).

Expected Behavior

The invite register-options endpoint should resolve the public origin the same way every other passkey endpoint does:

// FIXED — resolve siteUrl from config / EMDASH_SITE_URL env var
const siteUrl = getPublicOrigin(url, emdash?.config);
const passkeyConfig = getPasskeyConfig(url, siteName, siteUrl);

Comparison With Working Endpoints

All other passkey registration endpoints correctly pass siteUrl:

Endpoint File Passes siteUrl?
Admin setup setup/admin.ts:67-68 ✅
Add passkey (authed) passkey/register/options.ts:56-57 ✅
Passkey login passkey/options.ts:67-68 ✅
Passkey verify passkey/verify.ts:38-43 ✅
Signup complete signup/complete.ts:42-47 ✅
Invite complete invite/complete.ts:42-47 ✅
Invite register-options invite/register-options.ts:55 ❌

Reproduction

  1. Deploy EmDash behind a TLS-terminating reverse proxy with EMDASH_SITE_URL=https://staging.example.com
  2. Log in as admin and invite a new user
  3. New user opens invite link (correctly shows https://staging.example.com)
  4. User tries to register a passkey → "Security error" because the WebAuthn RP ID is localhost

Environment

  • EmDash via Docker (Node.js adapter)
  • Behind Traefik reverse proxy (TLS termination)
  • EMDASH_SITE_URL set correctly in container env
  • Passkey login works fine for existing admin users (only invite flow is broken)

Activity

  1. digi4care commented on May 11, 2026

    @digi4care
    Author

    Proof of fix

    I patched the bundled register-options_D9cNRkR4.mjs on our staging deployment to confirm the diagnosis:

    +import { a as getPublicOrigin } from ./public-url_CaGH3ATc.mjs;
    
    -    const passkeyConfig = getPasskeyConfig(url, siteName);
    +    const siteUrl = getPublicOrigin(url, emdash?.config);
    +    const passkeyConfig = getPasskeyConfig(url, siteName, siteUrl);

    Before patch: invite passkey registration fails with "Security error. Make sure you're on a secure connection." — the browser rejects the WebAuthn call because rpId is localhost instead of the actual domain.

    After patch: invite passkey registration works correctly. The new user can register their passkey and log in.

    The fix is confirmed. The one-line change (resolving siteUrl via getPublicOrigin before calling getPasskeyConfig) is all that is needed.

  2. ascorbic commented on May 12, 2026

    @ascorbic
    Member

    /bonk fix this pls

  3. ask-bonk commented on May 12, 2026

    @ask-bonk
    Contributor

    Created PR #1000

    github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions