Sha256: 30be9901e2546b04b71fe9c81ffffaaec7bba494f13e002c14b72bb02335f933

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 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 :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)

  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"
    @@provyder = complete_provyder(config[:provyder])
    @@setup_omniauth = config[:setup_omniauth] || true
  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

5 entries across 5 versions & 1 rubygems

Version Path
sso_clyent-0.0.7.1 lib/sso_clyent.rb
sso_clyent-0.0.7 lib/sso_clyent.rb
sso_clyent-0.0.6 lib/sso_clyent.rb
sso_clyent-0.0.5 lib/sso_clyent.rb
sso_clyent-0.0.4 lib/sso_clyent.rb