Skip to content

Commit d68ec2e

Browse files
authored
docs: update readme (#7)
* docs: update readme * docs: fix github actions badge
1 parent 65ab965 commit d68ec2e

File tree

1 file changed

+72
-5
lines changed

1 file changed

+72
-5
lines changed

README.md

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,77 @@
11
# omniauth-ethereum
2-
Implements the Ethereum provider strategy for OmniAuth
32

4-
To test
3+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/q9f/omniauth-ethereum/Test)](https://github.com/q9f/omniauth-ethereum/actions)
4+
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/q9f/omniauth-ethereum)](https://github.com/q9f/omniauth-ethereum/releases)
5+
[![Gem](https://img.shields.io/gem/v/omniauth-ethereum)](https://rubygems.org/gems/omniauth-ethereum)
6+
[![GitHub top language](https://img.shields.io/github/languages/top/q9f/omniauth-ethereum?color=red)](https://github.com/q9f/omniauth-ethereum/pulse)
7+
[![GitHub](https://img.shields.io/github/license/q9f/omniauth-ethereum)](LICENSE)
8+
9+
Authentication Strategy for [OmniAuth](https://github.com/omniauth/omniauth) to authenticate a user with an [Ethereum](https://ethereum.org) account.
10+
11+
### Installation
12+
Add `omniauth-ethereum` to your `Gemspec`.
13+
14+
```ruby
15+
gem 'omniauth-ethereum'
16+
```
17+
18+
### Rails Usage
19+
1. Configure `config/routes.rb` in rails to serve the following routes:
20+
21+
```ruby
22+
Rails.application.routes.draw do
23+
post '/auth/:provider/callback', to: 'sessions#create'
24+
post '/auth/ethereum', to: 'sessions#new'
25+
root to: 'sessions#index'
26+
end
527
```
6-
bundle
7-
rspec
28+
29+
2. Create a `SessionsController` for your app that enables an Ethereum authentication path.
30+
31+
```ruby
32+
class SessionsController < ApplicationController
33+
skip_before_action :verify_authenticity_token, only: :create
34+
35+
def create
36+
if request.env['omniauth.auth']
37+
flash[:notice] = "Logged in"
38+
else
39+
flash[:notice] = "Unable to log in"
40+
end
41+
42+
redirect_to '/'
43+
end
44+
45+
def index
46+
render inline: "<%= button_to 'Sign in', auth_ethereum_path %>", layout: true
47+
end
48+
end
849
```
950

10-
An [example Rails app using omniauth-ethereum](https://github.com/nahurst/omniauth-ethereum-rails)
51+
3. Add an Ethereum provider to your `config/initializers/omniauth.rb` middleware.
52+
53+
```ruby
54+
Rails.application.config.middleware.use OmniAuth::Builder do
55+
provider :ethereum
56+
end
57+
```
58+
59+
4. Add a `notice` class to your body templates relevant for authentication.
60+
61+
```html
62+
<p class="notice"><%= notice %></p>
63+
```
64+
65+
### Testing
66+
Run the spec tests:
67+
68+
```shell
69+
bundle install
70+
bundle exec rspec --require spec_helper
71+
```
72+
73+
### Demo template
74+
An example Rails app using omniauth-ethereum can be found at [nahurst/omniauth-ethereum-rails](https://github.com/nahurst/omniauth-ethereum-rails).
75+
76+
### License
77+
The gem is available as open-source software under the terms of the [Apache 2.0 License](LICENSE).

0 commit comments

Comments
 (0)