LOGIN is a Rails engine to quickly enable OAuth logins in a Rails website.

1) Create an OAuth application, 2) Configure LOGIN to work with it, 3) run the migrations, and you'll be ready to login users to your site.

LOGIN uses Devise and OmniAuth, and curruntly supports :github, :twitter, :facebook, and :google_apps providers. You can only do OAuth. Login with passwords is not supported, and will never be. The world has enough passwords.


gem "login"

rake login:install:migrations
rake db:migrate

Configuration Example

Enable login via github

1) Create a github application, note the Client ID and Client Secret. The callback URL has to be #YOUR-SITE/users/auth/github/callback

2) Initialize this in your app:

Login.config = {
  :github => ["#{client_id}", "#{client_secret}", :scope => "user"]

3) Somewhere in your views, add a link to login: link_to "Login in via Github", omniauth_authorize_path('user', :github) There is also a logout route: link_to "Logout", logout_path

And that would be it. Devise/OmniAuth/LOGIN take care of the rest.

You can use Devise helpers as normal, current_user, user_signed_in?, etc..

What LOGIN does

LOGIN creates 2 tables:

  • users: will have a row for each unique user, it also has name and accounts columns, and will put information there if available (from OAuth).
  • providers: for each provider a user uses, LOGIN will store a record here.

A user might have many providers, the same user (identified uniquiely by email when available), can login with github, and google_apps, for example, as long as OAuth gives that unique email, LOGIN logs the user's record in.

LOGIN configures OAuth callbacks to work in an autamatic way, if the user is logging to your website for the first time, LOGIN creates a new users record for them, after that, it's a normal login for an existing record. If you need to capture more information about the user, you can always later force them to update the profile, for example.