devise 1.5.0 → 1.5.1

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

Potentially problematic release.


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

@@ -10,3 +10,4 @@ notifications:
10
10
  - jose.valim@plataformatec.com.br
11
11
  - carlos@plataformatec.com.br
12
12
  - rodrigo.flores@plataformatec.com.br
13
+ - rafael.franca@plataformatec.com.br
@@ -1,3 +1,8 @@
1
+ == 1.5.1
2
+
3
+ * bug fix
4
+ * Devise should not attempt to load OmniAuth strategies. Strategies should be loaded before hand by the developer or explicitly given to Devise.
5
+
1
6
  == 1.5.0
2
7
 
3
8
  * enhancements
data/Gemfile CHANGED
@@ -3,30 +3,27 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem "rails", "~> 3.1.0"
6
- gem 'omniauth', '~> 1.0.0'
7
- gem 'omniauth-oauth2', '~> 1.0.0'
8
-
6
+ gem "omniauth", "~> 1.0.0"
7
+ gem "omniauth-oauth2", "~> 1.0.0"
9
8
  gem "rdoc"
10
9
 
11
10
  group :test do
12
- gem 'omniauth-facebook'
13
- gem 'omniauth-openid', '~> 1.0.1'
11
+ gem "omniauth-facebook"
12
+ gem "omniauth-openid", "~> 1.0.1"
14
13
  gem "webrat", "0.7.2", :require => false
15
14
  gem "mocha", :require => false
16
- end
17
-
18
- platforms :jruby do
19
- gem 'activerecord-jdbc-adapter'
20
- gem 'activerecord-jdbcsqlite3-adapter'
21
- gem 'jruby-openssl'
22
- end
23
15
 
24
- platforms :mri_18 do
25
- group :test do
16
+ platforms :mri_18 do
26
17
  gem "ruby-debug", ">= 0.10.3"
27
18
  end
28
19
  end
29
20
 
21
+ platforms :jruby do
22
+ gem "activerecord-jdbc-adapter"
23
+ gem "activerecord-jdbcsqlite3-adapter"
24
+ gem "jruby-openssl"
25
+ end
26
+
30
27
  platforms :ruby do
31
28
  gem "sqlite3-ruby"
32
29
 
@@ -21,13 +21,14 @@ class Devise::SessionsController < ApplicationController
21
21
  # DELETE /resource/sign_out
22
22
  def destroy
23
23
  signed_in = signed_in?(resource_name)
24
+ redirect_path = after_sign_out_path_for(resource_name)
24
25
  Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
25
26
  set_flash_message :notice, :signed_out if signed_in
26
27
 
27
- # We actually need to hardcode this, as Rails default responder doesn't
28
+ # We actually need to hardcode this as Rails default responder doesn't
28
29
  # support returning empty response on GET request
29
30
  respond_to do |format|
30
- format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) }
31
+ format.any(*navigational_formats) { redirect_to redirect_path }
31
32
  format.all do
32
33
  method = "to_#{request_format}"
33
34
  text = {}.respond_to?(method) ? {}.send(method) : ""
@@ -207,7 +207,7 @@ module Devise
207
207
  # scope. Notice that differently from +after_sign_in_path_for+ this method
208
208
  # receives a symbol with the scope, and not the resource.
209
209
  #
210
- # By default is the root_path.
210
+ # By default it is the root_path.
211
211
  def after_sign_out_path_for(resource_or_scope)
212
212
  root_path
213
213
  end
@@ -236,8 +236,9 @@ module Devise
236
236
  # after_sign_out_path_for.
237
237
  def sign_out_and_redirect(resource_or_scope)
238
238
  scope = Devise::Mapping.find_scope!(resource_or_scope)
239
+ redirect_path = after_sign_out_path_for(scope)
239
240
  Devise.sign_out_all_scopes ? sign_out : sign_out(scope)
240
- redirect_to after_sign_out_path_for(scope)
241
+ redirect_to redirect_path
241
242
  end
242
243
 
243
244
  # Overwrite Rails' handle unverified request to sign out all scopes,
@@ -1,6 +1,6 @@
1
1
  begin
2
2
  require "omniauth"
3
- require 'omniauth/version'
3
+ require "omniauth/version"
4
4
  rescue LoadError => e
5
5
  warn "Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile."
6
6
  raise
@@ -1,23 +1,28 @@
1
1
  module Devise
2
2
  module OmniAuth
3
+ class StrategyNotFound < NameError
4
+ def initialize(strategy)
5
+ @strategy = strategy
6
+ super("Could not find a strategy with name `#{strategy}'. " \
7
+ "Please ensure it is required or explicitly set it using the :klass option.")
8
+ end
9
+ end
10
+
3
11
  class Config
4
12
  attr_accessor :strategy
5
- attr_reader :args, :options, :provider
13
+ attr_reader :args, :options, :provider, :strategy_name
6
14
 
7
15
  def initialize(provider, args)
8
- @provider = provider
9
- @args = args
10
- @strategy = nil
11
- @options = @args.last.is_a?(Hash) ? @args.last : {}
12
- end
13
-
14
- # open_id strategy can have configurable name
15
- def strategy_name
16
- options[:name] || @provider
16
+ @provider = provider
17
+ @args = args
18
+ @options = @args.last.is_a?(Hash) ? @args.last : {}
19
+ @strategy = nil
20
+ @strategy_name = options[:name] || @provider
21
+ @strategy_class = options.delete(:strategy_class)
17
22
  end
18
23
 
19
24
  def strategy_class
20
- find_strategy || require_strategy
25
+ @strategy_class ||= find_strategy || autoload_strategy
21
26
  end
22
27
 
23
28
  def find_strategy
@@ -27,20 +32,14 @@ module Devise
27
32
  end
28
33
  end
29
34
 
30
- def require_strategy
31
- if [:facebook, :github, :twitter].include?(provider.to_sym)
32
- require "omniauth/strategies/#{provider}"
33
- elsif options[:require]
34
- require options[:require]
35
+ def autoload_strategy
36
+ name = ::OmniAuth::Utils.camelize(provider.to_s)
37
+ if ::OmniAuth::Strategies.const_defined?(name)
38
+ ::OmniAuth::Strategies.const_get(name)
35
39
  else
36
- require "omniauth-#{provider}"
40
+ raise StrategyNotFound, name
37
41
  end
38
- find_strategy || autoload_strategy
39
- end
40
-
41
- def autoload_strategy
42
- ::OmniAuth::Strategies.const_get(::OmniAuth::Utils.camelize(provider.to_s))
43
42
  end
44
43
  end
45
44
  end
46
- end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module Devise
2
- VERSION = "1.5.0".freeze
2
+ VERSION = "1.5.1".freeze
3
3
  end
@@ -1,8 +1,8 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class OmniAuthConfigTest < ActiveSupport::TestCase
4
- setup do
5
- $: << File.dirname(__FILE__)
4
+ class MyStrategy
5
+ include OmniAuth::Strategy
6
6
  end
7
7
 
8
8
  test 'strategy_name returns provider if no options given' do
@@ -42,15 +42,16 @@ class OmniAuthConfigTest < ActiveSupport::TestCase
42
42
  assert_equal UnNamedTestStrategy, config.strategy_class
43
43
  end
44
44
 
45
- test 'attempts to load an as-yet not loaded plugin' do
46
- config = Devise::OmniAuth::Config.new :my_strategy, [{}]
47
- config_class = config.strategy_class
48
- assert_equal MyStrategy, config_class
45
+ test 'raises an error if strategy cannot be found' do
46
+ config = Devise::OmniAuth::Config.new :my_other_strategy, [{}]
47
+ assert_raise Devise::OmniAuth::StrategyNotFound do
48
+ config.strategy_class
49
+ end
49
50
  end
50
51
 
51
52
  test 'allows the user to define a custom require path' do
52
- config = Devise::OmniAuth::Config.new :my_other_strategy, [{:require => 'my_other_strategy'}]
53
+ config = Devise::OmniAuth::Config.new :my_strategy, [{:strategy_class => MyStrategy}]
53
54
  config_class = config.strategy_class
54
- assert_equal MyOtherStrategy, config_class
55
+ assert_equal MyStrategy, config_class
55
56
  end
56
57
  end
@@ -1,3 +1,6 @@
1
+ require "omniauth-facebook"
2
+ require "omniauth-openid"
3
+
1
4
  # Use this hook to configure devise mailer, warden hooks and so forth. The first
2
5
  # four configuration values can also be set straight in your models.
3
6
  Devise.setup do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-13 00:00:00.000000000 Z
13
+ date: 2011-11-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: warden
17
- requirement: &70275073382440 !ruby/object:Gem::Requirement
17
+ requirement: &70325690146000 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '1.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70275073382440
25
+ version_requirements: *70325690146000
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: orm_adapter
28
- requirement: &70275073381940 !ruby/object:Gem::Requirement
28
+ requirement: &70325690145300 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70275073381940
36
+ version_requirements: *70325690145300
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bcrypt-ruby
39
- requirement: &70275073381340 !ruby/object:Gem::Requirement
39
+ requirement: &70325690144180 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '3.0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70275073381340
47
+ version_requirements: *70325690144180
48
48
  description: Flexible authentication solution for Rails with Warden
49
49
  email: contact@plataformatec.com.br
50
50
  executables: []
@@ -198,8 +198,6 @@ files:
198
198
  - test/models/validatable_test.rb
199
199
  - test/models_test.rb
200
200
  - test/omniauth/config_test.rb
201
- - test/omniauth/my_other_strategy.rb
202
- - test/omniauth/omniauth-my_strategy.rb
203
201
  - test/omniauth/url_helpers_test.rb
204
202
  - test/orm/active_record.rb
205
203
  - test/orm/mongoid.rb
@@ -330,8 +328,6 @@ test_files:
330
328
  - test/models/validatable_test.rb
331
329
  - test/models_test.rb
332
330
  - test/omniauth/config_test.rb
333
- - test/omniauth/my_other_strategy.rb
334
- - test/omniauth/omniauth-my_strategy.rb
335
331
  - test/omniauth/url_helpers_test.rb
336
332
  - test/orm/active_record.rb
337
333
  - test/orm/mongoid.rb
@@ -1,5 +0,0 @@
1
- require 'omniauth'
2
-
3
- class MyOtherStrategy
4
- include OmniAuth::Strategy
5
- end
@@ -1,5 +0,0 @@
1
- require 'omniauth'
2
-
3
- class MyStrategy
4
- include OmniAuth::Strategy
5
- end