Install dependencies:
bundle
Follow the instructions (here)[https://admin.passwordless.dev/signup] to create a Passwordless.dev account with Bitwarden. Then create your free application. You will be given three values: An API URL, an API private key, and an API public key. Create a .env file and provide these values:
BITWARDEN_PASSWORDLESS_API_URL=
BITWARDEN_PASSWORDLESS_API_PRIVATE_KEY=
BITWARDEN_PASSWORDLESS_API_PUBLIC_KEY=
Ensure you have Postgresql installed and running locally. Then run:
rails db:create
rails db:migrate
rails s
- Install Devise and associate it to a
User
model. You can optionally remove the password field before running the migration. - Install the Bitwarden Passwordless.dev JS client using your choice of package manager. The example uses
import-maps
. - Add the Devise module and strategy from lib/devise in this example.
- Generate the Devise controller for
sessions
and configure your routes like so:
devise_for :users, controllers: {
sessions: "users/sessions"
}
- Replace the contents of
app/controllers/users/sessions.rb
with the contents of the matching file in this example. - Add the Stimulus controller in
app/javascript/controllers/passwordless_controller.js
. - Navigate to your new combined signup/login page and test it out.