Class: OmniAuth::Configuration
- Inherits:
-
Object
- Object
- OmniAuth::Configuration
- Includes:
- Singleton
- Defined in:
- lib/omniauth.rb
Instance Attribute Summary collapse
-
#allowed_request_methods ⇒ Object
Returns the value of attribute allowed_request_methods.
- #before_callback_phase(&block) ⇒ Object
- #before_options_phase(&block) ⇒ Object
- #before_request_phase(&block) ⇒ Object
-
#camelizations ⇒ Object
Returns the value of attribute camelizations.
-
#failure_raise_out_environments ⇒ Object
Returns the value of attribute failure_raise_out_environments.
-
#form_css ⇒ Object
Returns the value of attribute form_css.
-
#full_host ⇒ Object
Returns the value of attribute full_host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#mock_auth ⇒ Object
Returns the value of attribute mock_auth.
- #on_failure(&block) ⇒ Object
-
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
- #request_validation_phase(&block) ⇒ Object
-
#silence_get_warning ⇒ Object
Returns the value of attribute silence_get_warning.
-
#test_mode ⇒ Object
Returns the value of attribute test_mode.
Class Method Summary collapse
- .default_logger ⇒ Object
-
.defaults ⇒ Object
rubocop:disable MethodLength.
Instance Method Summary collapse
-
#add_camelization(name, camelized) ⇒ Object
This is a convenience method to be used by strategy authors so that they can add special cases to the camelization utility method that allows OmniAuth::Builder to work.
- #add_mock(provider, original = {}) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
52 53 54 |
# File 'lib/omniauth.rb', line 52 def initialize self.class.defaults.each_pair { |k, v| send("#{k}=", v) } end |
Instance Attribute Details
#allowed_request_methods ⇒ Object
Returns the value of attribute allowed_request_methods.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def allowed_request_methods @allowed_request_methods end |
#before_callback_phase(&block) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/omniauth.rb', line 64 def before_callback_phase(&block) if block_given? @before_callback_phase = block else @before_callback_phase end end |
#before_options_phase(&block) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/omniauth.rb', line 72 def (&block) if block_given? @before_options_phase = block else @before_options_phase end end |
#before_request_phase(&block) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/omniauth.rb', line 88 def before_request_phase(&block) if block_given? @before_request_phase = block else @before_request_phase end end |
#camelizations ⇒ Object
Returns the value of attribute camelizations.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def camelizations @camelizations end |
#failure_raise_out_environments ⇒ Object
Returns the value of attribute failure_raise_out_environments.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def failure_raise_out_environments @failure_raise_out_environments end |
#form_css ⇒ Object
Returns the value of attribute form_css.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def form_css @form_css end |
#full_host ⇒ Object
Returns the value of attribute full_host.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def full_host @full_host end |
#logger ⇒ Object
Returns the value of attribute logger.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def logger @logger end |
#mock_auth ⇒ Object
Returns the value of attribute mock_auth.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def mock_auth @mock_auth end |
#on_failure(&block) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/omniauth.rb', line 56 def on_failure(&block) if block_given? @on_failure = block else @on_failure end end |
#path_prefix ⇒ Object
Returns the value of attribute path_prefix.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def path_prefix @path_prefix end |
#request_validation_phase(&block) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/omniauth.rb', line 80 def request_validation_phase(&block) if block_given? @request_validation_phase = block else @request_validation_phase end end |
#silence_get_warning ⇒ Object
Returns the value of attribute silence_get_warning.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def silence_get_warning @silence_get_warning end |
#test_mode ⇒ Object
Returns the value of attribute test_mode.
126 127 128 |
# File 'lib/omniauth.rb', line 126 def test_mode @test_mode end |
Class Method Details
.default_logger ⇒ Object
27 28 29 30 31 |
# File 'lib/omniauth.rb', line 27 def self.default_logger logger = Logger.new(STDOUT) logger.progname = 'omniauth' logger end |
.defaults ⇒ Object
rubocop:disable MethodLength
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/omniauth.rb', line 33 def self.defaults # rubocop:disable MethodLength @defaults ||= { :camelizations => {}, :path_prefix => '/auth', :on_failure => OmniAuth::FailureEndpoint, :failure_raise_out_environments => ['development'], :request_validation_phase => OmniAuth::AuthenticityTokenProtection, :before_request_phase => nil, :before_callback_phase => nil, :before_options_phase => nil, :form_css => Form::DEFAULT_CSS, :test_mode => false, :logger => default_logger, :allowed_request_methods => %i[post], :mock_auth => {:default => AuthHash.new('provider' => 'default', 'uid' => '1234', 'info' => {'name' => 'Example User'})}, :silence_get_warning => false } end |
Instance Method Details
#add_camelization(name, camelized) ⇒ Object
This is a convenience method to be used by strategy authors so that they can add special cases to the camelization utility method that allows OmniAuth::Builder to work.
121 122 123 |
# File 'lib/omniauth.rb', line 121 def add_camelization(name, camelized) camelizations[name.to_s] = camelized.to_s end |
#add_mock(provider, original = {}) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/omniauth.rb', line 96 def add_mock(provider, original = {}) # Create key-stringified new hash from given auth hash mock = {} original.each_pair do |key, val| mock[key.to_s] = if val.is_a? Hash Hash[val.each_pair { |k, v| [k.to_s, v] }] else val end end # Merge with the default mock and ensure provider is correct. mock = mock_auth[:default].dup.merge(mock) mock['provider'] = provider.to_s # Add it to the mocks. mock_auth[provider.to_sym] = mock end |