loyal_warden 0.0.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/History.rdoc +0 -7
- data/README.textile +1 -2
- data/lib/warden.rb +1 -1
- data/lib/warden/config.rb +1 -1
- data/lib/warden/errors.rb +1 -1
- data/lib/warden/hooks.rb +1 -1
- data/lib/warden/manager.rb +2 -1
- data/lib/warden/mixins/common.rb +3 -4
- data/lib/warden/proxy.rb +2 -2
- data/lib/warden/session_serializer.rb +2 -6
- data/lib/warden/strategies.rb +2 -3
- data/lib/warden/strategies/base.rb +1 -1
- data/lib/warden/test/helpers.rb +1 -1
- data/lib/warden/test/warden_helpers.rb +1 -1
- data/lib/warden/version.rb +2 -2
- data/loyal_warden.gemspec +3 -6
- data/spec/helpers/request_helper.rb +2 -2
- data/spec/helpers/strategies/failz.rb +1 -1
- data/spec/helpers/strategies/invalid.rb +2 -2
- data/spec/helpers/strategies/pass.rb +1 -1
- data/spec/helpers/strategies/pass_with_message.rb +1 -1
- data/spec/helpers/strategies/password.rb +1 -1
- data/spec/helpers/strategies/single.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/warden/authenticated_data_store_spec.rb +1 -1
- data/spec/warden/config_spec.rb +1 -1
- data/spec/warden/errors_spec.rb +1 -1
- data/spec/warden/hooks_spec.rb +1 -1
- data/spec/warden/manager_spec.rb +1 -1
- data/spec/warden/proxy_spec.rb +7 -24
- data/spec/warden/scoped_session_serializer.rb +1 -1
- data/spec/warden/session_serializer_spec.rb +1 -6
- data/spec/warden/strategies/base_spec.rb +1 -1
- data/spec/warden/strategies_spec.rb +2 -12
- data/spec/warden/test/helpers_spec.rb +1 -1
- data/spec/warden/test/test_mode_spec.rb +1 -1
- data/warden.gemspec +0 -1
- metadata +5 -7
- data/lib/loyal_warden.rb +0 -2
data/Gemfile
CHANGED
data/History.rdoc
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
== Version 1.2.3 / 2013-07-14
|
2
|
-
* Fix an issue with lazy loaded sessions
|
3
|
-
|
4
|
-
== Version 1.2.2 / 2013-07-12
|
5
|
-
* Support nil session stores on logout
|
6
|
-
* Fix strategies blowing up with undefined method base
|
7
|
-
|
8
1
|
== Version 1.2.1 / 2012-06-16
|
9
2
|
* Minor caching and speed improvements
|
10
3
|
* Add support to #lock in the proxy
|
data/README.textile
CHANGED
@@ -4,6 +4,5 @@ h2. Maintainers
|
|
4
4
|
|
5
5
|
* Daniel Neighman (hassox)
|
6
6
|
* José Valim (josevalim)
|
7
|
-
* Justin Smestad (jsmestad)
|
8
7
|
|
9
|
-
"A list of all contributors is available on Github.":https://github.com/hassox/warden/contributors
|
8
|
+
"A list of all contributors is available on Github.":https://github.com/hassox/warden/contributors
|
data/lib/warden.rb
CHANGED
data/lib/warden/config.rb
CHANGED
data/lib/warden/errors.rb
CHANGED
data/lib/warden/hooks.rb
CHANGED
data/lib/warden/manager.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
require 'warden/hooks'
|
3
3
|
require 'warden/config'
|
4
4
|
|
@@ -123,6 +123,7 @@ module Warden
|
|
123
123
|
def call_failure_app(env, options = {})
|
124
124
|
if config.failure_app
|
125
125
|
options.merge!(:attempted_path => ::Rack::Request.new(env).fullpath)
|
126
|
+
options.merge!(:attempted_url => ::Rack::Request.new(env).url)
|
126
127
|
env["PATH_INFO"] = "/#{options[:action]}"
|
127
128
|
env["warden.options"] = options
|
128
129
|
|
data/lib/warden/mixins/common.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
module Warden
|
3
3
|
module Mixins
|
4
4
|
module Common
|
@@ -24,7 +24,7 @@ module Warden
|
|
24
24
|
def warden_cookies
|
25
25
|
warn "warden_cookies was never functional and is going to be removed in next versions"
|
26
26
|
env['warden.cookies'] ||= {}
|
27
|
-
end #
|
27
|
+
end # response
|
28
28
|
|
29
29
|
# Convenience method to access the rack request params
|
30
30
|
# :api: public
|
@@ -37,8 +37,7 @@ module Warden
|
|
37
37
|
# @api overwritable
|
38
38
|
def reset_session!
|
39
39
|
raw_session.clear
|
40
|
-
end
|
41
|
-
|
40
|
+
end
|
42
41
|
end # Common
|
43
42
|
end # Mixins
|
44
43
|
end # Warden
|
data/lib/warden/proxy.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
module Warden
|
4
4
|
class UserNotSet < RuntimeError; end
|
@@ -261,7 +261,7 @@ module Warden
|
|
261
261
|
user = @users.delete(scope)
|
262
262
|
manager._run_callbacks(:before_logout, user, self, :scope => scope)
|
263
263
|
|
264
|
-
raw_session.delete("warden.user.#{scope}.session")
|
264
|
+
raw_session.delete("warden.user.#{scope}.session")
|
265
265
|
session_serializer.delete(scope, user)
|
266
266
|
end
|
267
267
|
|
@@ -1,7 +1,8 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
module Warden
|
3
3
|
class SessionSerializer
|
4
4
|
attr_reader :env
|
5
|
+
include ::Warden::Mixins::Common
|
5
6
|
|
6
7
|
def initialize(env)
|
7
8
|
@env = env
|
@@ -43,10 +44,5 @@ module Warden
|
|
43
44
|
def delete(scope, user=nil)
|
44
45
|
session.delete(key_for(scope))
|
45
46
|
end
|
46
|
-
|
47
|
-
# We can't cache this result because the session can be lazy loaded
|
48
|
-
def session
|
49
|
-
env["rack.session"] || {}
|
50
|
-
end
|
51
47
|
end # SessionSerializer
|
52
48
|
end # Warden
|
data/lib/warden/strategies.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
module Warden
|
3
3
|
module Strategies
|
4
4
|
class << self
|
@@ -11,8 +11,7 @@ module Warden
|
|
11
11
|
raise NoMethodError, "authenticate! is not declared in the #{label.inspect} strategy"
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
unless strategy.ancestors.include?(base)
|
14
|
+
unless strategy.ancestors.include?(Warden::Strategies::Base)
|
16
15
|
raise "#{label.inspect} is not a #{base}"
|
17
16
|
end
|
18
17
|
|
data/lib/warden/test/helpers.rb
CHANGED
data/lib/warden/version.rb
CHANGED
data/loyal_warden.gemspec
CHANGED
@@ -4,23 +4,20 @@ require './lib/warden/version'
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = %q{loyal_warden}
|
7
|
-
|
8
|
-
s.version = '0.0.5'
|
7
|
+
s.version = Warden::VERSION.dup
|
9
8
|
s.authors = ["Daniel Neighman"]
|
10
|
-
s.email = %q{
|
11
|
-
s.license = "MIT"
|
9
|
+
s.email = %q{andywang7259@gmail.com}
|
12
10
|
s.extra_rdoc_files = [
|
13
11
|
"LICENSE",
|
14
12
|
"README.textile"
|
15
13
|
]
|
16
14
|
s.files = Dir["**/*"] - Dir["*.gem"] - ["Gemfile.lock"]
|
17
|
-
s.homepage = %q{http://github.com/
|
15
|
+
s.homepage = %q{http://github.com/blogsoso/warden}
|
18
16
|
s.rdoc_options = ["--charset=UTF-8"]
|
19
17
|
s.require_paths = ["lib"]
|
20
18
|
s.rubyforge_project = %q{warden}
|
21
19
|
s.rubygems_version = %q{1.3.7}
|
22
20
|
s.summary = %q{Rack middleware that provides authentication for rack applications}
|
23
|
-
|
24
21
|
s.add_dependency "rack", ">= 1.0"
|
25
22
|
end
|
26
23
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
module Warden::Spec
|
3
3
|
module Helpers
|
4
4
|
FAILURE_APP = lambda{|e|[401, {"Content-Type" => "text/plain"}, ["You Fail!"]] }
|
@@ -18,7 +18,7 @@ module Warden::Spec
|
|
18
18
|
blk = opts[:configurator] || proc{}
|
19
19
|
|
20
20
|
Rack::Builder.new do
|
21
|
-
use opts[:session] || Warden::Spec::Helpers::Session
|
21
|
+
use opts[:session] || Warden::Spec::Helpers::Session
|
22
22
|
use Warden::Manager, opts, &blk
|
23
23
|
run app
|
24
24
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/warden/config_spec.rb
CHANGED
data/spec/warden/errors_spec.rb
CHANGED
data/spec/warden/hooks_spec.rb
CHANGED
data/spec/warden/manager_spec.rb
CHANGED
data/spec/warden/proxy_spec.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Warden::Proxy do
|
5
|
+
|
5
6
|
before(:all) do
|
6
7
|
load_strategies
|
7
8
|
end
|
@@ -339,6 +340,7 @@ describe Warden::Proxy do
|
|
339
340
|
end
|
340
341
|
setup_rack(app).call(@env)
|
341
342
|
end
|
343
|
+
|
342
344
|
end
|
343
345
|
|
344
346
|
describe "set user" do
|
@@ -364,17 +366,6 @@ describe Warden::Proxy do
|
|
364
366
|
setup_rack(app).call(@env)
|
365
367
|
end
|
366
368
|
|
367
|
-
it "should not throw error when no session is configured and store is false" do
|
368
|
-
app = lambda do |env|
|
369
|
-
env['rack.session'] = nil
|
370
|
-
env['warden'].authenticate(:pass, :store => false)
|
371
|
-
env['warden'].should be_authenticated
|
372
|
-
env['warden'].user.should == "Valid User"
|
373
|
-
valid_response
|
374
|
-
end
|
375
|
-
setup_rack(app).call(@env)
|
376
|
-
end
|
377
|
-
|
378
369
|
it "should not run the callbacks when :run_callbacks is false" do
|
379
370
|
app = lambda do |env|
|
380
371
|
env['warden'].manager.should_not_receive(:_run_callbacks)
|
@@ -521,6 +512,7 @@ describe Warden::Proxy do
|
|
521
512
|
end
|
522
513
|
|
523
514
|
describe "logout" do
|
515
|
+
|
524
516
|
before(:each) do
|
525
517
|
@env['rack.session'] = {"warden.user.default.key" => "default key", "warden.user.foo.key" => "foo key", :foo => "bar"}
|
526
518
|
@app = lambda do |e|
|
@@ -557,13 +549,6 @@ describe Warden::Proxy do
|
|
557
549
|
@env['rack.session'].should be_empty
|
558
550
|
end
|
559
551
|
|
560
|
-
it "should not raise exception if raw_session is nil" do
|
561
|
-
@app = setup_rack(@app, { nil_session: true })
|
562
|
-
@env['rack.session'] = nil
|
563
|
-
@env['warden.spec.which_logout'] = :foo
|
564
|
-
expect { @app.call(@env) }.to_not raise_error(NoMethodError)
|
565
|
-
end
|
566
|
-
|
567
552
|
it "should clear the user when logging out" do
|
568
553
|
@env['rack.session'].should_not be_nil
|
569
554
|
app = lambda do |e|
|
@@ -680,7 +665,7 @@ describe Warden::Proxy do
|
|
680
665
|
app = lambda do |e|
|
681
666
|
e['warden'].should be_authenticated
|
682
667
|
end
|
683
|
-
setup_rack(app).call(@env)
|
668
|
+
result = setup_rack(app).call(@env)
|
684
669
|
end
|
685
670
|
|
686
671
|
it "should yield to a block when the block is passed and authenticated" do
|
@@ -715,7 +700,7 @@ describe Warden::Proxy do
|
|
715
700
|
app = lambda do |e|
|
716
701
|
e['warden'].should_not be_authenticated
|
717
702
|
end
|
718
|
-
setup_rack(app).call(@env)
|
703
|
+
result = setup_rack(app).call(@env)
|
719
704
|
end
|
720
705
|
|
721
706
|
it "should return false if scope cannot be retrieved from session" do
|
@@ -801,7 +786,7 @@ describe Warden::Proxy do
|
|
801
786
|
app = lambda do |e|
|
802
787
|
e['warden'].should be_unauthenticated
|
803
788
|
end
|
804
|
-
setup_rack(app).call(@env)
|
789
|
+
result = setup_rack(app).call(@env)
|
805
790
|
end
|
806
791
|
|
807
792
|
it "should yield to a block when the block is passed and authenticated" do
|
@@ -843,8 +828,6 @@ end
|
|
843
828
|
|
844
829
|
describe "dynamic default_strategies" do
|
845
830
|
before(:all) do
|
846
|
-
load_strategies
|
847
|
-
|
848
831
|
class ::DynamicDefaultStrategies
|
849
832
|
def initialize(app, &blk)
|
850
833
|
@app, @blk = app, blk
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Warden::SessionSerializer do
|
@@ -45,9 +45,4 @@ describe Warden::SessionSerializer do
|
|
45
45
|
@session.fetch(:default)
|
46
46
|
@env['rack.session'].should_not have_key("warden.user.default.key")
|
47
47
|
end
|
48
|
-
|
49
|
-
it "should support a nil session store" do
|
50
|
-
@env['rack.session'] = nil
|
51
|
-
@session.fetch(:default).should be_nil
|
52
|
-
end
|
53
48
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Warden::Strategies do
|
@@ -11,23 +11,13 @@ describe Warden::Strategies do
|
|
11
11
|
Warden::Strategies[:strategy1].ancestors.should include(Warden::Strategies::Base)
|
12
12
|
end
|
13
13
|
|
14
|
-
it "should raise an error if I add a strategy via a block, that does not have an
|
14
|
+
it "should raise an error if I add a strategy via a block, that does not have an autheniticate! method" do
|
15
15
|
lambda do
|
16
16
|
Warden::Strategies.add(:strategy2) do
|
17
17
|
end
|
18
18
|
end.should raise_error
|
19
19
|
end
|
20
20
|
|
21
|
-
it "should raise an error if I add a strategy that does not extend Warden::Strategies::Base" do
|
22
|
-
non_base = Class.new do
|
23
|
-
def authenticate!
|
24
|
-
end
|
25
|
-
end
|
26
|
-
expect do
|
27
|
-
Warden::Strategies.add(:strategy_non_base, non_base)
|
28
|
-
end.to raise_error(/is not a Warden::Strategies::Base/)
|
29
|
-
end
|
30
|
-
|
31
21
|
it "should allow me to get access to a particular strategy" do
|
32
22
|
Warden::Strategies.add(:strategy3) do
|
33
23
|
def authenticate!; end
|
data/warden.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loyal_warden
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.0'
|
30
30
|
description:
|
31
|
-
email:
|
31
|
+
email: andywang7259@gmail.com
|
32
32
|
executables: []
|
33
33
|
extensions: []
|
34
34
|
extra_rdoc_files:
|
@@ -49,7 +49,6 @@ files:
|
|
49
49
|
- lib/warden/errors.rb
|
50
50
|
- lib/warden/session_serializer.rb
|
51
51
|
- lib/warden.rb
|
52
|
-
- lib/loyal_warden.rb
|
53
52
|
- warden.gemspec
|
54
53
|
- History.rdoc
|
55
54
|
- spec/warden/hooks_spec.rb
|
@@ -76,9 +75,8 @@ files:
|
|
76
75
|
- Gemfile
|
77
76
|
- Rakefile
|
78
77
|
- README.textile
|
79
|
-
homepage: http://github.com/
|
80
|
-
licenses:
|
81
|
-
- MIT
|
78
|
+
homepage: http://github.com/blogsoso/warden
|
79
|
+
licenses: []
|
82
80
|
post_install_message:
|
83
81
|
rdoc_options:
|
84
82
|
- "--charset=UTF-8"
|
data/lib/loyal_warden.rb
DELETED