gem ‘sso_clyent’


Setup following config variables (app.config)


config.sso_clyent =

:path                => "/sso",   # ex '/' - the path where you want to mount the sso_clyent_engine
:user_class          =>  "User",  # ex: User - the class where you store your users info
:unique_id           =>  "uid",   # ex: :uid - the attr of the user model that allows you to identify a user
:after_sign_in_path  => '/',      # ex '/' - the path where you want your users to be redirected by default after sign in

:provyder            => {         # info for the omniauth strategy connecting to omniauth_provider

                          :url              => "http://localhost:3000#{options[:path_prefix]",     # url of the sso provider
                          :authorize_path   => '/oauth/authorize',                                  # auth path @ the sso provider
                          :token_path       => '/oauth/token',                                      # token path @ the sso provider
                          :user             => {  :path           => "/auth/user",                  # path to user info @ the sso provider
                                                  :uid            => "id",                          # name of attribute to correspond to id
                                                  :info           => %w(email),                     # info to retrieve from provider response
                                                  :extras         => %w()         }                 # extras
                          :app_id           => 'YOURAPPID',                                         # your app id to identify @ the provider
                          :app_secret       => 'YOURAPPSECRET',                                     # your app secret to identify @ the provider
                        }

}

You can overwrite following methods in your controllers


# def login_required

# if !current_user

# respond_to do |format|

# format.html { redirect_to “#{SsoClyent.path}/auth/sso” }

# format.json { render :json => { ‘error’ => ‘Access Denied’ }.to_json }

# end

# end

# end

#

# def current_user

# return nil unless session

# users = user_klass

# uid = userid

# if users.respond_to?(:“find_by_#{uid}”)

# @current_user ||= users.send(:“find_by_#{uid}”, session[‘uid’])

# end

# end

#

# def sso_clyent_user_klass

# SsoClyent.user_class

# end

#

# def sso_clyent_userid # SsoClyent.unique_id

# end

OLD DOCS !

# A Rails Engine providing an Omniauth client with single sign on features in a minute. # # See sso_provyder for the provider part. # Based on Devise, Authentifyd and joshsoftware/sso-devise-omniauth-client. Parts directly taken from github.com/joshsoftware/sso-devise-omniauth-client #

# install the gem

#

# add a config/intializers/sso_clyent.rb file with the following:

#

# # Provide sso_clyent with the user_class you use to store your users # SsoClyent.user_class = “User” #

# # … and the name of the attribute / field you use to identify your user # # across services # SsoClyent.unique_id = “unique_id” #

# # Also provide sso_clyent with the sso_provider you want to target # # # # * url, # # * authorizeurl, and # # * access_token url # # * user # # + where to get user_info from provider # # + the unique id you expect from provider

# # + the info you expect from provider

# # + the extra_info you expect from provider # # # # NB: the provider is expected to respond_to [:user].json # # # SsoClyent.sso_provider = { # :url => ‘localhost:3000’, # :authorize_path => ‘/auth/sso/authorize’, # :token_path => ‘/auth/sso/access_token’, # :user => { :path => “/auth/sso/user” # :uid => “id”, # :info => %w(email), # :extras => %w() } } # # add a config/intializers/omniauth.rb file with the following:

#

# # Change this omniauth configuration to point to your registered provider # # Since this is a registered application, add the app id and secret here # APP_ID = ‘YE0NYveQGoFsNLX220Dy5g’ # APP_SECRET = ‘aqpGBedDnHFyp5MmgT8KErr9D015ScmaY8r3vHg5C0’ # # Rails.application.config.middleware.use OmniAuth::Builder do # provider :sso_server, APP_ID, APP_SECRET # end #

# add the following line to your controllers

#

# before_filter :login_required