You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve WellKnownWebAuthnView reference docs based on feedback; combine content in PR#73, thereby creating a how-to guide section; guide on how to configure for related origins; move the guides in Customizing behavior to the how-to guide section
Copy file name to clipboardExpand all lines: docs/customizing_behavior.rst
-9Lines changed: 0 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -45,12 +45,3 @@ Customizing frontend
45
45
--------------------
46
46
47
47
The frontend implementation in this library supports customization only through CSS. For any additional customization, you have to create your own implementation. As long as you call the same API endpoints and use the same JSON structure, you can still use all other components of this package, including views and models.
48
-
49
-
50
-
.. toctree::
51
-
:maxdepth:2
52
-
:hidden:
53
-
54
-
Customize views <customize_views.rst>
55
-
Customize helper class <customize_helper_class.rst>
Copy file name to clipboardExpand all lines: docs/glossary.rst
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,9 @@ Glossary
9
9
authenticator
10
10
An authenticator is a software or hardware implementation of the client side of the Web Authentication standard. It manages the cryptographic parts of the process. When a user registers or logs in with a credential, the browser usually presents several authenticator options. Common examples include Chrome Password Manager, a USB key, iCloud Keychain, or a smartphone.
11
11
12
+
country code top-level domain (ccTLD)
13
+
A specific type of top-level domain (TLD) that is associated with a particular country or territory. It consists of two letters and is used to identify websites related to that country. For example, ".uk" for the United Kingdom or ".de" for Germany.
14
+
12
15
credential ID
13
16
A unique identifier generated by the authenticator when creating a WebAuthn credential. Credential ID consists of a random sequence of bytes and is used in negotiations between the browser and the server.
14
17
@@ -34,6 +37,9 @@ Glossary
34
37
relying party
35
38
The entity that relies on the Web Authentication standard to authenticate users. This refers to you, as you are using Web Authentication to authenticate your users.
36
39
40
+
relying party ID (rpID)
41
+
The domain of the website or service where a passkey can be used, without including protocol, port, or path. For example, ``acbde.com``. It ties the passkey to a specific domain to prevent phishing. Subdomains match a parent rpID, but not the other way around. The rpID is included in WebAuthn login requests and verified by the browser against the current page's origin.
42
+
37
43
resident key
38
44
An alternative term for a for a passkey or resident key. It refers to a WebAuthn credential that allows authentication without the server providing credential IDs.
You can use ``WellKnownWebAuthnView`` to configure your application to use the same :term:`WebAuthn credentials <WebAuthn credential>` across multiple domains. For example, if your main application runs on ``https://example.com`` and you have a localized version on ``https://example.co.uk`` and ``https://example.de``.
5
+
6
+
Set up the URL
7
+
--------------
8
+
9
+
Modify your ``<project>/urls.py`` file and add the required URL configuration:
10
+
11
+
.. code-block:: py
12
+
13
+
from django.urls import path
14
+
from django_otp_webauthn.views import WellKnownWebAuthnView
Now in your ``<project>/settings.py`` file, add your related origins to ``OTP_WEBAUTHN_RP_RELATED_ORIGINS``. The related origins must use ``HTTPS``, except for localhost origins which can use ``HTTP`` for local development:
24
+
25
+
.. code-block:: py
26
+
27
+
OTP_WEBAUTHN_RP_RELATED_ORIGINS= [
28
+
"https://example.com",
29
+
"https://example.co.uk",
30
+
"https://example.de",
31
+
"https://app.example.com"
32
+
]
33
+
34
+
For more information, see the reference docs on :ref:`WellKnownWebAuthnView <wellknownwebauthnview>`.
Copy file name to clipboardExpand all lines: docs/reference/views.rst
+58-5Lines changed: 58 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -38,12 +38,65 @@ Finally, the system logs in the user associated with the ``WebAuthnCredential``
38
38
WellKnownWebAuthnView
39
39
---------------------
40
40
41
-
``WellKnownWebAuthnView`` supports WebAuthn across related origins.
41
+
``WellKnownWebAuthnView`` supports :term:`WebAuthn` across related origins. The view permits public access, doesn't require authentication, and accepts only ``GET`` requests. It also accepts origins that use ``https`` or ``http://localhost`` for local development, and caches responses for 10 minutes.
42
42
43
-
The view returns a JSON response containing the list of related origins configured in the ``OTP_WEBAUTHN_RP_RELATED_ORIGINS`` setting. This allows :term:`WebAuthn credentials <WebAuthn credential>` to work across multiple domains that share the same :term:`relying party`.
43
+
Use cases
44
+
~~~~~~~~~
44
45
45
-
The view permits public access, doesn't require authentication, and accepts only GET requests. Also, Responses are cached for 10 minutes.
46
+
Two use cases necessitate allowing requests from related origins.
46
47
47
-
You can Configure this view at the ``/.well-known/webauthn`` URL. Define the ``OTP_WEBAUTHN_RP_RELATED_ORIGINS`` setting as a list of secure origins.
48
+
The first use case is deployments that use different :term:`country code top-level domains (ccTLD) <country code top-level domain (ccTLD)>` worldwide. For example, a grocery website might use ``https://grocery.com`` for users in the United States, ``https://grocery.co.uk`` for the United Kingdom, and ``https://grocery.de`` for Germany.
48
49
49
-
The view accepts only origins that use ``https`` or ``http://localhost`` for local development.
50
+
The second use case is for organizations that offer additional services with different or extended branding and share the same accounts. For example, a grocery website may have a website for taking orders from buyers and a separate website for tracking delivery.
51
+
52
+
How it works
53
+
~~~~~~~~~~~~
54
+
55
+
``WellKnownWebAuthnView`` works by allowing a :term:`relying party` to provide a list of valid origins for a given :term:`relying party ID (rpID)`.
56
+
57
+
During a WebAuthn operation, the browser checks whether the current origin matches the rpID. If the origin and rpID differ, and the client supports related origin requests, the browser queries the ``/.well-known/webauthn`` endpoint hosted at the rpID. The server responds with a JSON document that includes a top-level ``origins`` key, with a list of related origins as its value. The browser verifies the list and continues with authentication if the current origin is included.
58
+
59
+
The browser processes this list using **labels**. A label refers to the part of the domain directly preceding the top-level domain. For example, ``grocery`` is the label for domains like ``https://grocery.com``, ``https://grocery.co.uk``, and ``https://grocery.de``. This grouping allows browsers to support origin lists efficiently without processing excessive unique entries.
60
+
61
+
Client implementations shouldn't support more than five labels. So if the list contains 30 domains that all share the label ``grocery``, the browser counts these as a single unique label.
62
+
63
+
Configuration
64
+
~~~~~~~~~~~~~
65
+
66
+
To support related origins, define the list of allowed origins in the ``OTP_WEBAUTHN_RP_RELATED_ORIGINS`` setting. Each origin must use ``https``, except for ``http://localhost`` during development.
67
+
68
+
Also, a JSON document must be hosted at the WebAuthn well-known path for the rpID, ``/.well-known/webauthn``. For example, if the rpID is ``grocery.com``, the full URL would be ``https://grocery.com/.well-known/webauthn``. The server must also respond with a content type of ``application/json``. The JSON response must contain the list of related origins configured in ``OTP_WEBAUTHN_RP_RELATED_ORIGINS`` in the ``<project>/settings.py`` file.
69
+
70
+
Here is an example configuration in the ``<project>/settings.py`` file:
71
+
72
+
.. code-block:: py
73
+
74
+
OTP_WEBAUTHN_RP_RELATED_ORIGINS= [
75
+
"https://grocery.com",
76
+
"https://grocery.co.uk",
77
+
"https://grocery.de",
78
+
]
79
+
80
+
The JSON response will look like this:
81
+
82
+
.. code-block:: json
83
+
84
+
{
85
+
"origins": [
86
+
"https://grocery.com",
87
+
"https://grocery.co.uk",
88
+
"https://grocery.de",
89
+
]
90
+
}
91
+
92
+
Choosing rpID
93
+
~~~~~~~~~~~~~
94
+
95
+
The most important decision when configuring your application for related origins is choosing a primary rpID. All related origins must use the primary rpID for authentication. You should select the domain most closely tied to your brand, usually the ``.com`` domain.
96
+
97
+
Existing deployments that already use multiple rpIDs face different challenges. The system must maintain backward compatibility while implementing the related origins feature. Users with passkeys tied to the local rpID can continue normal operations, while those with credentials from other origins require additional steps. The solution requires each existing rpID to serve its well-known WebAuthn document listing all authorized origins. The backend must track which rpID created each passkey through explicit metadata or derived information. The login interface must handle cases where automatic recognition fails by implementing username-based lookup flows that redirect users to the correct authentication endpoint.
98
+
99
+
Browser compatibility
100
+
~~~~~~~~~~~~~~~~~~~~~
101
+
102
+
All deployments must account for browser compatibility since not all browsers support related origin requests. The system should detect browser capabilities and provide fallback authentication methods when needed. For the list of supported browsers, see `Matrix <https://passkeys.dev/device-support/#matrix>`_.
0 commit comments