omniauth 1.3.1 → 1.9.1

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: 06e30f31bdee870b242a81af5c01e813539e8030
4
- data.tar.gz: c417d4689e17580d7f018205c298f41d3ff3c644
3
+ metadata.gz: a60cc2e4ba6c8135e9707ee25a4075b2948c5ca7
4
+ data.tar.gz: 8e240213e8aa84d5f37e7f1de2fae934dbc5bb70
5
5
  SHA512:
6
- metadata.gz: 2b3928add7b13234a4272afa70076b7e13c76256f9ca55c40aa50fd435f108609621b7ae0954407880a51422f5354b40b4332478e6df7f15cfc5cb16167e476a
7
- data.tar.gz: a2706e7afe3eb62b911c151d216f2b22fa02b92f4c0e0aa08ad89fd627bb90ec8c5a2d8fc58b0bdbca87a664775ab7654ec3f83cf568581d3402d3d78b6189a0
6
+ metadata.gz: cab0699b737d95347ef012062ef88a1e4c73d961a7154345157b77be0e32212d5a4a32ccc645714024a1e645926d82d3b8e7a7644e159ac9f5015d9f195e249a
7
+ data.tar.gz: c68c617b16b9c9bba273c150604a9bc4ab832a1f18dbe0e09e88d39c07be772718ff681c293a25515d2fdf9701f7eb50cec88810188e3fc156842503cc623551
@@ -0,0 +1,20 @@
1
+ Please complete all sections.
2
+
3
+ ### Configuration
4
+
5
+ - Provider Gem: `omniauth-*`
6
+ - Ruby Version: ``
7
+ - Framework: ``
8
+ - Platform: ``
9
+
10
+ ### Expected Behavior
11
+
12
+ Tell us what should happen.
13
+
14
+ ### Actual Behavior
15
+
16
+ Tell us what happens instead.
17
+
18
+ ### Steps to Reproduce
19
+
20
+ Please list all steps to reproduce the issue.
@@ -1,6 +1,24 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+
4
+ Layout/AccessModifierIndentation:
5
+ EnforcedStyle: outdent
6
+
7
+ Layout/AlignHash:
8
+ Enabled: false
9
+
10
+ Layout/DotPosition:
11
+ EnforcedStyle: trailing
12
+
13
+ Layout/SpaceInsideHashLiteralBraces:
14
+ EnforcedStyle: no_space
15
+
1
16
  Lint/HandleExceptions:
2
17
  Enabled: false
3
18
 
19
+ Metrics/BlockLength:
20
+ Enabled: false
21
+
4
22
  Metrics/BlockNesting:
5
23
  Max: 2
6
24
 
@@ -19,9 +37,6 @@ Metrics/ParameterLists:
19
37
  Metrics/AbcSize:
20
38
  Enabled: false
21
39
 
22
- Style/AccessModifierIndentation:
23
- EnforcedStyle: outdent
24
-
25
40
  Style/CollectionMethods:
26
41
  PreferredMethods:
27
42
  map: 'collect'
@@ -32,9 +47,6 @@ Style/CollectionMethods:
32
47
  Style/Documentation:
33
48
  Enabled: false
34
49
 
35
- Style/DotPosition:
36
- EnforcedStyle: trailing
37
-
38
50
  Style/DoubleNegation:
39
51
  Enabled: false
40
52
 
@@ -44,6 +56,9 @@ Style/EachWithObject:
44
56
  Style/Encoding:
45
57
  Enabled: false
46
58
 
59
+ Style/ExpandPathArguments:
60
+ Enabled: false
61
+
47
62
  Style/HashSyntax:
48
63
  EnforcedStyle: hash_rockets
49
64
 
@@ -52,6 +67,3 @@ Style/Lambda:
52
67
 
53
68
  Style/RaiseArgs:
54
69
  EnforcedStyle: compact
55
-
56
- Style/SpaceInsideHashLiteralBraces:
57
- EnforcedStyle: no_space
@@ -1,33 +1,25 @@
1
1
  bundler_args: --without development
2
- before_install: gem install bundler
2
+ before_install:
3
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
4
+ - gem install bundler -v '1.17.3'
5
+ install:
6
+ - bundle _1.17.3_ install --jobs=3 --retry=3
3
7
  cache: bundler
4
8
  env:
5
9
  global:
6
10
  - JRUBY_OPTS="$JRUBY_OPTS --debug"
7
- gemfile:
8
- - Gemfile
9
- - Gemfile.rack-1.3.x
10
11
  language: ruby
11
12
  rvm:
12
- - jruby-18mode
13
- - jruby-19mode
14
13
  - jruby-9000
15
- - 1.8.7
16
- - 1.9.3
17
- - 2.0.0
18
- - 2.1
19
- - 2.2
14
+ - 2.2.9
15
+ - 2.3.5
16
+ - 2.4.4
17
+ - 2.5.3
20
18
  - jruby-head
21
- - rbx-2
22
19
  - ruby-head
23
20
  matrix:
24
- include:
25
- - rvm: 2.2.2
26
- gemfile: Gemfile.rack-master
27
21
  allow_failures:
28
22
  - rvm: jruby-head
29
- - rvm: rbx-2
30
23
  - rvm: ruby-head
31
- - gemfile: Gemfile.rack-master
32
24
  fast_finish: true
33
25
  sudo: false
data/Gemfile CHANGED
@@ -1,24 +1,27 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'jruby-openssl', :platforms => :jruby
4
- gem 'rake'
5
- gem 'yard'
3
+ gem 'jruby-openssl', '~> 0.9.19', :platforms => :jruby
4
+ gem 'rake', '>= 12.0'
5
+ gem 'yard', '>= 0.9.11'
6
6
 
7
7
  group :development do
8
+ gem 'benchmark-ips'
8
9
  gem 'kramdown'
10
+ gem 'memory_profiler'
9
11
  gem 'pry'
10
12
  end
11
13
 
12
14
  group :test do
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]
15
+ gem 'coveralls', :require => false
16
+ gem 'hashie', '>= 3.4.6', '~> 4.0.0', :platforms => [:jruby_18]
17
+ gem 'json', '~> 2.0.3', :platforms => %i[jruby_18 jruby_19 ruby_19]
18
+ gem 'mime-types', '~> 3.1', :platforms => [:jruby_18]
19
+ gem 'rack', '>= 2.0.6', :platforms => %i[jruby_18 jruby_19 ruby_19 ruby_20 ruby_21]
17
20
  gem 'rack-test'
18
- gem 'rest-client', '~> 1.6.0', :platforms => [:jruby_18, :ruby_18]
19
- gem 'rspec', '~> 3.0'
20
- gem 'rubocop', '>= 0.25', :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
21
- gem 'simplecov', '>= 0.9'
21
+ gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18]
22
+ gem 'rspec', '~> 3.5.0'
23
+ gem 'rubocop', '>= 0.58.2', '< 0.69.0', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]
24
+ gem 'tins', '~> 1.13.0', :platforms => %i[jruby_18 jruby_19 ruby_19]
22
25
  end
23
26
 
24
27
  gemspec
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2013 Michael Bleigh and Intridea, Inc.
1
+ Copyright (c) 2010-2017 Michael Bleigh and Intridea, Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,22 +1,15 @@
1
1
  # OmniAuth: Standardized Multi-Provider Authentication
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/omniauth.svg)][gem]
4
- [![Build Status](http://img.shields.io/travis/intridea/omniauth.svg)][travis]
5
- [![Dependency Status](http://img.shields.io/gemnasium/intridea/omniauth.svg)][gemnasium]
6
- [![Code Climate](http://img.shields.io/codeclimate/github/intridea/omniauth.svg)][codeclimate]
7
- [![Coverage Status](http://img.shields.io/coveralls/intridea/omniauth.svg)][coveralls]
8
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/intridea/omniauth/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
4
+ [![Build Status](http://img.shields.io/travis/omniauth/omniauth.svg)][travis]
5
+ [![Code Climate](http://img.shields.io/codeclimate/github/omniauth/omniauth.svg)][codeclimate]
6
+ [![Coverage Status](http://img.shields.io/coveralls/omniauth/omniauth.svg)][coveralls]
7
+ [![Security](https://hakiri.io/github/omniauth/omniauth/master.svg)](https://hakiri.io/github/omniauth/omniauth/master)
9
8
 
10
9
  [gem]: https://rubygems.org/gems/omniauth
11
- [travis]: http://travis-ci.org/intridea/omniauth
12
- [gemnasium]: https://gemnasium.com/intridea/omniauth
13
- [codeclimate]: https://codeclimate.com/github/intridea/omniauth
14
- [coveralls]: https://coveralls.io/r/intridea/omniauth
15
-
16
- **OmniAuth 1.0 has several breaking changes from version 0.x. You can set
17
- the dependency to `~> 0.3.2` if you do not wish to make the more difficult
18
- upgrade. See [the wiki](https://github.com/intridea/omniauth/wiki/Upgrading-to-1.0)
19
- for more information.**
10
+ [travis]: http://travis-ci.org/omniauth/omniauth
11
+ [codeclimate]: https://codeclimate.com/github/omniauth/omniauth
12
+ [coveralls]: https://coveralls.io/r/omniauth/omniauth
20
13
 
21
14
  ## An Introduction
22
15
  OmniAuth is a library that standardizes multi-provider authentication for
@@ -27,7 +20,7 @@ have been created for everything from Facebook to LDAP.
27
20
 
28
21
  In order to use OmniAuth in your applications, you will need to leverage
29
22
  one or more strategies. These strategies are generally released
30
- individually as RubyGems, and you can see a [community maintained list](https://github.com/intridea/omniauth/wiki/List-of-Strategies)
23
+ individually as RubyGems, and you can see a [community maintained list](https://github.com/omniauth/omniauth/wiki/List-of-Strategies)
31
24
  on the wiki for this project.
32
25
 
33
26
  One strategy, called `Developer`, is included with OmniAuth and provides
@@ -120,13 +113,71 @@ Authentication Hash which will contain information about the just
120
113
  authenticated user including a unique id, the strategy they just used
121
114
  for authentication, and personal details such as name and email address
122
115
  as available. For an in-depth description of what the authentication
123
- hash might contain, see the [Auth Hash Schema wiki page](https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema).
116
+ hash might contain, see the [Auth Hash Schema wiki page](https://github.com/omniauth/omniauth/wiki/Auth-Hash-Schema).
124
117
 
125
118
  Note that OmniAuth does not perform any actions beyond setting some
126
119
  environment information on the callback request. It is entirely up to
127
120
  you how you want to implement the particulars of your application's
128
121
  authentication flow.
129
122
 
123
+ **Please note:** there is currently a CSRF vulnerability which affects OmniAuth (designated [CVE-2015-9284](https://nvd.nist.gov/vuln/detail/CVE-2015-9284)) that requires mitigation at the application level. More details on how to do this can be found on the [Wiki](https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284).
124
+
125
+ ## Configuring The `origin` Param
126
+ The `origin` url parameter is typically used to inform where a user came from and where, should you choose to use it, they'd want to return to.
127
+
128
+ There are three possible options:
129
+
130
+ Default Flow:
131
+ ```ruby
132
+ # /auth/twitter/?origin=[URL]
133
+ # No change
134
+ # If blank, `omniauth.origin` is set to HTTP_REFERER
135
+ ```
136
+
137
+ Renaming Origin Param:
138
+ ```ruby
139
+ # /auth/twitter/?return_to=[URL]
140
+ # If blank, `omniauth.origin` is set to HTTP_REFERER
141
+ provider :twitter, ENV['KEY'], ENV['SECRET'], origin_param: 'return_to'
142
+ ```
143
+
144
+ Disabling Origin Param:
145
+ ```ruby
146
+ # /auth/twitter
147
+ # Origin handled externally, if need be. `omniauth.origin` is not set
148
+ provider :twitter, ENV['KEY'], ENV['SECRET'], origin_param: false
149
+ ```
150
+
151
+ ## Integrating OmniAuth Into Your Rails API
152
+ The following middleware are (by default) included for session management in
153
+ Rails applications. When using OmniAuth with a Rails API, you'll need to add
154
+ one of these required middleware back in:
155
+
156
+ - `ActionDispatch::Session::CacheStore`
157
+ - `ActionDispatch::Session::CookieStore`
158
+ - `ActionDispatch::Session::MemCacheStore`
159
+
160
+ The trick to adding these back in is that, by default, they are passed
161
+ `session_options` when added (including the session key), so you can't just add
162
+ a `session_store.rb` initializer, add `use ActionDispatch::Session::CookieStore`
163
+ and have sessions functioning as normal.
164
+
165
+ To be clear: sessions may work, but your session options will be ignored
166
+ (i.e the session key will default to `_session_id`). Instead of the
167
+ initializer, you'll have to set the relevant options somewhere
168
+ before your middleware is built (like `application.rb`) and pass them to your
169
+ preferred middleware, like this:
170
+
171
+ **application.rb:**
172
+
173
+ ```ruby
174
+ config.session_store :cookie_store, key: '_interslice_session'
175
+ config.middleware.use ActionDispatch::Cookies # Required for all session management
176
+ config.middleware.use ActionDispatch::Session::CookieStore, config.session_options
177
+ ```
178
+
179
+ (Thanks @mltsy)
180
+
130
181
  ## Logging
131
182
  OmniAuth supports a configurable logger. By default, OmniAuth will log
132
183
  to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
@@ -137,13 +188,13 @@ OmniAuth.config.logger = Rails.logger
137
188
  ```
138
189
 
139
190
  ## Resources
140
- The [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki) has
191
+ The [OmniAuth Wiki](https://github.com/omniauth/omniauth/wiki) has
141
192
  actively maintained in-depth documentation for OmniAuth. It should be
142
193
  your first stop if you are wondering about a more in-depth look at
143
194
  OmniAuth, how it works, and how to use it.
144
195
 
145
196
  ## Supported Ruby Versions
146
- OmniAuth is tested under 1.8.7, 1.9.3, 2.0.0, 2.1.0, JRuby, and Rubinius.
197
+ OmniAuth is tested under 2.1.10, 2.2.6, 2.3.3, 2.4.0, 2.5.0, and JRuby.
147
198
 
148
199
  ## Versioning
149
200
  This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
@@ -158,10 +209,10 @@ Constraint][pvc] with two digits of precision. For example:
158
209
  spec.add_dependency 'omniauth', '~> 1.0'
159
210
 
160
211
  [semver]: http://semver.org/
161
- [pvc]: http://docs.rubygems.org/read/chapter/16#page74
212
+ [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
162
213
 
163
214
  ## License
164
- Copyright (c) 2010-2013 Michael Bleigh and Intridea, Inc. See [LICENSE][] for
215
+ Copyright (c) 2010-2017 Michael Bleigh and Intridea, Inc. See [LICENSE][] for
165
216
  details.
166
217
 
167
218
  [license]: LICENSE.md
data/Rakefile CHANGED
@@ -10,8 +10,44 @@ begin
10
10
  RuboCop::RakeTask.new
11
11
  rescue LoadError
12
12
  task :rubocop do
13
- $stderr.puts 'RuboCop is disabled'
13
+ warn 'RuboCop is disabled'
14
14
  end
15
15
  end
16
16
 
17
- task :default => [:spec, :rubocop]
17
+ task :default => %i[spec rubocop]
18
+
19
+ namespace :perf do
20
+ task :setup do
21
+ require 'omniauth'
22
+ require 'rack/test'
23
+ app = Rack::Builder.new do |b|
24
+ b.use Rack::Session::Cookie, :secret => 'abc123'
25
+ b.use OmniAuth::Strategies::Developer
26
+ b.run lambda { |_env| [200, {}, ['Not Found']] }
27
+ end.to_app
28
+ @app = Rack::MockRequest.new(app)
29
+
30
+ def call_app(path = ENV['GET_PATH'] || '/')
31
+ result = @app.get(path)
32
+ raise "Did not succeed #{result.body}" unless result.status == 200
33
+
34
+ result
35
+ end
36
+ end
37
+
38
+ task :ips => :setup do
39
+ require 'benchmark/ips'
40
+ Benchmark.ips do |x|
41
+ x.report('ips') { call_app }
42
+ end
43
+ end
44
+
45
+ task :mem => :setup do
46
+ require 'memory_profiler'
47
+ num = Integer(ENV['CNT'] || 1)
48
+ report = MemoryProfiler.report do
49
+ num.times { call_app }
50
+ end
51
+ report.pretty_print
52
+ end
53
+ end
@@ -41,7 +41,7 @@ module OmniAuth
41
41
  :form_css => Form::DEFAULT_CSS,
42
42
  :test_mode => false,
43
43
  :logger => default_logger,
44
- :allowed_request_methods => [:get, :post],
44
+ :allowed_request_methods => %i[get post],
45
45
  :mock_auth => {:default => AuthHash.new('provider' => 'default', 'uid' => '1234', 'info' => {'name' => 'Example User'})}
46
46
  }
47
47
  end
@@ -132,7 +132,7 @@ module OmniAuth
132
132
  end
133
133
 
134
134
  module Utils
135
- module_function
135
+ module_function # rubocop:disable Layout/IndentationWidth
136
136
 
137
137
  def form_css
138
138
  "<style type='text/css'>#{OmniAuth.config.form_css}</style>"
@@ -141,7 +141,7 @@ module OmniAuth
141
141
  def deep_merge(hash, other_hash)
142
142
  target = hash.dup
143
143
 
144
- other_hash.keys.each do |key|
144
+ other_hash.each_key do |key|
145
145
  if other_hash[key].is_a?(::Hash) && hash[key].is_a?(::Hash)
146
146
  target[key] = deep_merge(target[key], other_hash[key])
147
147
  next
@@ -1,11 +1,11 @@
1
- require 'hashie/mash'
1
+ require 'omniauth/key_store'
2
2
 
3
3
  module OmniAuth
4
4
  # The AuthHash is a normalized schema returned by all OmniAuth
5
5
  # strategies. It maps as much user information as the provider
6
6
  # is able to provide into the InfoHash (stored as the `'info'`
7
7
  # key).
8
- class AuthHash < Hashie::Mash
8
+ class AuthHash < OmniAuth::KeyStore
9
9
  def self.subkey_class
10
10
  Hashie::Mash
11
11
  end
@@ -20,13 +20,11 @@ module OmniAuth
20
20
  end
21
21
 
22
22
  def regular_writer(key, value)
23
- if key.to_s == 'info' && !value.is_a?(InfoHash)
24
- value = InfoHash.new(value)
25
- end
23
+ value = InfoHash.new(value) if key.to_s == 'info' && value.is_a?(::Hash) && !value.is_a?(InfoHash)
26
24
  super
27
25
  end
28
26
 
29
- class InfoHash < Hashie::Mash
27
+ class InfoHash < OmniAuth::KeyStore
30
28
  def self.subkey_class
31
29
  Hashie::Mash
32
30
  end
@@ -36,13 +34,14 @@ module OmniAuth
36
34
  return "#{first_name} #{last_name}".strip if first_name? || last_name?
37
35
  return nickname if nickname?
38
36
  return email if email?
37
+
39
38
  nil
40
39
  end
41
40
 
42
41
  def name?
43
42
  !!name
44
43
  end
45
- alias_method :valid?, :name?
44
+ alias valid? name?
46
45
 
47
46
  def to_hash
48
47
  hash = super
@@ -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,7 +21,8 @@ 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
 
@@ -49,7 +31,7 @@ module OmniAuth
49
31
  middleware = klass
50
32
  else
51
33
  begin
52
- middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
34
+ middleware = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s)
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
@@ -22,7 +22,7 @@ module OmniAuth
22
22
  end
23
23
 
24
24
  def raise_out!
25
- fail(env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type']))
25
+ raise(env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type']))
26
26
  end
27
27
 
28
28
  def redirect_to_failure
@@ -33,11 +33,13 @@ module OmniAuth
33
33
 
34
34
  def strategy_name_query_param
35
35
  return '' unless env['omniauth.error.strategy']
36
+
36
37
  "&strategy=#{env['omniauth.error.strategy'].name}"
37
38
  end
38
39
 
39
40
  def origin_query_param
40
41
  return '' unless env['omniauth.origin']
42
+
41
43
  "&origin=#{Rack::Utils.escape(env['omniauth.origin'])}"
42
44
  end
43
45
  end
@@ -56,7 +56,7 @@ input {
56
56
  }
57
57
 
58
58
  input#identifier, input#openid_url {
59
- background: url(http://openid.net/login-bg.gif) no-repeat;
59
+ background: url(https://openid.net/images/login-bg.gif) no-repeat;
60
60
  background-position: 0 50%;
61
61
  padding-left: 18px;
62
62
  }
@@ -82,6 +82,7 @@ module OmniAuth
82
82
 
83
83
  def footer
84
84
  return self if @footer
85
+
85
86
  @html << "\n<button type='submit'>Connect</button>" unless @with_custom_button
86
87
  @html << <<-HTML
87
88
  </form>
@@ -0,0 +1,22 @@
1
+ require 'hashie/mash'
2
+
3
+ module OmniAuth
4
+ # Generic helper hash that allows method access on deeply nested keys.
5
+ class KeyStore < ::Hashie::Mash
6
+ # Disables warnings on Hashie 3.5.0+ for overwritten keys
7
+ def self.override_logging
8
+ require 'hashie/version'
9
+ return unless Gem::Version.new(Hashie::VERSION) >= Gem::Version.new('3.5.0')
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
+ end
18
+
19
+ # Disable on loading of the class
20
+ override_logging
21
+ end
22
+ end
@@ -31,7 +31,7 @@ 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
@@ -1,4 +1,4 @@
1
- require 'hashie/mash'
1
+ require 'omniauth/key_store'
2
2
 
3
3
  module OmniAuth
4
4
  class NoSessionError < StandardError; 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,15 +136,16 @@ 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
 
142
147
  # Make sure that all of the args have been dealt with, otherwise error out.
143
- fail(ArgumentError.new("Received wrong number of arguments. #{args.inspect}")) unless args.empty?
148
+ raise(ArgumentError.new("Received wrong number of arguments. #{args.inspect}")) unless args.empty?
144
149
 
145
150
  yield options if block_given?
146
151
  end
@@ -172,7 +177,7 @@ module OmniAuth
172
177
  def call!(env) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
173
178
  unless env['rack.session']
174
179
  error = OmniAuth::NoSessionError.new('You must provide a session to use OmniAuth.')
175
- fail(error)
180
+ raise(error)
176
181
  end
177
182
 
178
183
  @env = env
@@ -183,6 +188,7 @@ module OmniAuth
183
188
  return request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
184
189
  return callback_call if on_callback_path?
185
190
  return other_phase if respond_to?(:other_phase)
191
+
186
192
  @app.call(env)
187
193
  end
188
194
 
@@ -197,21 +203,26 @@ module OmniAuth
197
203
  def request_call # rubocop:disable CyclomaticComplexity, MethodLength, PerceivedComplexity
198
204
  setup_phase
199
205
  log :info, 'Request phase initiated.'
206
+
200
207
  # store query params from the request url, extracted in the callback_phase
201
- session['omniauth.params'] = request.params
208
+ session['omniauth.params'] = request.GET
202
209
  OmniAuth.config.before_request_phase.call(env) if OmniAuth.config.before_request_phase
210
+
203
211
  if options.form.respond_to?(:call)
204
212
  log :info, 'Rendering form from supplied Rack endpoint.'
205
213
  options.form.call(env)
206
214
  elsif options.form
207
215
  log :info, 'Rendering form from underlying application.'
208
216
  call_app!
217
+ elsif !options.origin_param
218
+ request_phase
209
219
  else
210
- if request.params['origin']
211
- env['rack.session']['omniauth.origin'] = request.params['origin']
220
+ if request.params[options.origin_param]
221
+ env['rack.session']['omniauth.origin'] = request.params[options.origin_param]
212
222
  elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
213
223
  env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
214
224
  end
225
+
215
226
  request_phase
216
227
  end
217
228
  end
@@ -234,8 +245,8 @@ module OmniAuth
234
245
  end
235
246
 
236
247
  def on_request_path?
237
- if options.request_path.respond_to?(:call)
238
- options.request_path.call(env)
248
+ if options[:request_path].respond_to?(:call)
249
+ options[:request_path].call(env)
239
250
  else
240
251
  on_path?(request_path)
241
252
  end
@@ -246,7 +257,7 @@ module OmniAuth
246
257
  end
247
258
 
248
259
  def on_path?(path)
249
- current_path.casecmp(path) == 0
260
+ current_path.casecmp(path).zero?
250
261
  end
251
262
 
252
263
  def options_request?
@@ -257,20 +268,23 @@ module OmniAuth
257
268
  # in the event that OmniAuth has been configured to be
258
269
  # in test mode.
259
270
  def mock_call!(*)
260
- return mock_request_call if on_request_path?
271
+ return mock_request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
261
272
  return mock_callback_call if on_callback_path?
273
+
262
274
  call_app!
263
275
  end
264
276
 
265
277
  def mock_request_call
266
278
  setup_phase
267
279
 
268
- session['omniauth.params'] = request.params
280
+ session['omniauth.params'] = request.GET
269
281
  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']
282
+ if options.origin_param
283
+ if request.params[options.origin_param]
284
+ session['omniauth.origin'] = request.params[options.origin_param]
285
+ elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
286
+ session['omniauth.origin'] = env['HTTP_REFERER']
287
+ end
274
288
  end
275
289
 
276
290
  redirect(callback_url)
@@ -280,12 +294,13 @@ module OmniAuth
280
294
  setup_phase
281
295
  @env['omniauth.origin'] = session.delete('omniauth.origin')
282
296
  @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
297
+ @env['omniauth.params'] = session.delete('omniauth.params') || {}
298
+
283
299
  mocked_auth = OmniAuth.mock_auth_for(name.to_s)
284
300
  if mocked_auth.is_a?(Symbol)
285
301
  fail!(mocked_auth)
286
302
  else
287
303
  @env['omniauth.auth'] = mocked_auth
288
- @env['omniauth.params'] = session.delete('omniauth.params') || {}
289
304
  OmniAuth.config.before_callback_phase.call(@env) if OmniAuth.config.before_callback_phase
290
305
  call_app!
291
306
  end
@@ -299,7 +314,7 @@ module OmniAuth
299
314
  if options[:setup].respond_to?(:call)
300
315
  log :info, 'Setup endpoint detected, running now.'
301
316
  options[:setup].call(env)
302
- elsif options.setup?
317
+ elsif options[:setup]
303
318
  log :info, 'Calling through to underlying application for setup.'
304
319
  setup_env = env.merge('PATH_INFO' => setup_path, 'REQUEST_METHOD' => 'GET')
305
320
  call_app!(setup_env)
@@ -310,7 +325,7 @@ module OmniAuth
310
325
  # perform any information gathering you need to be able to authenticate
311
326
  # the user in this phase.
312
327
  def request_phase
313
- fail(NotImplementedError)
328
+ raise(NotImplementedError)
314
329
  end
315
330
 
316
331
  def uid
@@ -347,14 +362,10 @@ module OmniAuth
347
362
  #
348
363
  # use MyStrategy, :skip_info => lambda{|uid| User.find_by_uid(uid)}
349
364
  def skip_info?
350
- if options.skip_info?
351
- if options.skip_info.respond_to?(:call)
352
- return options.skip_info.call(uid)
353
- else
354
- return true
355
- end
356
- end
357
- false
365
+ return false unless options.skip_info?
366
+ return true unless options.skip_info.respond_to?(:call)
367
+
368
+ options.skip_info.call(uid)
358
369
  end
359
370
 
360
371
  def callback_phase
@@ -370,6 +381,7 @@ module OmniAuth
370
381
  if options[kind].respond_to?(:call)
371
382
  result = options[kind].call(env)
372
383
  return nil unless result.is_a?(String)
384
+
373
385
  result
374
386
  else
375
387
  options[kind]
@@ -394,7 +406,7 @@ module OmniAuth
394
406
  options[:setup_path] || "#{path_prefix}/#{name}/setup"
395
407
  end
396
408
 
397
- CURRENT_PATH_REGEX = %r{/$}
409
+ CURRENT_PATH_REGEX = %r{/$}.freeze
398
410
  EMPTY_STRING = ''.freeze
399
411
  def current_path
400
412
  @current_path ||= request.path_info.downcase.sub(CURRENT_PATH_REGEX, EMPTY_STRING)
@@ -445,7 +457,7 @@ module OmniAuth
445
457
  end
446
458
 
447
459
  def name
448
- options.name
460
+ options[:name]
449
461
  end
450
462
 
451
463
  def redirect(uri)
@@ -485,7 +497,7 @@ module OmniAuth
485
497
  end
486
498
  end
487
499
 
488
- class Options < Hashie::Mash; end
500
+ class Options < OmniAuth::KeyStore; end
489
501
 
490
502
  protected
491
503
 
@@ -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' }
@@ -37,7 +37,7 @@ module OmniAuth
37
37
 
38
38
  def strategy
39
39
  error = NotImplementedError.new('Including specs must define #strategy')
40
- fail(error)
40
+ raise(error)
41
41
  end
42
42
  end
43
43
  end
@@ -1,3 +1,3 @@
1
1
  module OmniAuth
2
- VERSION = '1.3.1'
2
+ VERSION = '1.9.1'.freeze
3
3
  end
@@ -1,21 +1,24 @@
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'
8
+ spec.add_dependency 'hashie', ['>= 3.4.6']
9
+ spec.add_dependency 'rack', ['>= 1.6.2', '< 3']
10
+ spec.add_development_dependency 'bundler', '~> 1.14'
11
+ spec.add_development_dependency 'rake', '~> 12.0'
10
12
  spec.authors = ['Michael Bleigh', 'Erik Michaels-Ober', 'Tom Milewski']
11
13
  spec.description = 'A generalized Rack framework for multiple-provider authentication.'
12
14
  spec.email = ['michael@intridea.com', 'sferik@gmail.com', 'tmilewski@gmail.com']
13
15
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.start_with?('spec/') }
14
- spec.homepage = 'http://github.com/intridea/omniauth'
15
- spec.licenses = %w(MIT)
16
+ spec.homepage = 'https://github.com/omniauth/omniauth'
17
+ spec.licenses = %w[MIT]
16
18
  spec.name = 'omniauth'
17
- spec.require_paths = %w(lib)
19
+ spec.require_paths = %w[lib]
18
20
  spec.required_rubygems_version = '>= 1.3.5'
21
+ spec.required_ruby_version = '>= 2.2'
19
22
  spec.summary = spec.description
20
23
  spec.version = OmniAuth::VERSION
21
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-20 00:00:00.000000000 Z
13
+ date: 2020-03-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hashie
@@ -18,27 +18,21 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '1.2'
22
- - - "<"
23
- - !ruby/object:Gem::Version
24
- version: '4'
21
+ version: 3.4.6
25
22
  type: :runtime
26
23
  prerelease: false
27
24
  version_requirements: !ruby/object:Gem::Requirement
28
25
  requirements:
29
26
  - - ">="
30
27
  - !ruby/object:Gem::Version
31
- version: '1.2'
32
- - - "<"
33
- - !ruby/object:Gem::Version
34
- version: '4'
28
+ version: 3.4.6
35
29
  - !ruby/object:Gem::Dependency
36
30
  name: rack
37
31
  requirement: !ruby/object:Gem::Requirement
38
32
  requirements:
39
33
  - - ">="
40
34
  - !ruby/object:Gem::Version
41
- version: '1.0'
35
+ version: 1.6.2
42
36
  - - "<"
43
37
  - !ruby/object:Gem::Version
44
38
  version: '3'
@@ -48,7 +42,7 @@ dependencies:
48
42
  requirements:
49
43
  - - ">="
50
44
  - !ruby/object:Gem::Version
51
- version: '1.0'
45
+ version: 1.6.2
52
46
  - - "<"
53
47
  - !ruby/object:Gem::Version
54
48
  version: '3'
@@ -58,14 +52,28 @@ dependencies:
58
52
  requirements:
59
53
  - - "~>"
60
54
  - !ruby/object:Gem::Version
61
- version: '1.0'
55
+ version: '1.14'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.14'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rake
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '12.0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
65
73
  requirements:
66
74
  - - "~>"
67
75
  - !ruby/object:Gem::Version
68
- version: '1.0'
76
+ version: '12.0'
69
77
  description: A generalized Rack framework for multiple-provider authentication.
70
78
  email:
71
79
  - michael@intridea.com
@@ -75,14 +83,13 @@ executables: []
75
83
  extensions: []
76
84
  extra_rdoc_files: []
77
85
  files:
86
+ - ".github/ISSUE_TEMPLATE.md"
78
87
  - ".gitignore"
79
88
  - ".rspec"
80
89
  - ".rubocop.yml"
81
90
  - ".travis.yml"
82
91
  - ".yardopts"
83
92
  - Gemfile
84
- - Gemfile.rack-1.3.x
85
- - Gemfile.rack-master
86
93
  - LICENSE.md
87
94
  - README.md
88
95
  - Rakefile
@@ -92,6 +99,7 @@ files:
92
99
  - lib/omniauth/failure_endpoint.rb
93
100
  - lib/omniauth/form.css
94
101
  - lib/omniauth/form.rb
102
+ - lib/omniauth/key_store.rb
95
103
  - lib/omniauth/strategies/developer.rb
96
104
  - lib/omniauth/strategy.rb
97
105
  - lib/omniauth/test.rb
@@ -100,7 +108,7 @@ files:
100
108
  - lib/omniauth/test/strategy_test_case.rb
101
109
  - lib/omniauth/version.rb
102
110
  - omniauth.gemspec
103
- homepage: http://github.com/intridea/omniauth
111
+ homepage: https://github.com/omniauth/omniauth
104
112
  licenses:
105
113
  - MIT
106
114
  metadata: {}
@@ -112,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
120
  requirements:
113
121
  - - ">="
114
122
  - !ruby/object:Gem::Version
115
- version: '0'
123
+ version: '2.2'
116
124
  required_rubygems_version: !ruby/object:Gem::Requirement
117
125
  requirements:
118
126
  - - ">="
@@ -120,9 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
128
  version: 1.3.5
121
129
  requirements: []
122
130
  rubyforge_project:
123
- rubygems_version: 2.5.1
131
+ rubygems_version: 2.6.14.4
124
132
  signing_key:
125
133
  specification_version: 4
126
134
  summary: A generalized Rack framework for multiple-provider authentication.
127
135
  test_files: []
128
- has_rdoc:
@@ -1,20 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'jruby-openssl', :platforms => :jruby
4
- gem 'rack', '~> 1.3.0'
5
- gem 'rake'
6
- gem 'yard'
7
-
8
- group :test do
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]
13
- gem 'rack-test'
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'
18
- end
19
-
20
- gemspec
@@ -1,16 +0,0 @@
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