Skip to content
The simplest way to add passwordless authentication to your application
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Kno Ruby

Gem Version

Go Passwordless with

Use the Kno service for passwordless authentication, it handles sending emails so you don't have to. It also allows users to set up device-based authentication so they don't have to wait for any email (after the first).


Add kno as a dependency in your Gemfile:

gem 'kno'

Then, install it using bundler:

$ bundle install


This library integrates Kno into any Rack-based application, including Rails, Hanami and Sinatra.

Rails integration

Configure middleware

Add Kno::Session to the middleware stack, by configuring it in /my_app/config/application.rb

module MyApp
  class Application < Rails::Application
    # ...
    config.load_defaults 6.0

    config.middleware.use Kno::Session, sign_in_redirect: "/"

Make sure to add Kno::Session after the default middleware as it requires the session middleware to be applied.

Add sign in/out button

Use the helpers that Kno added to the request to show the correct sign in, or sign out, button.

<%= request.env['kno'].session_button().html_safe %>

Check the user is authenticated

Controllers can check if a user is authenticated by looking up their persona_id.

persona_id = request.env['kno'].persona_id

With Kno, users are uniquely identified by their persona_id. If the request is unauthenticated, then the value will be nil.

Local development

Authentication is now setup for local development. Run locally and click the sign in button and you should see a sign in modal.

Local development screenshot

Enter your real email address. Kno runs a service for local development that sends a limited number of emails.

Get production keys

To use Kno in production you will need site and API tokens for your application.

Create an account at and follow the guidance to create your first space. This will direct you to create a site_token and api_token. Add these to your environment and edit the middleware configuration.

config.middleware.use Kno::Session,
  sign_in_redirect: "/"
  site_token: ENV["KNO_SITE_TOKEN"],
  api_token: ENV["KNO_API_TOKEN"]

NOTE: The tokens do not have to be stored in the environment. However the api token MUST be kept secure and should not be committed to your applications source code.


Contributions are very welcome. Please do open an issue or pull request or reach out to us at


If you do not have node installed, you can run locally in Docker with the following command.

docker run \
  -it \
  --rm \
  -w="/opt/app" \
  -v="$(pwd):/opt/app" \
  --env="PORT=3000" \
  -p="3000:3000" \
  --network="host" \
  ruby:2.7.0 bash

NOTE: You will need to bundle install every time you start a container with this command

You can’t perform that action at this time.