https://github.com/yhirano55/genkan
:door::running:Genkan is authentication engine for Rails
https://github.com/yhirano55/genkan
omniauth rails-engine ruby
Last synced: 2 months ago
JSON representation
:door::running:Genkan is authentication engine for Rails
- Host: GitHub
- URL: https://github.com/yhirano55/genkan
- Owner: yhirano55
- License: mit
- Created: 2017-07-04T13:55:41.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-15T01:35:27.000Z (almost 8 years ago)
- Last Synced: 2025-04-18T23:04:51.118Z (2 months ago)
- Topics: omniauth, rails-engine, ruby
- Language: Ruby
- Homepage:
- Size: 66.4 KB
- Stars: 13
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/yhirano55/genkan)
[](https://badge.fury.io/rb/genkan)Genkan is authentication engine for Rails
## Installation
```ruby
gem 'genkan'# Add any omniauth provider
gem 'omniauth-google-oauth2'
gem 'omniauth-facebook'
```And then execute:
```bash
$ bundle
```## Getting started
```bash
$ 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:```ruby
Genkan.configure do |config|
config.user_class_name = 'User'
config.auto_acceptance = true
config.cookie_expiration = 1.week
endGenkan::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
```2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:```ruby
root to: "home#index"
```3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:```ruby
<%= notice %>
<%= alert %>
```4. Ensure you have set logout link in app/views/layouts/application.html.erb.
For example:```ruby
<% if logged_in? %>
<%= link_to "logout", genkan.logout_path %>
<% end %>
```## Debugging
You can check on dummy server:
```bash
$ 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:
- [Creating a Google API Console project and client ID | Google Sign-In for Websites | Google Developers](https://developers.google.com/identity/sign-in/web/devconsole-project).
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).