omniauth 2.1.4 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/omniauth.rb CHANGED
@@ -1,7 +1,3 @@
1
- # TODO: Fixed in https://github.com/rack/rack/pull/1610 for Rack 3
2
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
3
- require 'delegate'
4
- end
5
1
  require 'rack'
6
2
  require 'singleton'
7
3
  require 'logger'
@@ -29,18 +25,18 @@ module OmniAuth
29
25
  include Singleton
30
26
 
31
27
  def self.default_logger
32
- logger = Logger.new(STDOUT)
28
+ logger = Logger.new($stdout)
33
29
  logger.progname = 'omniauth'
34
30
  logger
35
31
  end
36
32
 
37
- def self.defaults # rubocop:disable MethodLength
33
+ def self.defaults # rubocop:disable Metrics/MethodLength
38
34
  @defaults ||= {
39
35
  :camelizations => {},
40
36
  :path_prefix => '/auth',
41
- :on_failure => OmniAuth::FailureEndpoint,
37
+ :on_failure => FailureEndpoint,
42
38
  :failure_raise_out_environments => ['development'],
43
- :request_validation_phase => OmniAuth::AuthenticityTokenProtection,
39
+ :request_validation_phase => AuthenticityTokenProtection,
44
40
  :before_request_phase => nil,
45
41
  :after_request_phase => nil,
46
42
  :before_callback_phase => nil,
@@ -50,12 +46,13 @@ module OmniAuth
50
46
  :logger => default_logger,
51
47
  :allowed_request_methods => %i[post],
52
48
  :mock_auth => {:default => AuthHash.new('provider' => 'default', 'uid' => '1234', 'info' => {'name' => 'Example User'})},
53
- :silence_get_warning => false
49
+ :silence_get_warning => false,
50
+ :allowed_hosts => nil
54
51
  }
55
52
  end
56
53
 
57
54
  def initialize
58
- self.class.defaults.each_pair { |k, v| send("#{k}=", v) }
55
+ self.class.defaults.each_pair { |k, v| public_send("#{k}=", v) }
59
56
  end
60
57
 
61
58
  def on_failure(&block)
@@ -108,17 +105,18 @@ module OmniAuth
108
105
 
109
106
  def add_mock(provider, original = {})
110
107
  # Create key-stringified new hash from given auth hash
111
- mock = {}
108
+ mock = {} #: Hash[String, untyped]
112
109
  original.each_pair do |key, val|
113
110
  mock[key.to_s] = if val.is_a? Hash
114
- Hash[val.each_pair { |k, v| [k.to_s, v] }]
111
+ val.transform_keys(&:to_s)
115
112
  else
116
113
  val
117
114
  end
118
115
  end
119
116
 
120
117
  # Merge with the default mock and ensure provider is correct.
121
- mock = mock_auth[:default].dup.merge(mock)
118
+ default = mock_auth.fetch(:default) #: AuthHash
119
+ mock = default.merge(mock)
122
120
  mock['provider'] = provider.to_s
123
121
 
124
122
  # Add it to the mocks.
@@ -137,7 +135,8 @@ module OmniAuth
137
135
 
138
136
  attr_writer :on_failure, :before_callback_phase, :before_options_phase, :before_request_phase, :after_request_phase, :request_validation_phase
139
137
  attr_accessor :failure_raise_out_environments, :path_prefix, :allowed_request_methods, :form_css,
140
- :test_mode, :mock_auth, :full_host, :camelizations, :logger, :silence_get_warning
138
+ :test_mode, :mock_auth, :full_host, :camelizations, :logger, :silence_get_warning,
139
+ :allowed_hosts
141
140
  end
142
141
 
143
142
  def self.config
@@ -157,7 +156,7 @@ module OmniAuth
157
156
  end
158
157
 
159
158
  module Utils
160
- module_function # rubocop:disable Layout/IndentationWidth
159
+ module_function
161
160
 
162
161
  def form_css
163
162
  "<style type='text/css'>#{OmniAuth.config.form_css}</style>"
@@ -166,25 +165,29 @@ module OmniAuth
166
165
  def deep_merge(hash, other_hash)
167
166
  target = hash.dup
168
167
 
169
- other_hash.each_key do |key|
170
- if other_hash[key].is_a?(::Hash) && hash[key].is_a?(::Hash)
171
- target[key] = deep_merge(target[key], other_hash[key])
172
- next
173
- end
174
-
175
- target[key] = other_hash[key]
168
+ other_hash.each_pair do |key, value|
169
+ current = hash[key]
170
+ target[key] = current.is_a?(Hash) && value.is_a?(Hash) ? deep_merge(current, value) : value
176
171
  end
177
172
 
178
173
  target
179
174
  end
180
175
 
181
176
  def camelize(word, first_letter_in_uppercase = true)
182
- return OmniAuth.config.camelizations[word.to_s] if OmniAuth.config.camelizations[word.to_s]
177
+ camelized = OmniAuth.config.camelizations[word.to_s]
178
+ return camelized if camelized
183
179
 
184
180
  if first_letter_in_uppercase
185
- word.to_s.gsub(%r{/(.?)}) { '::' + Regexp.last_match[1].upcase }.gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
181
+ namespaced = word.to_s.gsub(%r{/(.?)}) do
182
+ char = Regexp.last_match(1) #: String
183
+ "::#{char.upcase}"
184
+ end
185
+ namespaced.gsub(/(\A|_)(.)/) do
186
+ char = Regexp.last_match(2) #: String
187
+ char.upcase
188
+ end
186
189
  else
187
- camelize(word).tap { |w| w[0] = w[0].downcase }
190
+ camelize(word).tap { |w| w[0] = w[0].to_s.downcase }
188
191
  end
189
192
  end
190
193
  end
data/sig/manifest.yaml ADDED
@@ -0,0 +1,5 @@
1
+ # Standard libraries these signatures refer to, which RBS loads for anyone
2
+ # using them.
3
+ dependencies:
4
+ - name: logger
5
+ - name: singleton