SSO client Rails Engine

Circle CI Dependency Status Gem Version Code Climate Test Coverage

About

SOON

Installation

Add engine and omniauth provider gems to your project:

# Gemfile

gem 'omniauth-example'
gem 'rails_sso'

Install initializer and mount routes:

bin/rails generate rails_sso

Configure initializer:

# conifg/initializers/sso.rb

RailsSso.configure do |config|
  # url of entity provider
  config.provider_url = 'https://example.com'
  # name of oauth2 provider
  config.provider_name = 'example'
  # oauth keys for omniauth-example
  config.provider_key = ENV['PROVIDER_KEY']
  config.provider_secret = ENV['PROVIDER_SECRET']
  # path for fetching user data
  config.provider_profile_path = '/api/v1/profile'
  # set if you support single sign out
  config.provider_sign_out_path = '/api/v1/session'
  # enable cache (will use Rails.cache store)
  config.use_cache = Rails.application.config.action_controller.perform_caching
end

And mount it:

# config/routes.rb

Rails.application.routes.draw do
  mount RailsSso::Engine => '/sso', as: 'sso'
end

Usage

Available helpers for controllers and views:

  • current_user_data
  • user_signed_in?

Available filters and helpers for controllers:

  • authenticate_user!
  • save_access_token!
  • invalidate_access_token!

Available helpers for views:

  • sso.sign_in_path
  • sso.sign_out_path

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request