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 environment variables (all lowercase). You can use https://github.com/laserlemon/figaro or similar.
gk_client_id: xxxx.apps.googleusercontent.com
gk_service_account_email: [email protected]
# gk_service_account_key is p12 file in base64
gk_service_account_key: xxxx
gk_server_api_key: xxxx
gk_browser_api_key: xxxx
gk_project_id: xxxx
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.