Class: OmniAuth::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/omniauth/core.rb

Constant Summary collapse

@@defaults =
{
  :path_prefix => '/auth',
  :on_failure => Proc.new do |env|
    message_key = env['omniauth.error.type']
    new_path = "#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
    [302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
  end,
  :form_css => Form::DEFAULT_CSS,
  :test_mode => false,
  :allowed_request_methods => [:get, :post],
  :mock_auth => {
    :default => {
      'provider' => 'default',
      'uid' => '1234',
      'user_info' => {
        'name' => 'Bob Example'
      }
    }
  }
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



46
47
48
# File 'lib/omniauth/core.rb', line 46

def initialize
  @@defaults.each_pair{|k,v| self.send("#{k}=",v)}
end

Instance Attribute Details

#allowed_request_methodsObject

Returns the value of attribute allowed_request_methods.



76
77
78
# File 'lib/omniauth/core.rb', line 76

def allowed_request_methods
  @allowed_request_methods
end

#form_cssObject

Returns the value of attribute form_css.



76
77
78
# File 'lib/omniauth/core.rb', line 76

def form_css
  @form_css
end

#full_hostObject

Returns the value of attribute full_host.



76
77
78
# File 'lib/omniauth/core.rb', line 76

def full_host
  @full_host
end

#mock_authObject

Returns the value of attribute mock_auth.



76
77
78
# File 'lib/omniauth/core.rb', line 76

def mock_auth
  @mock_auth
end

#on_failure(&block) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/omniauth/core.rb', line 50

def on_failure(&block)
  if block_given?
    @on_failure = block
  else
    @on_failure
  end
end

#path_prefixObject

Returns the value of attribute path_prefix.



76
77
78
# File 'lib/omniauth/core.rb', line 76

def path_prefix
  @path_prefix
end

#test_modeObject

Returns the value of attribute test_mode.



76
77
78
# File 'lib/omniauth/core.rb', line 76

def test_mode
  @test_mode
end

Class Method Details

.defaultsObject



42
43
44
# File 'lib/omniauth/core.rb', line 42

def self.defaults
  @@defaults
end

Instance Method Details

#add_mock(provider, mock = {}) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/omniauth/core.rb', line 58

def add_mock(provider, mock={})
  # Stringify keys recursively one level.
  mock.stringify_keys!
  mock.keys.each do|key|
    if mock[key].is_a? Hash
      mock[key].stringify_keys!
    end
  end

  # Merge with the default mock and ensure provider is correct.
  mock = self.mock_auth[:default].dup.merge(mock)
  mock["provider"] = provider.to_s

  # Add it to the mocks.
  self.mock_auth[provider.to_sym] = mock
end