A Stimulus controller to implement web authn client side.
$ yarn add stimulus-web-authn
Register the controller with Stimulus:
// application.js
import { Application } from "@hotwired/stimulus"
import WebAuthnController from "stimulus-web-authn"
const application = Application.start()
application.register("web-authn", WebAuthnController)
<div
data-controller="web-authn"
data-web-authn-loading-class="web-authn-loading"
data-web-authn-challenge-url-value="https://myapp.com/two_factor_authentication/challenge/web_authn/new"
data-web-authn-verification-url-value="https://myapp.com/two_factor_authentication/challenge/web_authn"
data-web-authn-fallback-url-value="/two_factor_authentication/challenge">
<button name="button" type="button" data-web-authn-target="button" data-action="web-authn#getCredential">
Use security key
</button>
<p data-web-authn-target="error" hidden></p>
</div>
Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.
This project is released under the MIT license.