WebAuthn RP ID: choose the domain scope for passkeys
The RP ID scopes a WebAuthn credential to a domain. A broader parent domain can share credentials across subdomains, but also expands the code and origin trust boundary.
WebAuthn RP ID: choose the domain scope for passkeys
A WebAuthn relying party identifier (RP ID) is a domain string that scopes a public-key credential, such as a passkey. By default it is the effective domain of the current web origin. A service may choose an equal or registrable parent-domain suffix when the WebAuthn rules allow it. A broader RP ID can make one credential usable at more subdomains, but it also expands the set of origins and code that must be secured.
An origin contains a scheme, host, and port, such as https://login.example.com:8443. An RP ID contains only a domain name, with no scheme or port. For a web page at https://login.example.com, the default is login.example.com; example.com is also a valid explicit choice, while m.login.example.com and com are not.
| Current origin | Default RP ID | Valid explicit example | Invalid examples |
|---|---|---|---|
https://login.example.com | login.example.com | example.com | m.login.example.com, com |
http://localhost:8000 | localhost | localhost | an unrelated domain |
For web origins, HTTPS is required, except that HTTP is allowed for localhost development. The port is unrestricted. Related Origin Requests can define a separately validated exception in environments that support it; do not assume that exception is a general RP ID rule or that a given browser supports a particular configuration.
The RP ID determines the credential scope. If login.example.com and shop.example.com both use example.com, the same credential can be used at both origins. This can simplify a product with several subdomains, but a compromised or attacker-controlled subdomain can put credentials in the same security boundary. The W3C advises RPs not to accept unexpected subdomain origins by default. If a deployment needs them, it must not serve untrusted code on allowed subdomains within the credential scope. RP ID scope does not replace server-side origin validation.
Before choosing a value, list every sign-in, account-management, and embedded-app origin that really needs the credential. Start with the narrowest RP ID and share a parent domain only for a documented product need. Keep the same RP ID for registration and authentication; changing it can make existing credentials unusable and may require re-registration or a migration plan. Validate the response origin separately, including scheme, host, and port, against the deployed allowlist. Review ownership and deployment controls for every subdomain in scope, including third-party hosting, user content, temporary services, and stale DNS. Separate test and production domains and plan recovery before switching.
If registration raises SecurityError, check whether the chosen RP ID is more specific than the page host or crosses the registrable-domain boundary. If registration works but a passkey is not offered at sign-in, compare the RP ID used by creation and request options. If the RP ID hash matches but the server rejects the response, inspect the expected-origin list and its scheme/host/port matching. Before expanding the scope, decide how existing credentials and sessions will be handled; changing the RP ID does not automatically convert them.
Sources
[W3C Web Authentication Level 3](https://www.w3.org/TR/webauthn-3/)
[W3C WebAuthn Level 3, Origin validation](https://www.w3.org/TR/webauthn-3/#sctn-verifying-origin)