
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@web-auth/webauthn-stimulus
Advanced tools
WebAuthn Stimulus controllers for passwordless authentication in web applications.
This package provides ready-to-use Stimulus controllers for implementing WebAuthn/FIDO2 authentication (passkeys) in your web applications. It wraps @simplewebauthn/browser to provide an easy-to-use interface for credential registration and authentication.
npm install @web-auth/webauthn-stimulus
This package requires:
@hotwired/stimulus ^3.0.0@simplewebauthn/browser ^13.2.0These are listed as peer dependencies and should be installed in your project.
If you're using a module bundler (webpack, Vite, etc.) without Symfony UX, you can import controllers directly:
// Import individual controllers
import { AuthenticationController, RegistrationController } from '@web-auth/webauthn-stimulus';
// Or import specific ones
import AuthenticationController from '@web-auth/webauthn-stimulus/src/authentication-controller.js';
// Register with Stimulus
import { Application } from '@hotwired/stimulus';
const app = Application.start();
app.register('webauthn--authentication', AuthenticationController);
authentication-controller.js)Handles user sign-in with existing credentials.
<form data-controller="webauthn--authentication"
data-webauthn--authentication-options-url-value="/auth/options"
data-webauthn--authentication-result-url-value="/auth/verify"
data-webauthn--authentication-conditional-ui-value="true"
data-action="submit->webauthn--authentication#authenticate">
<input type="text"
name="username"
autocomplete="username webauthn"
data-webauthn--authentication-target="username">
<input type="hidden" data-webauthn--authentication-target="result">
<button type="submit">Sign In</button>
</form>
Features:
registration-controller.js)Handles new credential registration (user sign-up).
<form data-controller="webauthn--registration"
data-webauthn--registration-options-url-value="/register/options"
data-webauthn--registration-result-url-value="/register/verify"
data-action="submit->webauthn--registration#register">
<input type="text"
name="username"
data-webauthn--registration-target="username">
<input type="text"
name="displayName"
data-webauthn--registration-target="displayName">
<select name="attestation" data-webauthn--registration-target="attestation">
<option value="none">None</option>
<option value="direct">Direct</option>
</select>
<input type="hidden" data-webauthn--registration-target="result">
<button type="submit">Register</button>
</form>
Features:
controller.js)Combined controller for backward compatibility. Handles both registration and authentication.
<form data-controller="webauthn">
<!-- Registration -->
<button data-action="webauthn#signup">Sign Up</button>
<!-- Authentication -->
<button data-action="webauthn#signin">Sign In</button>
</form>
| Value | Type | Description | Default |
|---|---|---|---|
optionsUrl | String | URL to fetch options from | Required |
resultUrl | String | URL to send result to | Required |
submitViaForm | Boolean | Submit via form instead of API | false |
successRedirectUri | String | Redirect URL after success | - |
| Value | Type | Description | Default |
|---|---|---|---|
conditionalUi | Boolean | Enable browser autofill | false |
verifyAutofillInput | Boolean | Verify autofill input exists | true |
| Value | Type | Description | Default |
|---|---|---|---|
autoRegister | Boolean | Enable auto-register mode | false |
All controllers dispatch custom events for integration:
webauthn:connect - Controller connectedwebauthn:options:request - Options requestedwebauthn:options:success - Options receivedwebauthn:authenticator:response - Authenticator respondedwebauthn:attestation:success - Registration successfulwebauthn:assertion:success - Authentication successfulwebauthn:unsupported - WebAuthn not supportedwebauthn:options:failure - Failed to get optionswebauthn:attestation:failure - Registration failedwebauthn:assertion:failure - Authentication faileddocument.addEventListener('webauthn:assertion:success', (event) => {
console.log('Authentication successful!', event.detail);
});
document.addEventListener('webauthn:assertion:failure', (event) => {
console.error('Authentication failed:', event.detail.exception);
});
Your backend needs to provide two endpoints per operation:
GET/POST) - Returns PublicKeyCredentialRequestOptionsPOST) - Verifies the authentication responseGET/POST) - Returns PublicKeyCredentialCreationOptionsPOST) - Verifies and stores the credentialSee @simplewebauthn/server for server-side implementation examples.
This package is designed to work seamlessly with the web-auth/webauthn-framework Symfony bundle:
composer require web-auth/webauthn-stimulus
When installed via Composer with Symfony Flex, the controllers are automatically registered and available in your Twig templates:
<form {{ stimulus_controller('@web-auth/webauthn-stimulus/authentication') }}>
{# ... #}
</form>
For detailed Symfony integration documentation, visit:
Requires browsers with WebAuthn support:
Check support at runtime:
import { browserSupportsWebAuthn } from '@simplewebauthn/browser';
if (browserSupportsWebAuthn()) {
// Show WebAuthn UI
}
<form data-controller="webauthn--authentication"
data-webauthn--authentication-options-url-value="/api/auth/options"
data-webauthn--authentication-result-url-value="/api/auth/verify"
data-webauthn--authentication-success-redirect-uri-value="/dashboard">
<!-- Form fields -->
</form>
<form data-controller="webauthn--registration"
data-webauthn--registration-options-url-value="/register/options"
data-webauthn--registration-submit-via-form-value="true">
<input type="hidden" data-webauthn--registration-target="result">
<!-- Form fields -->
</form>
<form data-controller="webauthn--authentication"
data-webauthn--authentication-conditional-ui-value="true">
<input type="text"
name="username"
autocomplete="username webauthn"
data-webauthn--authentication-target="username">
</form>
# Install dependencies
npm install
# Run tests
npm test
# Lint code
npm run lint
# Format code
npm run format
MIT - See LICENSE file for details.
This is a sub-package of the web-auth/webauthn-framework monorepo.
Please submit issues and pull requests to the main repository:
FAQs
Webauthn integration for Symfony
We found that @web-auth/webauthn-stimulus demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.