Gitkite

Gitkite is the Rails authentication engine for Google Identity Toolkit (gitkit). It provides all the endpoints and views necessary for gitkit.

Google Identity Toolkit (gitkit) - https://developers.google.com/identity/toolkit/

Installation

Add this line to your application's Gemfile:

gem 'gitkite'

And then execute:

$ bundle

Or install it yourself as:

$ gem install gitkite

Create a User model with the fields

email
user_id
name
photo_url
provider_id

Add these environment variables (all lowercase).

export railsappname_p12=$(cat /path-to/xxxxxx.p12 | base64)
export railsappname_browser_key=xxxxxxxxx
export railsappname_server_key=xxxxxxxxx
export railsappname_project_name=xxxxxxxxx
export railsappname_service_account_email=xxxxxxxxx

You can get the values from Google Developer Console. Instructions can be found here - https://developers.google.com/identity/toolkit/web/configure-service

Add these lines to application_controller.rb.

include Gitkite::ApplicationHelper
helper Gitkite::ApplicationHelper

Add routes to your routes.rb

mount Gitkite::Engine, at: "/"

Add the before action to controllers that need authentication

before_action :authenticate_user!

To get the current user in a view or controller use -

current_user

License

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