Passkey Authentication #19629
Replies: 1 comment
-
|
I searched issues instead of discussions. There is an existing discussion for the same request. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Passkeys offer a fresh take on password-free and soon, even username-free logins.
In non-enterprise Directus setups without SAML, passkeys are valuable for bolstering secure authentication and access.
Basic Example
No response
Motivation
Enhanced Security: Harder to guess than regular passwords.
Simplicity: Easier to remember or manage.
Quick Entry: Faster login process.
No Reuse: Passkeys are often temporary, reducing risk of reuse.
Phishing Resistance: Less vulnerable to phishing attacks.
and we are willing to sponsor this feature.
Detailed Design
Terminology
WebAuthn: Web Authentication API for public key-based credentials.
Passkey: A hardware device, mobile device, or biometric data used for authentication.
Credential ID: A unique identifier for each passkey.
Requirements:
Directus 9.x or higher
WebAuthn-compatible browser
Hardware key (e.g., YubiKey), or a biometric-enabled device
Data Model Changes:
Add new columns in the directus_users table:
webauthn_credential_id (String)
webauthn_public_key (String)
It actually might be more ideal to have a separate table for the keys, as in the future you might want to bring support to multiple keys per user.
API Endpoints:
POST /auth/webauthn-register: Register a new passkey.
Input: credential
Output: success: true/false
POST /auth/webauthn-auth: Authenticate using a passkey.
Input: assertion
Output: JWT token
Workflow:
Register Passkey: User chooses to register a new WebAuthn device. The frontend requests the POST /auth/webauthn-register endpoint.
Corner Case: If the user already has a registered device, ask to overwrite or add another.
Store Credentials: After successful registration, store webauthn_credential_id and webauthn_public_key in the directus_users table.
Authenticate: When logging in, the user can choose WebAuthn. The frontend calls POST /auth/webauthn-auth.
Corner Case: If the device isn't recognized, fallback to password login.
Example Use Cases:
User registers their fingerprint and logs in using it.
User tries to authenticate with an unrecognized device, and the system falls back to password login.
Security Considerations:
Implement rate limiting on WebAuthn registration and authentication endpoints.
Frontend Changes:
Add a "Register WebAuthn Device" button in user settings.
Add a "Login with WebAuthn" button on the login screen.
Backend Changes:
Integrate a WebAuthn library to handle registration and authentication.
Testing:
Unit tests for WebAuthn registration and authentication.
End-to-end tests for logging in with and without a passkey.
Requirements List
Must-Have:
directus_userstable must support WebAuthn fields (webauthn_credential_id,webauthn_public_key).POST /auth/webauthn-registerandPOST /auth/webauthn-auth.Should-Have:
Could-Have:
Won't-Have (this time):
Drawbacks
Alternatives
Two-Factor Authentication (2FA): Use SMS or authenticator apps for additional security.
OAuth Providers: Using Google, Facebook, etc., for login.
Biometric Authentication: Use native biometrics (fingerprint, face recognition) of devices.
Passwordless Email Links: Send one-time-use login links via email.
Impact of Not Implementing WebAuthn
Adoption Strategy
Adoption:
Breaking Change:
Migration:
directus_userstable.Impact on Other Directus Projects:
In summary, this should be a smooth, non-breaking change that adds an extra layer of security, provided it's implemented carefully with good documentation.
Unresolved Questions
No response
Beta Was this translation helpful? Give feedback.
All reactions