omniauth 1.4.2 → 2.1.2

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.
@@ -1,24 +1,5 @@
1
1
  module OmniAuth
2
2
  class Builder < ::Rack::Builder
3
- def initialize(app, &block)
4
- @options = nil
5
- if rack14? || rack2?
6
- super
7
- else
8
- @app = app
9
- super(&block)
10
- @ins << @app
11
- end
12
- end
13
-
14
- def rack14?
15
- Rack.release.start_with?('1.') && (Rack.release.split('.')[1].to_i >= 4)
16
- end
17
-
18
- def rack2?
19
- Rack.release.start_with? '2.'
20
- end
21
-
22
3
  def on_failure(&block)
23
4
  OmniAuth.config.on_failure = block
24
5
  end
@@ -40,23 +21,23 @@ module OmniAuth
40
21
  end
41
22
 
42
23
  def options(options = false)
43
- return @options || {} if options == false
24
+ return @options ||= {} if options == false
25
+
44
26
  @options = options
45
27
  end
46
28
 
47
- def provider(klass, *args, &block)
29
+ def provider(klass, *args, **opts, &block)
48
30
  if klass.is_a?(Class)
49
31
  middleware = klass
50
32
  else
51
33
  begin
52
- middleware = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s)
34
+ middleware = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s, false)
53
35
  rescue NameError
54
36
  raise(LoadError.new("Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."))
55
37
  end
56
38
  end
57
39
 
58
- args.last.is_a?(Hash) ? args.push(options.merge(args.pop)) : args.push(options)
59
- use middleware, *args, &block
40
+ use middleware, *args, **options.merge(opts), &block
60
41
  end
61
42
 
62
43
  def call(env)
@@ -27,17 +27,28 @@ module OmniAuth
27
27
 
28
28
  def redirect_to_failure
29
29
  message_key = env['omniauth.error.type']
30
- new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}#{origin_query_param}#{strategy_name_query_param}"
30
+
31
+ new_path = "#{env['SCRIPT_NAME']}#{strategy_path_prefix}/failure?message=#{Rack::Utils.escape(message_key)}#{origin_query_param}#{strategy_name_query_param}"
31
32
  Rack::Response.new(['302 Moved'], 302, 'Location' => new_path).finish
32
33
  end
33
34
 
35
+ def strategy_path_prefix
36
+ if env['omniauth.error.strategy']
37
+ env['omniauth.error.strategy'].path_prefix
38
+ else
39
+ OmniAuth.config.path_prefix
40
+ end
41
+ end
42
+
34
43
  def strategy_name_query_param
35
44
  return '' unless env['omniauth.error.strategy']
45
+
36
46
  "&strategy=#{env['omniauth.error.strategy'].name}"
37
47
  end
38
48
 
39
49
  def origin_query_param
40
50
  return '' unless env['omniauth.origin']
51
+
41
52
  "&origin=#{Rack::Utils.escape(env['omniauth.origin'])}"
42
53
  end
43
54
  end
data/lib/omniauth/form.rb CHANGED
@@ -7,9 +7,10 @@ module OmniAuth
7
7
  def initialize(options = {})
8
8
  options[:title] ||= 'Authentication Info Required'
9
9
  options[:header_info] ||= ''
10
+ options[:method] ||= 'post'
10
11
  self.options = options
11
12
 
12
- @html = ''
13
+ @html = +'' # unary + string allows it to be mutable if strings are frozen
13
14
  @with_custom_button = false
14
15
  @footer = nil
15
16
  header(options[:title], options[:header_info])
@@ -75,13 +76,14 @@ module OmniAuth
75
76
  </head>
76
77
  <body>
77
78
  <h1>#{title}</h1>
78
- <form method='post' #{"action='#{options[:url]}' " if options[:url]}noValidate='noValidate'>
79
+ <form method='#{options[:method]}' #{"action='#{options[:url]}' " if options[:url]}noValidate='noValidate'>
79
80
  HTML
80
81
  self
81
82
  end
82
83
 
83
84
  def footer
84
85
  return self if @footer
86
+
85
87
  @html << "\n<button type='submit'>Connect</button>" unless @with_custom_button
86
88
  @html << <<-HTML
87
89
  </form>
@@ -8,15 +8,12 @@ module OmniAuth
8
8
  require 'hashie/version'
9
9
  return unless Gem::Version.new(Hashie::VERSION) >= Gem::Version.new('3.5.0')
10
10
 
11
- # if respond_to?(:disable_warnings)
12
- # disable_warnings
13
- # else
14
- # define_method(:log_built_in_message) { |*| }
15
- # private :log_built_in_message
16
- # end
17
-
18
- define_method(:log_built_in_message) { |*| }
19
- private :log_built_in_message
11
+ if respond_to?(:disable_warnings)
12
+ disable_warnings
13
+ else
14
+ define_method(:log_built_in_message) { |*| }
15
+ private :log_built_in_message
16
+ end
20
17
  end
21
18
 
22
19
  # Disable on loading of the class
@@ -31,11 +31,11 @@ module OmniAuth
31
31
  class Developer
32
32
  include OmniAuth::Strategy
33
33
 
34
- option :fields, [:name, :email]
34
+ option :fields, %i[name email]
35
35
  option :uid_field, :email
36
36
 
37
37
  def request_phase
38
- form = OmniAuth::Form.new(:title => 'User Info', :url => callback_path)
38
+ form = OmniAuth::Form.new(:title => 'User Info', :url => callback_path, :method => 'get')
39
39
  options.fields.each do |field|
40
40
  form.text_field field.to_s.capitalize.tr('_', ' '), field.to_s
41
41
  end
@@ -14,6 +14,7 @@ module OmniAuth
14
14
  base.class_eval do
15
15
  option :setup, false
16
16
  option :skip_info, false
17
+ option :origin_param, 'origin'
17
18
  end
18
19
  end
19
20
 
@@ -21,9 +22,9 @@ module OmniAuth
21
22
  # Returns an inherited set of default options set at the class-level
22
23
  # for each strategy.
23
24
  def default_options
24
- return @default_options if instance_variable_defined?(:@default_options) && @default_options
25
+ # existing = superclass.default_options if superclass.respond_to?(:default_options)
25
26
  existing = superclass.respond_to?(:default_options) ? superclass.default_options : {}
26
- @default_options = OmniAuth::Strategy::Options.new(existing)
27
+ @default_options ||= OmniAuth::Strategy::Options.new(existing)
27
28
  end
28
29
 
29
30
  # This allows for more declarative subclassing of strategies by allowing
@@ -87,10 +88,13 @@ module OmniAuth
87
88
  (instance_variable_defined?(:@args) && @args) || existing
88
89
  end
89
90
 
90
- %w(uid info extra credentials).each do |fetcher|
91
- class_eval <<-RUBY
91
+ %w[uid info extra credentials].each do |fetcher|
92
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
93
+ attr_reader :#{fetcher}_proc
94
+ private :#{fetcher}_proc
95
+
92
96
  def #{fetcher}(&block)
93
- return @#{fetcher}_proc unless block_given?
97
+ return #{fetcher}_proc unless block_given?
94
98
  @#{fetcher}_proc = block
95
99
  end
96
100
 
@@ -132,10 +136,11 @@ module OmniAuth
132
136
  @options = self.class.default_options.dup
133
137
 
134
138
  options.deep_merge!(args.pop) if args.last.is_a?(Hash)
135
- options.name ||= self.class.to_s.split('::').last.downcase
139
+ options[:name] ||= self.class.to_s.split('::').last.downcase
136
140
 
137
141
  self.class.args.each do |arg|
138
142
  break if args.empty?
143
+
139
144
  options[arg] = args.shift
140
145
  end
141
146
 
@@ -176,16 +181,47 @@ module OmniAuth
176
181
  end
177
182
 
178
183
  @env = env
184
+
185
+ warn_if_using_get_on_request_path
186
+
179
187
  @env['omniauth.strategy'] = self if on_auth_path?
180
188
 
181
189
  return mock_call!(env) if OmniAuth.config.test_mode
182
- return options_call if on_auth_path? && options_request?
183
- return request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
184
- return callback_call if on_callback_path?
185
- return other_phase if respond_to?(:other_phase)
190
+
191
+ begin
192
+ return options_call if on_auth_path? && options_request?
193
+ return request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
194
+ return callback_call if on_callback_path?
195
+ return other_phase if respond_to?(:other_phase)
196
+ rescue StandardError => e
197
+ raise e if env.delete('omniauth.error.app')
198
+
199
+ return fail!(e.message, e)
200
+ end
201
+
186
202
  @app.call(env)
187
203
  end
188
204
 
205
+ def warn_if_using_get_on_request_path
206
+ return unless on_request_path?
207
+ return unless OmniAuth.config.allowed_request_methods.include?(:get)
208
+ return if OmniAuth.config.silence_get_warning
209
+
210
+ log :warn, <<-WARN
211
+ You are using GET as an allowed request method for OmniAuth. This may leave
212
+ you open to CSRF attacks. As of v2.0.0, OmniAuth by default allows only POST
213
+ to its own routes. You should review the following resources to guide your
214
+ mitigation:
215
+ https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284
216
+ https://github.com/omniauth/omniauth/issues/960
217
+ https://nvd.nist.gov/vuln/detail/CVE-2015-9284
218
+ https://github.com/omniauth/omniauth/pull/809
219
+
220
+ You can ignore this warning by setting:
221
+ OmniAuth.config.silence_get_warning = true
222
+ WARN
223
+ end
224
+
189
225
  # Responds to an OPTIONS request.
190
226
  def options_call
191
227
  OmniAuth.config.before_options_phase.call(env) if OmniAuth.config.before_options_phase
@@ -196,30 +232,39 @@ module OmniAuth
196
232
  # Performs the steps necessary to run the request phase of a strategy.
197
233
  def request_call # rubocop:disable CyclomaticComplexity, MethodLength, PerceivedComplexity
198
234
  setup_phase
199
- log :info, 'Request phase initiated.'
235
+ log :debug, 'Request phase initiated.'
236
+
200
237
  # store query params from the request url, extracted in the callback_phase
201
238
  session['omniauth.params'] = request.GET
239
+
240
+ OmniAuth.config.request_validation_phase.call(env) if OmniAuth.config.request_validation_phase
202
241
  OmniAuth.config.before_request_phase.call(env) if OmniAuth.config.before_request_phase
242
+
203
243
  if options.form.respond_to?(:call)
204
- log :info, 'Rendering form from supplied Rack endpoint.'
244
+ log :debug, 'Rendering form from supplied Rack endpoint.'
205
245
  options.form.call(env)
206
246
  elsif options.form
207
- log :info, 'Rendering form from underlying application.'
247
+ log :debug, 'Rendering form from underlying application.'
208
248
  call_app!
249
+ elsif !options.origin_param
250
+ request_phase
209
251
  else
210
- if request.params['origin']
211
- env['rack.session']['omniauth.origin'] = request.params['origin']
252
+ if request.params[options.origin_param]
253
+ env['rack.session']['omniauth.origin'] = request.params[options.origin_param]
212
254
  elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
213
255
  env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
214
256
  end
257
+
215
258
  request_phase
216
259
  end
260
+ rescue OmniAuth::AuthenticityError => e
261
+ fail!(:authenticity_error, e)
217
262
  end
218
263
 
219
264
  # Performs the steps necessary to run the callback phase of a strategy.
220
265
  def callback_call
221
266
  setup_phase
222
- log :info, 'Callback phase initiated.'
267
+ log :debug, 'Callback phase initiated.'
223
268
  @env['omniauth.origin'] = session.delete('omniauth.origin')
224
269
  @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
225
270
  @env['omniauth.params'] = session.delete('omniauth.params') || {}
@@ -234,8 +279,8 @@ module OmniAuth
234
279
  end
235
280
 
236
281
  def on_request_path?
237
- if options.request_path.respond_to?(:call)
238
- options.request_path.call(env)
282
+ if options[:request_path].respond_to?(:call)
283
+ options[:request_path].call(env)
239
284
  else
240
285
  on_path?(request_path)
241
286
  end
@@ -257,8 +302,15 @@ module OmniAuth
257
302
  # in the event that OmniAuth has been configured to be
258
303
  # in test mode.
259
304
  def mock_call!(*)
260
- return mock_request_call if on_request_path?
261
- return mock_callback_call if on_callback_path?
305
+ begin
306
+ return mock_request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
307
+ return mock_callback_call if on_callback_path?
308
+ rescue StandardError => e
309
+ raise e if env.delete('omniauth.error.app')
310
+
311
+ return fail!(e.message, e)
312
+ end
313
+
262
314
  call_app!
263
315
  end
264
316
 
@@ -266,11 +318,16 @@ module OmniAuth
266
318
  setup_phase
267
319
 
268
320
  session['omniauth.params'] = request.GET
321
+
322
+ OmniAuth.config.request_validation_phase.call(env) if OmniAuth.config.request_validation_phase
269
323
  OmniAuth.config.before_request_phase.call(env) if OmniAuth.config.before_request_phase
270
- if request.params['origin']
271
- @env['rack.session']['omniauth.origin'] = request.params['origin']
272
- elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
273
- @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
324
+
325
+ if options.origin_param
326
+ if request.params[options.origin_param]
327
+ session['omniauth.origin'] = request.params[options.origin_param]
328
+ elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
329
+ session['omniauth.origin'] = env['HTTP_REFERER']
330
+ end
274
331
  end
275
332
 
276
333
  redirect(callback_url)
@@ -280,12 +337,13 @@ module OmniAuth
280
337
  setup_phase
281
338
  @env['omniauth.origin'] = session.delete('omniauth.origin')
282
339
  @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
340
+ @env['omniauth.params'] = session.delete('omniauth.params') || {}
341
+
283
342
  mocked_auth = OmniAuth.mock_auth_for(name.to_s)
284
343
  if mocked_auth.is_a?(Symbol)
285
344
  fail!(mocked_auth)
286
345
  else
287
346
  @env['omniauth.auth'] = mocked_auth
288
- @env['omniauth.params'] = session.delete('omniauth.params') || {}
289
347
  OmniAuth.config.before_callback_phase.call(@env) if OmniAuth.config.before_callback_phase
290
348
  call_app!
291
349
  end
@@ -297,10 +355,10 @@ module OmniAuth
297
355
  # underlying application. This will default to `/auth/:provider/setup`.
298
356
  def setup_phase
299
357
  if options[:setup].respond_to?(:call)
300
- log :info, 'Setup endpoint detected, running now.'
358
+ log :debug, 'Setup endpoint detected, running now.'
301
359
  options[:setup].call(env)
302
- elsif options.setup?
303
- log :info, 'Calling through to underlying application for setup.'
360
+ elsif options[:setup]
361
+ log :debug, 'Calling through to underlying application for setup.'
304
362
  setup_env = env.merge('PATH_INFO' => setup_path, 'REQUEST_METHOD' => 'GET')
305
363
  call_app!(setup_env)
306
364
  end
@@ -330,11 +388,13 @@ module OmniAuth
330
388
  end
331
389
 
332
390
  def auth_hash
333
- hash = AuthHash.new(:provider => name, :uid => uid)
334
- hash.info = info unless skip_info?
335
- hash.credentials = credentials if credentials
336
- hash.extra = extra if extra
337
- hash
391
+ credentials_data = credentials
392
+ extra_data = extra
393
+ AuthHash.new(:provider => name, :uid => uid).tap do |auth|
394
+ auth.info = info unless skip_info?
395
+ auth.credentials = credentials_data if credentials_data
396
+ auth.extra = extra_data if extra_data
397
+ end
338
398
  end
339
399
 
340
400
  # Determines whether or not user info should be retrieved. This
@@ -349,6 +409,7 @@ module OmniAuth
349
409
  def skip_info?
350
410
  return false unless options.skip_info?
351
411
  return true unless options.skip_info.respond_to?(:call)
412
+
352
413
  options.skip_info.call(uid)
353
414
  end
354
415
 
@@ -365,6 +426,7 @@ module OmniAuth
365
426
  if options[kind].respond_to?(:call)
366
427
  result = options[kind].call(env)
367
428
  return nil unless result.is_a?(String)
429
+
368
430
  result
369
431
  else
370
432
  options[kind]
@@ -372,7 +434,12 @@ module OmniAuth
372
434
  end
373
435
 
374
436
  def request_path
375
- @request_path ||= options[:request_path].is_a?(String) ? options[:request_path] : "#{path_prefix}/#{name}"
437
+ @request_path ||=
438
+ if options[:request_path].is_a?(String)
439
+ options[:request_path]
440
+ else
441
+ "#{script_name}#{path_prefix}/#{name}"
442
+ end
376
443
  end
377
444
 
378
445
  def callback_path
@@ -380,7 +447,7 @@ module OmniAuth
380
447
  path = options[:callback_path] if options[:callback_path].is_a?(String)
381
448
  path ||= current_path if options[:callback_path].respond_to?(:call) && options[:callback_path].call(env)
382
449
  path ||= custom_path(:request_path)
383
- path ||= "#{path_prefix}/#{name}/callback"
450
+ path ||= "#{script_name}#{path_prefix}/#{name}/callback"
384
451
  path
385
452
  end
386
453
  end
@@ -389,10 +456,10 @@ module OmniAuth
389
456
  options[:setup_path] || "#{path_prefix}/#{name}/setup"
390
457
  end
391
458
 
392
- CURRENT_PATH_REGEX = %r{/$}
459
+ CURRENT_PATH_REGEX = %r{/$}.freeze
393
460
  EMPTY_STRING = ''.freeze
394
461
  def current_path
395
- @current_path ||= request.path_info.downcase.sub(CURRENT_PATH_REGEX, EMPTY_STRING)
462
+ @current_path ||= request.path.downcase.sub(CURRENT_PATH_REGEX, EMPTY_STRING)
396
463
  end
397
464
 
398
465
  def query_string
@@ -401,6 +468,9 @@ module OmniAuth
401
468
 
402
469
  def call_app!(env = @env)
403
470
  @app.call(env)
471
+ rescue StandardError => e
472
+ env['omniauth.error.app'] = true
473
+ raise e
404
474
  end
405
475
 
406
476
  def full_host
@@ -424,10 +494,11 @@ module OmniAuth
424
494
  end
425
495
 
426
496
  def callback_url
427
- full_host + script_name + callback_path + query_string
497
+ full_host + callback_path + query_string
428
498
  end
429
499
 
430
500
  def script_name
501
+ return '' if @env.nil?
431
502
  @env['SCRIPT_NAME'] || ''
432
503
  end
433
504
 
@@ -440,7 +511,7 @@ module OmniAuth
440
511
  end
441
512
 
442
513
  def name
443
- options.name
514
+ options[:name]
444
515
  end
445
516
 
446
517
  def redirect(uri)
@@ -474,16 +545,15 @@ module OmniAuth
474
545
  OmniAuth.config.on_failure.call(env)
475
546
  end
476
547
 
477
- def dup
478
- super.tap do
479
- @options = @options.dup
480
- end
481
- end
482
-
483
548
  class Options < OmniAuth::KeyStore; end
484
549
 
485
550
  protected
486
551
 
552
+ def initialize_copy(*args)
553
+ super
554
+ @options = @options.dup
555
+ end
556
+
487
557
  def merge_stack(stack)
488
558
  stack.inject({}) do |a, e|
489
559
  a.merge!(e)
@@ -10,7 +10,7 @@ module OmniAuth
10
10
  # include OmniAuth::Test::StrategyTestCase
11
11
  # def strategy
12
12
  # # return the parameters to a Rack::Builder map call:
13
- # [MyStrategy.new, :some, :configuration, :options => 'here']
13
+ # [MyStrategy, :some, :configuration, :options => 'here']
14
14
  # end
15
15
  # setup do
16
16
  # post '/auth/my_strategy/callback', :user => { 'name' => 'Dylan', 'id' => '445' }
@@ -1,3 +1,3 @@
1
1
  module OmniAuth
2
- VERSION = '1.4.2'.freeze
2
+ VERSION = '2.1.2'.freeze
3
3
  end
data/lib/omniauth.rb CHANGED
@@ -1,3 +1,7 @@
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
1
5
  require 'rack'
2
6
  require 'singleton'
3
7
  require 'logger'
@@ -15,6 +19,7 @@ module OmniAuth
15
19
  autoload :Form, 'omniauth/form'
16
20
  autoload :AuthHash, 'omniauth/auth_hash'
17
21
  autoload :FailureEndpoint, 'omniauth/failure_endpoint'
22
+ autoload :AuthenticityTokenProtection, 'omniauth/authenticity_token_protection'
18
23
 
19
24
  def self.strategies
20
25
  @strategies ||= []
@@ -29,20 +34,22 @@ module OmniAuth
29
34
  logger
30
35
  end
31
36
 
32
- def self.defaults
37
+ def self.defaults # rubocop:disable MethodLength
33
38
  @defaults ||= {
34
39
  :camelizations => {},
35
40
  :path_prefix => '/auth',
36
41
  :on_failure => OmniAuth::FailureEndpoint,
37
42
  :failure_raise_out_environments => ['development'],
43
+ :request_validation_phase => OmniAuth::AuthenticityTokenProtection,
38
44
  :before_request_phase => nil,
39
45
  :before_callback_phase => nil,
40
46
  :before_options_phase => nil,
41
47
  :form_css => Form::DEFAULT_CSS,
42
48
  :test_mode => false,
43
49
  :logger => default_logger,
44
- :allowed_request_methods => [:get, :post],
45
- :mock_auth => {:default => AuthHash.new('provider' => 'default', 'uid' => '1234', 'info' => {'name' => 'Example User'})}
50
+ :allowed_request_methods => %i[post],
51
+ :mock_auth => {:default => AuthHash.new('provider' => 'default', 'uid' => '1234', 'info' => {'name' => 'Example User'})},
52
+ :silence_get_warning => false
46
53
  }
47
54
  end
48
55
 
@@ -74,6 +81,14 @@ module OmniAuth
74
81
  end
75
82
  end
76
83
 
84
+ def request_validation_phase(&block)
85
+ if block_given?
86
+ @request_validation_phase = block
87
+ else
88
+ @request_validation_phase
89
+ end
90
+ end
91
+
77
92
  def before_request_phase(&block)
78
93
  if block_given?
79
94
  @before_request_phase = block
@@ -111,8 +126,9 @@ module OmniAuth
111
126
  camelizations[name.to_s] = camelized.to_s
112
127
  end
113
128
 
114
- attr_writer :on_failure, :before_callback_phase, :before_options_phase, :before_request_phase
115
- attr_accessor :failure_raise_out_environments, :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host, :camelizations, :logger
129
+ attr_writer :on_failure, :before_callback_phase, :before_options_phase, :before_request_phase, :request_validation_phase
130
+ attr_accessor :failure_raise_out_environments, :path_prefix, :allowed_request_methods, :form_css,
131
+ :test_mode, :mock_auth, :full_host, :camelizations, :logger, :silence_get_warning
116
132
  end
117
133
 
118
134
  def self.config
@@ -132,7 +148,7 @@ module OmniAuth
132
148
  end
133
149
 
134
150
  module Utils
135
- module_function
151
+ module_function # rubocop:disable Layout/IndentationWidth
136
152
 
137
153
  def form_css
138
154
  "<style type='text/css'>#{OmniAuth.config.form_css}</style>"
@@ -141,7 +157,7 @@ module OmniAuth
141
157
  def deep_merge(hash, other_hash)
142
158
  target = hash.dup
143
159
 
144
- other_hash.keys.each do |key|
160
+ other_hash.each_key do |key|
145
161
  if other_hash[key].is_a?(::Hash) && hash[key].is_a?(::Hash)
146
162
  target[key] = deep_merge(target[key], other_hash[key])
147
163
  next
@@ -159,7 +175,7 @@ module OmniAuth
159
175
  if first_letter_in_uppercase
160
176
  word.to_s.gsub(%r{/(.?)}) { '::' + Regexp.last_match[1].upcase }.gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
161
177
  else
162
- word.first + camelize(word)[1..-1]
178
+ camelize(word).tap { |w| w[0] = w[0].downcase }
163
179
  end
164
180
  end
165
181
  end
data/omniauth.gemspec CHANGED
@@ -1,22 +1,25 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'omniauth/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.add_dependency 'hashie', ['>= 1.2', '< 4']
8
- spec.add_dependency 'rack', ['>= 1.0', '< 3']
9
- spec.add_development_dependency 'bundler', '~> 1.0'
10
- spec.add_development_dependency 'rake', '>= 10.5'
8
+ spec.add_dependency 'hashie', ['>= 3.4.6']
9
+ spec.add_dependency 'rack', '>= 2.2.3'
10
+ spec.add_development_dependency 'bundler', '~> 2.0'
11
+ spec.add_dependency 'rack-protection'
12
+ spec.add_development_dependency 'rake', '~> 12.0'
11
13
  spec.authors = ['Michael Bleigh', 'Erik Michaels-Ober', 'Tom Milewski']
12
14
  spec.description = 'A generalized Rack framework for multiple-provider authentication.'
13
15
  spec.email = ['michael@intridea.com', 'sferik@gmail.com', 'tmilewski@gmail.com']
14
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.start_with?('spec/') }
15
17
  spec.homepage = 'https://github.com/omniauth/omniauth'
16
- spec.licenses = %w(MIT)
18
+ spec.licenses = %w[MIT]
17
19
  spec.name = 'omniauth'
18
- spec.require_paths = %w(lib)
20
+ spec.require_paths = %w[lib]
19
21
  spec.required_rubygems_version = '>= 1.3.5'
22
+ spec.required_ruby_version = '>= 2.2'
20
23
  spec.summary = spec.description
21
24
  spec.version = OmniAuth::VERSION
22
25
  end