omniauth 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of omniauth might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ccca6a859c1cf14b111691d6447c4fda9e6a392
4
- data.tar.gz: 9b5e43d88cdc536a6e2e31111ea81f547d18abe9
3
+ metadata.gz: db04fc4ab8d9dba42728ba79989f142dcd82bac6
4
+ data.tar.gz: 911610ee6a8e350ea53daeffa0f37d4d2a7997b5
5
5
  SHA512:
6
- metadata.gz: cae2202a6cfd9bbd4f0f5bc5b68d613e4890458ac14cdd6e919e1e53db3cb5835b17c3b0d426a4cce305b4508943534e7ebde9b2638fa1864cf3e929b3393603
7
- data.tar.gz: 4ea31502c6e79c25aa73e39340becc0302d4001fad09b0921ad08f211e6467a9b2a9982be5cadf63975b6f0e8af85291500492de52913af240d38da9a6de7e99
6
+ metadata.gz: 2de66181c46fc2e4a669606e5335fa21e64a317020847835832b204a5a5e382056c2c6244b02fa91359f0214bbe773f0520371b4fea51a65af3c6e95b3ea043b
7
+ data.tar.gz: 254628c583eed6e57ccd6e75e029a9686f7470abc1fe08e011f6170dc6f8a80becb5a4c036b0c7e1419197b61e4d9432f72997eb68823a097ea9eb3609ad613f
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  .rvmrc
5
5
  .yardoc
6
6
  Gemfile.lock
7
+ Gemfile.*.lock
7
8
  coverage/*
8
9
  doc/*
9
10
  log/*
@@ -1,81 +1,57 @@
1
- AllCops:
2
- Include:
3
- - 'Gemfile'
4
- - 'Rakefile'
5
- - 'omniauth.gemspec'
6
-
7
- # Avoid long parameter lists
8
- ParameterLists:
9
- Max: 4
10
- CountKeywordArgs: true
1
+ Lint/HandleExceptions:
2
+ Enabled: false
3
+
4
+ Metrics/BlockNesting:
5
+ Max: 2
6
+
7
+ Metrics/LineLength:
8
+ AllowURI: true
9
+ Enabled: false
11
10
 
12
- MethodLength:
11
+ Metrics/MethodLength:
13
12
  CountComments: false
14
13
  Max: 15
15
14
 
16
- # Avoid more than `Max` levels of nesting.
17
- BlockNesting:
18
- Max: 2
15
+ Metrics/ParameterLists:
16
+ Max: 4
17
+ CountKeywordArgs: true
18
+
19
+ Metrics/AbcSize:
20
+ Enabled: false
19
21
 
20
- # Align with the style guide.
21
- CollectionMethods:
22
+ Style/AccessModifierIndentation:
23
+ EnforcedStyle: outdent
24
+
25
+ Style/CollectionMethods:
22
26
  PreferredMethods:
23
27
  map: 'collect'
24
28
  reduce: 'inject'
25
29
  find: 'detect'
26
30
  find_all: 'select'
27
31
 
28
- # Limit line length
29
- LineLength:
30
- Enabled: false
31
-
32
- # Disable documentation checking until a class needs to be documented once
33
- Documentation:
32
+ Style/Documentation:
34
33
  Enabled: false
35
34
 
36
- # Enforce Ruby 1.8-compatible hash syntax
37
- HashSyntax:
38
- EnforcedStyle: hash_rockets
39
-
40
- # No spaces inside hash literals
41
- SpaceInsideHashLiteralBraces:
42
- EnforcedStyle: no_space
35
+ Style/DotPosition:
36
+ EnforcedStyle: trailing
43
37
 
44
- # Allow dots at the end of lines
45
- DotPosition:
38
+ Style/DoubleNegation:
46
39
  Enabled: false
47
40
 
48
- # Don't require magic comment at the top of every file
49
- Encoding:
41
+ Style/EachWithObject:
50
42
  Enabled: false
51
43
 
52
- # Enforce outdenting of access modifiers (i.e. public, private, protected)
53
- AccessModifierIndentation:
54
- EnforcedStyle: outdent
55
-
56
- EmptyLinesAroundAccessModifier:
57
- Enabled: true
58
-
59
- # Align ends correctly
60
- EndAlignment:
61
- AlignWith: variable
62
-
63
- # Indentation of when/else
64
- CaseIndentation:
65
- IndentWhenRelativeTo: end
66
- IndentOneStep: false
67
-
68
- Lambda:
44
+ Style/Encoding:
69
45
  Enabled: false
70
46
 
71
- HandleExceptions:
47
+ Style/HashSyntax:
48
+ EnforcedStyle: hash_rockets
49
+
50
+ Style/Lambda:
72
51
  Enabled: false
73
52
 
74
- RaiseArgs:
53
+ Style/RaiseArgs:
75
54
  EnforcedStyle: compact
76
55
 
77
- TrailingComma:
78
- Enabled: false
79
-
80
- EachWithObject:
81
- Enabled: false
56
+ Style/SpaceInsideHashLiteralBraces:
57
+ EnforcedStyle: no_space
@@ -1,37 +1,33 @@
1
1
  bundler_args: --without development
2
+ before_install: gem install bundler
3
+ cache: bundler
4
+ env:
5
+ global:
6
+ - JRUBY_OPTS="$JRUBY_OPTS --debug"
2
7
  gemfile:
3
8
  - Gemfile
4
9
  - Gemfile.rack-1.3.x
5
10
  language: ruby
6
11
  rvm:
12
+ - jruby-18mode
13
+ - jruby-19mode
14
+ - jruby-9000
7
15
  - 1.8.7
8
- - 1.9.2
9
16
  - 1.9.3
10
17
  - 2.0.0
11
- - 2.1.0
18
+ - 2.1
19
+ - 2.2
20
+ - jruby-head
12
21
  - rbx-2
13
22
  - ruby-head
14
23
  matrix:
15
24
  include:
16
- - rvm: jruby-18mode
17
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
18
- gemfile: Gemfile
19
- - rvm: jruby-18mode
20
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
21
- gemfile: Gemfile.rack-1.3.x
22
- - rvm: jruby-19mode
23
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
24
- gemfile: Gemfile
25
- - rvm: jruby-19mode
26
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
27
- gemfile: Gemfile.rack-1.3.x
28
- - rvm: jruby-head
29
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
30
- gemfile: Gemfile
31
- - rvm: jruby-head
32
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
33
- gemfile: Gemfile.rack-1.3.x
25
+ - rvm: 2.2.2
26
+ gemfile: Gemfile.rack-master
34
27
  allow_failures:
35
28
  - rvm: jruby-head
29
+ - rvm: rbx-2
36
30
  - rvm: ruby-head
31
+ - gemfile: Gemfile.rack-master
37
32
  fast_finish: true
33
+ sudo: false
data/Gemfile CHANGED
@@ -5,29 +5,20 @@ gem 'rake'
5
5
  gem 'yard'
6
6
 
7
7
  group :development do
8
- gem 'growl'
9
- platforms :ruby_19, :ruby_20 do
10
- gem 'guard'
11
- gem 'guard-bundler'
12
- gem 'guard-rspec'
13
- end
14
8
  gem 'kramdown'
15
- gem 'plymouth', :platforms => [:ruby_19, :ruby_20, :ruby_21]
16
9
  gem 'pry'
17
- gem 'pry-debugger', :platforms => [:mri_19, :mri_20]
18
- gem 'pry-byebug', :platforms => [:mri_21]
19
- gem 'rb-fsevent'
20
10
  end
21
11
 
22
12
  group :test do
23
- gem 'coveralls', :require => false
24
- gem 'json', '>= 1.8.1', :platforms => [:jruby, :ruby_18, :ruby_19]
25
- gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
13
+ gem 'coveralls'
14
+ gem 'hashie', '~> 2.0.5', :platforms => [:jruby_18, :ruby_18]
15
+ gem 'json', '>= 1.8.1', :platforms => [:jruby_18, :jruby_19, :ruby_18, :ruby_19]
16
+ gem 'mime-types', '~> 1.25', :platforms => [:jruby_18, :ruby_18]
26
17
  gem 'rack-test'
27
- gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
18
+ gem 'rest-client', '~> 1.6.0', :platforms => [:jruby_18, :ruby_18]
28
19
  gem 'rspec', '~> 3.0'
29
- gem 'rubocop', '>= 0.23', :platforms => [:ruby_19, :ruby_20, :ruby_21]
30
- gem 'simplecov', :require => false
20
+ gem 'rubocop', '>= 0.25', :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
21
+ gem 'simplecov', '>= 0.9'
31
22
  end
32
23
 
33
24
  gemspec
@@ -6,20 +6,15 @@ gem 'rake'
6
6
  gem 'yard'
7
7
 
8
8
  group :test do
9
- gem 'coveralls', :require => false
10
- gem 'json', '>= 1.8.1', :platforms => [:jruby, :rbx, :ruby_18, :ruby_19]
11
- gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
9
+ gem 'coveralls'
10
+ gem 'hashie', '~> 2.0.5', :platforms => [:jruby_18, :ruby_18]
11
+ gem 'json', '>= 1.8.1', :platforms => [:jruby_18, :jruby_18, :ruby_18, :ruby_19]
12
+ gem 'mime-types', '~> 1.25', :platforms => [:jruby_18, :ruby_18]
12
13
  gem 'rack-test'
13
- gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
14
- gem 'rspec', '>= 2.14'
15
- gem 'rubocop', '>= 0.23', :platforms => [:ruby_19, :ruby_20, :ruby_21]
16
- gem 'simplecov', :require => false
17
- end
18
-
19
- platforms :rbx do
20
- gem 'racc'
21
- gem 'rubinius-coverage', '~> 2.0'
22
- gem 'rubysl', '~> 2.0'
14
+ gem 'rest-client', '~> 1.6.0', :platforms => [:jruby_18, :ruby_18]
15
+ gem 'rspec', '~> 3.0'
16
+ gem 'rubocop', '>= 0.25', :platforms => [:ruby_19, :ruby_20, :ruby_21]
17
+ gem 'simplecov', '>= 0.9'
23
18
  end
24
19
 
25
20
  gemspec
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'jruby-openssl', :platforms => :jruby
4
+ gem 'rack', :git => 'https://github.com/rack/rack.git'
5
+ gem 'rake'
6
+ gem 'yard'
7
+
8
+ group :test do
9
+ gem 'coveralls'
10
+ gem 'rack-test'
11
+ gem 'rspec', '~> 3.0'
12
+ gem 'rubocop', '>= 0.25'
13
+ gem 'simplecov', '>= 0.9'
14
+ end
15
+
16
+ gemspec
data/README.md CHANGED
@@ -143,7 +143,7 @@ your first stop if you are wondering about a more in-depth look at
143
143
  OmniAuth, how it works, and how to use it.
144
144
 
145
145
  ## Supported Ruby Versions
146
- OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1.0, JRuby, and Rubinius.
146
+ OmniAuth is tested under 1.8.7, 1.9.3, 2.0.0, 2.1.0, JRuby, and Rubinius.
147
147
 
148
148
  ## Versioning
149
149
  This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
@@ -82,19 +82,15 @@ module OmniAuth
82
82
  end
83
83
  end
84
84
 
85
- def add_mock(provider, mock = {})
86
- # Stringify keys recursively one level.
87
- mock.keys.each do |key|
88
- mock[key.to_s] = mock.delete(key)
89
- end
90
- mock.each_pair do |_key, val|
91
- if val.is_a? Hash
92
- val.keys.each do |subkey|
93
- val[subkey.to_s] = val.delete(subkey)
94
- end
95
- else
96
- next
97
- end
85
+ def add_mock(provider, original = {})
86
+ # Create key-stringified new hash from given auth hash
87
+ mock = {}
88
+ original.each_pair do |key, val|
89
+ mock[key.to_s] = if val.is_a? Hash
90
+ Hash[val.each_pair { |k, v| [k.to_s, v] }]
91
+ else
92
+ val
93
+ end
98
94
  end
99
95
 
100
96
  # Merge with the default mock and ensure provider is correct.
@@ -136,7 +132,7 @@ module OmniAuth
136
132
  end
137
133
 
138
134
  module Utils
139
- module_function
135
+ module_function
140
136
 
141
137
  def form_css
142
138
  "<style type='text/css'>#{OmniAuth.config.form_css}</style>"
@@ -161,7 +157,7 @@ module OmniAuth
161
157
  return OmniAuth.config.camelizations[word.to_s] if OmniAuth.config.camelizations[word.to_s]
162
158
 
163
159
  if first_letter_in_uppercase
164
- word.to_s.gsub(/\/(.?)/) { '::' + Regexp.last_match[1].upcase }.gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
160
+ word.to_s.gsub(%r{/(.?)}) { '::' + Regexp.last_match[1].upcase }.gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
165
161
  else
166
162
  word.first + camelize(word)[1..-1]
167
163
  end
@@ -40,7 +40,7 @@ module OmniAuth
40
40
  end
41
41
 
42
42
  def name?
43
- !!name # rubocop:disable DoubleNegation
43
+ !!name
44
44
  end
45
45
  alias_method :valid?, :name?
46
46
 
@@ -2,7 +2,7 @@ module OmniAuth
2
2
  class Builder < ::Rack::Builder
3
3
  def initialize(app, &block)
4
4
  @options = nil
5
- if rack14?
5
+ if rack14? || rack2?
6
6
  super
7
7
  else
8
8
  @app = app
@@ -12,7 +12,11 @@ module OmniAuth
12
12
  end
13
13
 
14
14
  def rack14?
15
- Rack.release.split('.')[1].to_i >= 4
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.'
16
20
  end
17
21
 
18
22
  def on_failure(&block)
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
- class Form # rubocop:disable ClassLength
2
+ class Form
3
3
  DEFAULT_CSS = File.read(File.expand_path('../form.css', __FILE__))
4
4
 
5
5
  attr_accessor :options
@@ -37,7 +37,7 @@ module OmniAuth
37
37
  def request_phase
38
38
  form = OmniAuth::Form.new(:title => 'User Info', :url => callback_path)
39
39
  options.fields.each do |field|
40
- form.text_field field.to_s.capitalize.gsub('_', ' '), field.to_s
40
+ form.text_field field.to_s.capitalize.tr('_', ' '), field.to_s
41
41
  end
42
42
  form.button 'Sign In'
43
43
  form.to_response
@@ -6,7 +6,7 @@ module OmniAuth
6
6
  # wrangle multiple providers. Each strategy provided by
7
7
  # OmniAuth includes this mixin to gain the default functionality
8
8
  # necessary to be compatible with the OmniAuth library.
9
- module Strategy
9
+ module Strategy # rubocop:disable ModuleLength
10
10
  def self.included(base)
11
11
  OmniAuth.strategies << base
12
12
 
@@ -169,7 +169,7 @@ module OmniAuth
169
169
  # the request path is recognized.
170
170
  #
171
171
  # @param env [Hash] The Rack environment.
172
- def call!(env) # rubocop:disable CyclomaticComplexity
172
+ def call!(env) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
173
173
  unless env['rack.session']
174
174
  error = OmniAuth::NoSessionError.new('You must provide a session to use OmniAuth.')
175
175
  fail(error)
@@ -194,7 +194,7 @@ module OmniAuth
194
194
  end
195
195
 
196
196
  # Performs the steps necessary to run the request phase of a strategy.
197
- def request_call # rubocop:disable CyclomaticComplexity, MethodLength
197
+ def request_call # rubocop:disable CyclomaticComplexity, MethodLength, PerceivedComplexity
198
198
  setup_phase
199
199
  log :info, 'Request phase initiated.'
200
200
  # store query params from the request url, extracted in the callback_phase
@@ -278,14 +278,14 @@ module OmniAuth
278
278
 
279
279
  def mock_callback_call
280
280
  setup_phase
281
+ @env['omniauth.origin'] = session.delete('omniauth.origin')
282
+ @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
281
283
  mocked_auth = OmniAuth.mock_auth_for(name.to_s)
282
284
  if mocked_auth.is_a?(Symbol)
283
285
  fail!(mocked_auth)
284
286
  else
285
287
  @env['omniauth.auth'] = mocked_auth
286
288
  @env['omniauth.params'] = session.delete('omniauth.params') || {}
287
- @env['omniauth.origin'] = session.delete('omniauth.origin')
288
- @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
289
289
  OmniAuth.config.before_callback_phase.call(@env) if OmniAuth.config.before_callback_phase
290
290
  call_app!
291
291
  end
@@ -377,23 +377,27 @@ module OmniAuth
377
377
  end
378
378
 
379
379
  def request_path
380
- options[:request_path].is_a?(String) ? options[:request_path] : "#{path_prefix}/#{name}"
380
+ @request_path ||= options[:request_path].is_a?(String) ? options[:request_path] : "#{path_prefix}/#{name}"
381
381
  end
382
382
 
383
383
  def callback_path
384
- path = options[:callback_path] if options[:callback_path].is_a?(String)
385
- path ||= current_path if options[:callback_path].respond_to?(:call) && options[:callback_path].call(env)
386
- path ||= custom_path(:request_path)
387
- path ||= "#{path_prefix}/#{name}/callback"
388
- path
384
+ @callback_path ||= begin
385
+ path = options[:callback_path] if options[:callback_path].is_a?(String)
386
+ path ||= current_path if options[:callback_path].respond_to?(:call) && options[:callback_path].call(env)
387
+ path ||= custom_path(:request_path)
388
+ path ||= "#{path_prefix}/#{name}/callback"
389
+ path
390
+ end
389
391
  end
390
392
 
391
393
  def setup_path
392
394
  options[:setup_path] || "#{path_prefix}/#{name}/setup"
393
395
  end
394
396
 
397
+ CURRENT_PATH_REGEX = %r{/$}
398
+ EMPTY_STRING = ''.freeze
395
399
  def current_path
396
- request.path_info.downcase.sub(/\/$/, '')
400
+ @current_path ||= request.path_info.downcase.sub(CURRENT_PATH_REGEX, EMPTY_STRING)
397
401
  end
398
402
 
399
403
  def query_string
@@ -475,6 +479,12 @@ module OmniAuth
475
479
  OmniAuth.config.on_failure.call(env)
476
480
  end
477
481
 
482
+ def dup
483
+ super.tap do
484
+ @options = @options.dup
485
+ end
486
+ end
487
+
478
488
  class Options < Hashie::Mash; end
479
489
 
480
490
  protected
@@ -488,10 +498,10 @@ module OmniAuth
488
498
 
489
499
  def ssl?
490
500
  request.env['HTTPS'] == 'on' ||
491
- request.env['HTTP_X_FORWARDED_SSL'] == 'on' ||
492
- request.env['HTTP_X_FORWARDED_SCHEME'] == 'https' ||
493
- (request.env['HTTP_X_FORWARDED_PROTO'] && request.env['HTTP_X_FORWARDED_PROTO'].split(',')[0] == 'https') ||
494
- request.env['rack.url_scheme'] == 'https'
501
+ request.env['HTTP_X_FORWARDED_SSL'] == 'on' ||
502
+ request.env['HTTP_X_FORWARDED_SCHEME'] == 'https' ||
503
+ (request.env['HTTP_X_FORWARDED_PROTO'] && request.env['HTTP_X_FORWARDED_PROTO'].split(',')[0] == 'https') ||
504
+ request.env['rack.url_scheme'] == 'https'
495
505
  end
496
506
  end
497
507
  end