The project is in a healthy, maintained state
Authentication Strategy for OmniAuth to authenticate a user with an Ethereum account
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.1
~> 3.12

Runtime

~> 0.5
~> 2.1
 Project Readme

omniauth-ethereum

GitHub Workflow Status GitHub release (latest by date) Gem GitHub top language GitHub

Authentication Strategy for OmniAuth to authenticate a user with an Ethereum account.

Installation

Add omniauth-ethereum to your Gemspec.

gem 'omniauth-ethereum'

Rails Usage

  1. Configure config/routes.rb in rails to serve the following routes:
Rails.application.routes.draw do
  post '/auth/:provider/callback', to: 'sessions#create'
  post '/auth/ethereum', to: 'sessions#new'
  root to: 'sessions#index'
end
  1. Create a SessionsController for your app that enables an Ethereum authentication path.
class SessionsController < ApplicationController
  skip_before_action :verify_authenticity_token, only: :create

  def create
    if request.env['omniauth.auth']
      flash[:notice] = "Logged in"
    else
      flash[:notice] = "Unable to log in"
    end

    redirect_to '/'
  end

  def index
    render inline: "<%= button_to 'Sign in', auth_ethereum_path %>", layout: true
  end
end
  1. Add an Ethereum provider to your config/initializers/omniauth.rb middleware.
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :ethereum
end
  1. Add a notice class to your body templates relevant for authentication.
<p class="notice"><%= notice %></p>

Testing

Run the spec tests:

bundle install
bundle exec rspec --require spec_helper

Demo template

An example Rails app using omniauth-ethereum can be found at nahurst/omniauth-ethereum-rails.

License

The gem is available as open-source software under the terms of the Apache 2.0 License.