Sha256: e25bfefc483e2e8eee3f6f3769cde8d2d4b2899c8d700117ef5fab68e6a79970

Contents?: true

Size: 1.92 KB

Versions: 14

Compression:

Stored size: 1.92 KB

Contents

require "sso_clyent/engine"

module SsoClyent

  mattr_accessor :user_class, :unique_id
  mattr_accessor :after_sign_in_path
  mattr_accessor :path
  mattr_accessor :ssl_config
  mattr_accessor :provyder
  mattr_accessor :setup_omniauth # hack to allow sso_clyent to be incorporated to gems that are  used on apps without frontend (ex: in auth_passport_checkpoint for intermediary apis)
  mattr_accessor :logout_url, :signup_url, :login_url, :edit_account_url

  def self.configure(config)
    @@user_class = config[:user_class]
    @@unique_id = config[:unique_id]
    @@after_sign_in_path = config[:after_sign_in_path] || "/"
    @@path = config[:path] || "/sso"
    @@ssl_config = config[:ssl_config]
    @@provyder = complete_provyder(config[:provyder])
    @@setup_omniauth = config[:setup_omniauth] || true
    @@logout_url = config[:logout_url] || "#{@@provyder[:url]}/users/sign_out"
    @@signup_url = config[:signup_url] || "#{@@provyder[:url]}/users/sign_up"
    @@login_url = config[:login_url] || "#{@@provyder[:url]}/users/sign_in"
    @@edit_account_url = config[:edit_account_url] || "#{@@provyder[:url]}/users/edit"
  end

  def self.user_class
    @@user_class.constantize
  end

  private

  def self.complete_provyder(_provider=nil)
    options = _provider || {}
    base = options.reverse_merge({
      :url            => "http://localhost:3000#{options[:path_prefix]}",
      :authorize_path => '/oauth/authorize',
      :token_path     => '/oauth/token',
      :user           => {  :path           => "/user",
                            :uid            => "id",
                            :info           => %w(email),
                            :extras         => %w()         } })
    base.reverse_merge({
      :authorize_url  => "#{base[:url]}#{base[:authorize_path]}",
      :access_token_url  => "#{base[:url]}#{base[:token_path]}",
      :user_url => "#{base[:url]}#{base[:user][:path]}"
      })
  end

end

require 'sso_clyent/base'

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
sso_clyent-0.0.7.38 lib/sso_clyent.rb
sso_clyent-0.0.7.37 lib/sso_clyent.rb
sso_clyent-0.0.7.36 lib/sso_clyent.rb
sso_clyent-0.0.7.35 lib/sso_clyent.rb
sso_clyent-0.0.7.34 lib/sso_clyent.rb
sso_clyent-0.0.7.33 lib/sso_clyent.rb
sso_clyent-0.0.7.32 lib/sso_clyent.rb
sso_clyent-0.0.7.31 lib/sso_clyent.rb
sso_clyent-0.0.7.30 lib/sso_clyent.rb
sso_clyent-0.0.7.29 lib/sso_clyent.rb
sso_clyent-0.0.7.28 lib/sso_clyent.rb
sso_clyent-0.0.7.27 lib/sso_clyent.rb
sso_clyent-0.0.7.26 lib/sso_clyent.rb
sso_clyent-0.0.7.25 lib/sso_clyent.rb