omniauth 1.6.1 → 1.7.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: 2f9747fdf4d26b313c332d677cd38652b7d4c6de
4
- data.tar.gz: 62a3ea9d5e204ab8f00f42d7333d6aa64eed634d
3
+ metadata.gz: 30d55e6bde8f8c069dd705b2f96ba2b040f6185b
4
+ data.tar.gz: 4bcccb646d0cf51c829fe79c9fcb88c97443ff68
5
5
  SHA512:
6
- metadata.gz: d513f115eaa738232d437c33d6fb28ff8b13d4a75b8e0e0a03ad33425725eb6aced21788a589e1151442b24ecc4bbfad36d7e742a3af65518109b1f752a745d5
7
- data.tar.gz: b1aaa8309622e7980eb0b2568c77c9e23ed0233c001c85254ea39279b8b8d7fd973743aa8055ca6822b45db68174b5ecbe24aff17b967e7226ef5ca1b61b0977
6
+ metadata.gz: 4404ea3c465252b74af8f1b1abb0811eccff1195a7f8dd0182e625e33b3fb4ce31e942ab2cc9c16ada428b86f64580207823d9cc5f6ff8c9912c6ed78901483f
7
+ data.tar.gz: f46fa53a89a02101f602324d5d5a5c1b76837a027a19a0e8ab83bee8a5791cc3e7c43fc19d8fa5253e0ca713b2b4ecb3fcb2583b676b9ed3c5587919c9702309
data/Gemfile CHANGED
@@ -14,14 +14,14 @@ end
14
14
  group :test do
15
15
  gem 'coveralls', :require => false
16
16
  gem 'hashie', '>= 3.4.6', '< 3.6.0', :platforms => [:jruby_18]
17
- gem 'json', '~> 2.0.3', :platforms => [:jruby_18, :jruby_19, :ruby_19]
17
+ gem 'json', '~> 2.0.3', :platforms => %i[jruby_18 jruby_19 ruby_19]
18
18
  gem 'mime-types', '~> 3.1', :platforms => [:jruby_18]
19
- gem 'rack', '>= 1.6.2', :platforms => [:jruby_18, :jruby_19, :ruby_19, :ruby_20, :ruby_21]
19
+ gem 'rack', '>= 1.6.2', :platforms => %i[jruby_18 jruby_19 ruby_19 ruby_20 ruby_21]
20
20
  gem 'rack-test'
21
21
  gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18]
22
22
  gem 'rspec', '~> 3.5.0'
23
- gem 'rubocop', '>= 0.47', :platforms => [:ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24]
24
- gem 'tins', '~> 1.13.0', :platforms => [:jruby_18, :jruby_19, :ruby_19]
23
+ gem 'rubocop', '>= 0.47', :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]
25
25
  end
26
26
 
27
27
  gemspec
data/README.md CHANGED
@@ -122,6 +122,62 @@ environment information on the callback request. It is entirely up to
122
122
  you how you want to implement the particulars of your application's
123
123
  authentication flow.
124
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
+
125
181
  ## Logging
126
182
  OmniAuth supports a configurable logger. By default, OmniAuth will log
127
183
  to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ rescue LoadError
14
14
  end
15
15
  end
16
16
 
17
- task :default => [:spec, :rubocop]
17
+ task :default => %i[spec rubocop]
18
18
 
19
19
  namespace :perf do
20
20
  task :setup do
@@ -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
@@ -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
@@ -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
@@ -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
 
@@ -87,7 +88,7 @@ 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
+ %w[uid info extra credentials].each do |fetcher|
91
92
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
92
93
  attr_reader :#{fetcher}_proc
93
94
  private :#{fetcher}_proc
@@ -200,21 +201,26 @@ module OmniAuth
200
201
  def request_call # rubocop:disable CyclomaticComplexity, MethodLength, PerceivedComplexity
201
202
  setup_phase
202
203
  log :info, 'Request phase initiated.'
204
+
203
205
  # store query params from the request url, extracted in the callback_phase
204
206
  session['omniauth.params'] = request.GET
205
207
  OmniAuth.config.before_request_phase.call(env) if OmniAuth.config.before_request_phase
208
+
206
209
  if options.form.respond_to?(:call)
207
210
  log :info, 'Rendering form from supplied Rack endpoint.'
208
211
  options.form.call(env)
209
212
  elsif options.form
210
213
  log :info, 'Rendering form from underlying application.'
211
214
  call_app!
215
+ elsif !options.origin_param
216
+ request_phase
212
217
  else
213
- if request.params['origin']
214
- env['rack.session']['omniauth.origin'] = request.params['origin']
218
+ if request.params[options.origin_param]
219
+ env['rack.session']['omniauth.origin'] = request.params[options.origin_param]
215
220
  elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
216
221
  env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
217
222
  end
223
+
218
224
  request_phase
219
225
  end
220
226
  end
@@ -271,9 +277,9 @@ module OmniAuth
271
277
  session['omniauth.params'] = request.GET
272
278
  OmniAuth.config.before_request_phase.call(env) if OmniAuth.config.before_request_phase
273
279
  if request.params['origin']
274
- @env['rack.session']['omniauth.origin'] = request.params['origin']
280
+ session['omniauth.origin'] = request.params['origin']
275
281
  elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
276
- @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
282
+ session['omniauth.origin'] = env['HTTP_REFERER']
277
283
  end
278
284
 
279
285
  redirect(callback_url)
@@ -1,3 +1,3 @@
1
1
  module OmniAuth
2
- VERSION = '1.6.1'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
@@ -1,4 +1,5 @@
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'
@@ -13,9 +14,9 @@ Gem::Specification.new do |spec|
13
14
  spec.email = ['michael@intridea.com', 'sferik@gmail.com', 'tmilewski@gmail.com']
14
15
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.start_with?('spec/') }
15
16
  spec.homepage = 'https://github.com/omniauth/omniauth'
16
- spec.licenses = %w(MIT)
17
+ spec.licenses = %w[MIT]
17
18
  spec.name = 'omniauth'
18
- spec.require_paths = %w(lib)
19
+ spec.require_paths = %w[lib]
19
20
  spec.required_rubygems_version = '>= 1.3.5'
20
21
  spec.required_ruby_version = '>= 2.1.9'
21
22
  spec.summary = spec.description
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.6.1
4
+ version: 1.7.0
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: 2017-02-18 00:00:00.000000000 Z
13
+ date: 2017-09-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hashie
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  version: 1.3.5
135
135
  requirements: []
136
136
  rubyforge_project:
137
- rubygems_version: 2.6.10
137
+ rubygems_version: 2.6.11
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: A generalized Rack framework for multiple-provider authentication.