Skip to content
🚪🏃Genkan is authentication engine for Rails
Branch: master
Clone or download
Latest commit e80c078 Sep 15, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app Add Genkan::ApplicationHelper Jul 25, 2017
bin Fix rubocop Jul 24, 2017
config Added locales Jul 6, 2017
lib Bump v0.2.3 Jul 25, 2017
spec Fix rubocop Jul 24, 2017
.gitignore Updated .gitignore Jul 6, 2017
.rspec Configure RSpec Jul 6, 2017
.rubocop.yml onkcop init Jul 24, 2017
.travis.yml CI against Ruby 2.4.2 Sep 14, 2017
Gemfile Fix rubocop Jul 24, 2017
Gemfile.lock Update Gemfile.lock Jul 25, 2017
MIT-LICENSE rails plugin new genkan -T --mountable Jul 4, 2017
README.md Updated README Jul 24, 2017
Rakefile Fix rubocop Jul 24, 2017
genkan.gemspec Fix rubocop Jul 24, 2017

README.md

Build Status Gem Version

Genkan is authentication engine for Rails

Installation

gem 'genkan'

# Add any omniauth provider
gem 'omniauth-google-oauth2'
gem 'omniauth-facebook'

And then execute:

$ bundle

Getting started

$ bin/rails g genkan:install --model User
      create  config/initializers/genkan.rb
      create  db/migrate/20170705074103_create_users.rb
      create  app/models/user.rb
      insert  app/controllers/application_controller.rb
       route  mount Genkan::Engine, at: '/'
      create  app/views/genkan/sessions/new.html.erb

$ bin/rails db:migrate

Some setup you must do manually if you haven't yet:

  1. Ensure you have edited config/initializers/genkan.rb. For example:
Genkan.configure do |config|
  config.user_class_name   = 'User'
  config.auto_acceptance   = true
  config.cookie_expiration = 1.week
end

Genkan::Engine.configure do |config|
  config.middleware.use OmniAuth::Builder do
    # Add omniauth-google-oauth2 to Gemfile:
    #   gem 'omniauth-google-oauth2'
    provider(
      :google_oauth2,
      ENV['GOOGLE_OAUTH_CLIENT_ID'],
      ENV['GOOGLE_OAUTH_CLIENT_SECRET'],
      {
        name:       'google',
        scope:      'email',
        hd:         'host-domain.com',
        verify_iss: false,
      }
    )
  end
end
  1. Ensure you have defined root_url to something in your config/routes.rb. For example:
root to: "home#index"
  1. Ensure you have flash messages in app/views/layouts/application.html.erb. For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
  1. Ensure you have set logout link in app/views/layouts/application.html.erb. For example:
<% if logged_in? %>
  <p><%= link_to "logout", genkan.logout_path %></p>
<% end %>

Debugging

You can check on dummy server:

$ bundle
$ bin/rails db:setup
$ GOOGLE_OAUTH_CLIENT_ID=YOUR_ID GOOGLE_OAUTH_CLIENT_SECRET=YOUR_SECRET bin/rails s

How to create google client id and secret:

License

The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.