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. 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 the 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 same file in the example - Add the Stimulus controller in
app/javascript/controllers/passwordless_controller.js
- Generate the Devise views. Take the view for a new session and replace it with the contents of
app/views/devise/sessions/new.html.erb
in the example - Navigate to your new combined signup/login page and test it out.