warden 1.2.7 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +27 -0
  3. data/.gitignore +6 -0
  4. data/.rspec +3 -0
  5. data/{History.rdoc → CHANGELOG.md} +74 -39
  6. data/Gemfile +2 -2
  7. data/LICENSE +2 -1
  8. data/README.md +18 -0
  9. data/Rakefile +3 -8
  10. data/lib/warden/config.rb +1 -1
  11. data/lib/warden/errors.rb +2 -2
  12. data/lib/warden/hooks.rb +1 -1
  13. data/lib/warden/manager.rb +2 -2
  14. data/lib/warden/mixins/common.rb +1 -1
  15. data/lib/warden/proxy.rb +24 -5
  16. data/lib/warden/session_serializer.rb +1 -1
  17. data/lib/warden/strategies/base.rb +2 -1
  18. data/lib/warden/test/helpers.rb +2 -2
  19. data/lib/warden/test/mock.rb +5 -5
  20. data/lib/warden/test/warden_helpers.rb +1 -1
  21. data/lib/warden/version.rb +2 -2
  22. data/lib/warden.rb +1 -1
  23. data/warden.gemspec +18 -18
  24. metadata +18 -36
  25. data/README.textile +0 -9
  26. data/spec/helpers/request_helper.rb +0 -52
  27. data/spec/helpers/strategies/fail_with_user.rb +0 -11
  28. data/spec/helpers/strategies/failz.rb +0 -9
  29. data/spec/helpers/strategies/invalid.rb +0 -9
  30. data/spec/helpers/strategies/pass.rb +0 -9
  31. data/spec/helpers/strategies/pass_with_message.rb +0 -9
  32. data/spec/helpers/strategies/password.rb +0 -14
  33. data/spec/helpers/strategies/single.rb +0 -13
  34. data/spec/spec_helper.rb +0 -26
  35. data/spec/warden/authenticated_data_store_spec.rb +0 -115
  36. data/spec/warden/config_spec.rb +0 -49
  37. data/spec/warden/errors_spec.rb +0 -48
  38. data/spec/warden/hooks_spec.rb +0 -374
  39. data/spec/warden/manager_spec.rb +0 -341
  40. data/spec/warden/proxy_spec.rb +0 -1051
  41. data/spec/warden/scoped_session_serializer.rb +0 -124
  42. data/spec/warden/session_serializer_spec.rb +0 -54
  43. data/spec/warden/strategies/base_spec.rb +0 -314
  44. data/spec/warden/strategies_spec.rb +0 -95
  45. data/spec/warden/test/helpers_spec.rb +0 -94
  46. data/spec/warden/test/mock_spec.rb +0 -16
  47. data/spec/warden/test/test_mode_spec.rb +0 -76
metadata CHANGED
@@ -1,14 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Neighman
8
+ - Justin Smestad
9
+ - Whitney Smestad
10
+ - José Valim
8
11
  autorequire:
9
12
  bindir: bin
10
13
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
14
+ date: 2020-08-31 00:00:00.000000000 Z
12
15
  dependencies:
13
16
  - !ruby/object:Gem::Dependency
14
17
  name: rack
@@ -16,26 +19,29 @@ dependencies:
16
19
  requirements:
17
20
  - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: '1.0'
22
+ version: 2.0.9
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '1.0'
29
+ version: 2.0.9
27
30
  description:
28
- email: has.sox@gmail.com
31
+ email: hasox.sox@gmail.com justin.smestad@gmail.com whitcolorado@gmail.com
29
32
  executables: []
30
33
  extensions: []
31
34
  extra_rdoc_files:
32
35
  - LICENSE
33
- - README.textile
36
+ - README.md
34
37
  files:
38
+ - ".github/workflows/ruby.yml"
39
+ - ".gitignore"
40
+ - ".rspec"
41
+ - CHANGELOG.md
35
42
  - Gemfile
36
- - History.rdoc
37
43
  - LICENSE
38
- - README.textile
44
+ - README.md
39
45
  - Rakefile
40
46
  - lib/warden.rb
41
47
  - lib/warden/config.rb
@@ -51,36 +57,13 @@ files:
51
57
  - lib/warden/test/mock.rb
52
58
  - lib/warden/test/warden_helpers.rb
53
59
  - lib/warden/version.rb
54
- - spec/helpers/request_helper.rb
55
- - spec/helpers/strategies/fail_with_user.rb
56
- - spec/helpers/strategies/failz.rb
57
- - spec/helpers/strategies/invalid.rb
58
- - spec/helpers/strategies/pass.rb
59
- - spec/helpers/strategies/pass_with_message.rb
60
- - spec/helpers/strategies/password.rb
61
- - spec/helpers/strategies/single.rb
62
- - spec/spec_helper.rb
63
- - spec/warden/authenticated_data_store_spec.rb
64
- - spec/warden/config_spec.rb
65
- - spec/warden/errors_spec.rb
66
- - spec/warden/hooks_spec.rb
67
- - spec/warden/manager_spec.rb
68
- - spec/warden/proxy_spec.rb
69
- - spec/warden/scoped_session_serializer.rb
70
- - spec/warden/session_serializer_spec.rb
71
- - spec/warden/strategies/base_spec.rb
72
- - spec/warden/strategies_spec.rb
73
- - spec/warden/test/helpers_spec.rb
74
- - spec/warden/test/mock_spec.rb
75
- - spec/warden/test/test_mode_spec.rb
76
60
  - warden.gemspec
77
- homepage: http://github.com/hassox/warden
61
+ homepage: https://github.com/hassox/warden
78
62
  licenses:
79
63
  - MIT
80
64
  metadata: {}
81
65
  post_install_message:
82
- rdoc_options:
83
- - "--charset=UTF-8"
66
+ rdoc_options: []
84
67
  require_paths:
85
68
  - lib
86
69
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -94,9 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
77
  - !ruby/object:Gem::Version
95
78
  version: '0'
96
79
  requirements: []
97
- rubyforge_project: warden
98
- rubygems_version: 2.6.8
80
+ rubygems_version: 3.1.2
99
81
  signing_key:
100
82
  specification_version: 4
101
- summary: Rack middleware that provides authentication for rack applications
83
+ summary: An authentication library compatible with all Rack-based frameworks
102
84
  test_files: []
data/README.textile DELETED
@@ -1,9 +0,0 @@
1
- Please see the "Warden Wiki":http://wiki.github.com/hassox/warden for overview documentation.
2
-
3
- h2. Maintainers
4
-
5
- * Daniel Neighman (hassox)
6
- * José Valim (josevalim)
7
- * Justin Smestad (jsmestad)
8
-
9
- "A list of all contributors is available on Github.":https://github.com/hassox/warden/contributors
@@ -1,52 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- module Warden::Spec
4
- module Helpers
5
- FAILURE_APP = lambda{|e|[401, {"Content-Type" => "text/plain"}, ["You Fail!"]] }
6
-
7
- def env_with_params(path = "/", params = {}, env = {})
8
- method = params.delete(:method) || "GET"
9
- env = { 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => "#{method}" }.merge(env)
10
- Rack::MockRequest.env_for("#{path}?#{Rack::Utils.build_query(params)}", env)
11
- end
12
-
13
- def setup_rack(app = nil, opts = {}, &block)
14
- app ||= block if block_given?
15
-
16
- opts[:failure_app] ||= failure_app
17
- opts[:default_strategies] ||= [:password]
18
- opts[:default_serializers] ||= [:session]
19
- blk = opts[:configurator] || proc{}
20
-
21
- Rack::Builder.new do
22
- use opts[:session] || Warden::Spec::Helpers::Session unless opts[:nil_session]
23
- use Warden::Manager, opts, &blk
24
- run app
25
- end
26
- end
27
-
28
- def valid_response
29
- Rack::Response.new("OK").finish
30
- end
31
-
32
- def failure_app
33
- Warden::Spec::Helpers::FAILURE_APP
34
- end
35
-
36
- def success_app
37
- lambda{|e| [200, {"Content-Type" => "text/plain"}, ["You Win"]]}
38
- end
39
-
40
- class Session
41
- attr_accessor :app
42
- def initialize(app,configs = {})
43
- @app = app
44
- end
45
-
46
- def call(e)
47
- e['rack.session'] ||= {}
48
- @app.call(e)
49
- end
50
- end # session
51
- end
52
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- Warden::Strategies.add(:fail_with_user) do
4
- def authenticate!
5
- request.env['warden.spec.strategies'] ||= []
6
- request.env['warden.spec.strategies'] << :fail_with_user
7
- self.user = 'Valid User'
8
- fail!
9
- end
10
- end
11
-
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- Warden::Strategies.add(:failz) do
4
- def authenticate!
5
- request.env['warden.spec.strategies'] ||= []
6
- request.env['warden.spec.strategies'] << :failz
7
- fail!("The Fails Strategy Has Failed You")
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- Warden::Strategies.add(:invalid) do
4
- def valid?
5
- false
6
- end
7
-
8
- def authenticate!; end
9
- end
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- Warden::Strategies.add(:pass) do
4
- def authenticate!
5
- request.env['warden.spec.strategies'] ||= []
6
- request.env['warden.spec.strategies'] << :pass
7
- success!("Valid User") unless scope == :failz
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- Warden::Strategies.add(:pass_with_message) do
4
- def authenticate!
5
- request.env['warden.spec.strategies'] ||= []
6
- request.env['warden.spec.strategies'] << :pass_with_message
7
- success!("Valid User", "The Success Strategy Has Accepted You") unless scope == :failz
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- Warden::Strategies.add(:password) do
4
- def authenticate!
5
- request.env['warden.spec.strategies'] ||= []
6
- request.env['warden.spec.strategies'] << :password
7
- if params["password"] || params["username"]
8
- params["password"] == "sekrit" && params["username"] == "fred" ?
9
- success!("Authenticated User") : fail!("Username or password is incorrect")
10
- else
11
- pass
12
- end
13
- end
14
- end
@@ -1,13 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- Warden::Strategies.add(:single) do
4
- def authenticate!
5
- request.env['warden.spec.strategies'] ||= []
6
- request.env['warden.spec.strategies'] << :single
7
- success!("Valid User")
8
- end
9
-
10
- def store?
11
- false
12
- end
13
- end
data/spec/spec_helper.rb DELETED
@@ -1,26 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- $TESTING=true
4
-
5
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__)))
7
- require 'warden'
8
-
9
- require 'rubygems'
10
- require 'rack'
11
-
12
- Dir[File.join(File.dirname(__FILE__), "helpers", "**/*.rb")].each do |f|
13
- require f
14
- end
15
-
16
- RSpec.configure do |config|
17
- config.include(Warden::Spec::Helpers)
18
- config.include(Warden::Test::Helpers)
19
- config.include(Warden::Test::Mock)
20
-
21
- def load_strategies
22
- Dir[File.join(File.dirname(__FILE__), "helpers", "strategies", "**/*.rb")].each do |f|
23
- load f
24
- end
25
- end
26
- end
@@ -1,115 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- require 'spec_helper'
4
-
5
- describe "authenticated data store" do
6
-
7
- before(:each) do
8
- @env = env_with_params
9
- @env['rack.session'] = {
10
- "warden.user.foo.key" => "foo user",
11
- "warden.user.default.key" => "default user",
12
- :foo => "bar"
13
- }
14
- end
15
-
16
- it "should store data for the default scope" do
17
- app = lambda do |e|
18
- e['warden'].authenticate(:pass)
19
- e['warden'].authenticate(:pass, :scope => :foo)
20
- expect(e['warden']).to be_authenticated
21
- expect(e['warden']).to be_authenticated(:foo)
22
-
23
- # Store the data for :default
24
- e['warden'].session[:key] = "value"
25
- valid_response
26
- end
27
- setup_rack(app).call(@env)
28
- expect(@env['rack.session']['warden.user.default.session']).to eq(key: "value")
29
- expect(@env['rack.session']['warden.user.foo.session']).to be_nil
30
- end
31
-
32
- it "should store data for the foo user" do
33
- app = lambda do |e|
34
- e['warden'].session(:foo)[:key] = "value"
35
- valid_response
36
- end
37
- setup_rack(app).call(@env)
38
- expect(@env['rack.session']['warden.user.foo.session']).to eq(key: "value")
39
- end
40
-
41
- it "should store the data separately" do
42
- app = lambda do |e|
43
- e['warden'].session[:key] = "value"
44
- e['warden'].session(:foo)[:key] = "another value"
45
- valid_response
46
- end
47
- setup_rack(app).call(@env)
48
- expect(@env['rack.session']['warden.user.default.session']).to eq(key: "value")
49
- expect(@env['rack.session']['warden.user.foo.session' ]).to eq(key: "another value")
50
- end
51
-
52
- it "should clear the foo scoped data when foo logs out" do
53
- app = lambda do |e|
54
- e['warden'].session[:key] = "value"
55
- e['warden'].session(:foo)[:key] = "another value"
56
- e['warden'].logout(:foo)
57
- valid_response
58
- end
59
- setup_rack(app).call(@env)
60
- expect(@env['rack.session']['warden.user.default.session']).to eq(key: "value")
61
- expect(@env['rack.session']['warden.user.foo.session' ]).to be_nil
62
- end
63
-
64
- it "should clear out the default data when :default logs out" do
65
- app = lambda do |e|
66
- e['warden'].session[:key] = "value"
67
- e['warden'].session(:foo)[:key] = "another value"
68
- e['warden'].logout(:default)
69
- valid_response
70
- end
71
- setup_rack(app).call(@env)
72
- expect(@env['rack.session']['warden.user.default.session']).to be_nil
73
- expect(@env['rack.session']['warden.user.foo.session' ]).to eq(key: "another value")
74
- end
75
-
76
- it "should clear out all data when a general logout is performed" do
77
- app = lambda do |e|
78
- e['warden'].session[:key] = "value"
79
- e['warden'].session(:foo)[:key] = "another value"
80
- e['warden'].logout
81
- valid_response
82
- end
83
- setup_rack(app).call(@env)
84
- expect(@env['rack.session']['warden.user.default.session']).to be_nil
85
- expect(@env['rack.session']['warden.user.foo.session' ]).to be_nil
86
- end
87
-
88
- it "should logout multiple persons at once" do
89
- @env['rack.session']['warden.user.bar.key'] = "bar user"
90
-
91
- app = lambda do |e|
92
- e['warden'].session[:key] = "value"
93
- e['warden'].session(:foo)[:key] = "another value"
94
- e['warden'].session(:bar)[:key] = "yet another"
95
- e['warden'].logout(:bar, :default)
96
- valid_response
97
- end
98
- setup_rack(app).call(@env)
99
- expect(@env['rack.session']['warden.user.default.session']).to be_nil
100
- expect(@env['rack.session']['warden.user.foo.session' ]).to eq(key: "another value")
101
- expect(@env['rack.session']['warden.user.bar.session' ]).to be_nil
102
- end
103
-
104
- it "should not store data for a user who is not logged in" do
105
- @env['rack.session']
106
- app = lambda do |e|
107
- e['warden'].session(:not_here)[:key] = "value"
108
- valid_response
109
- end
110
-
111
- expect {
112
- setup_rack(app).call(@env)
113
- }.to raise_error(Warden::NotAuthenticated)
114
- end
115
- end
@@ -1,49 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- require 'spec_helper'
4
-
5
- describe Warden::Config do
6
-
7
- before(:each) do
8
- @config = Warden::Config.new
9
- end
10
-
11
- it "should behave like a hash" do
12
- @config[:foo] = :bar
13
- expect(@config[:foo]).to eq(:bar)
14
- end
15
-
16
- it "should provide hash accessors" do
17
- @config.failure_app = :foo
18
- expect(@config[:failure_app]).to eq(:foo)
19
- @config[:failure_app] = :bar
20
- expect(@config.failure_app).to eq(:bar)
21
- end
22
-
23
- it "should allow to read and set default strategies" do
24
- @config.default_strategies :foo, :bar
25
- expect(@config.default_strategies).to eq([:foo, :bar])
26
- end
27
-
28
- it "should allow to silence missing strategies" do
29
- @config.silence_missing_strategies!
30
- expect(@config.silence_missing_strategies?).to eq(true)
31
- end
32
-
33
- it "should set the default_scope" do
34
- expect(@config.default_scope).to eq(:default)
35
- @config.default_scope = :foo
36
- expect(@config.default_scope).to eq(:foo)
37
- end
38
-
39
- it "should merge given options on initialization" do
40
- expect(Warden::Config.new(:foo => :bar)[:foo]).to eq(:bar)
41
- end
42
-
43
- it "should setup defaults with the scope_defaults method" do
44
- c = Warden::Config.new
45
- c.scope_defaults :foo, :strategies => [:foo, :bar], :store => false
46
- expect(c.default_strategies(:scope => :foo)).to eq([:foo, :bar])
47
- expect(c.scope_defaults(:foo)).to eq(store: false)
48
- end
49
- end
@@ -1,48 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- require 'spec_helper'
4
-
5
- describe Warden::Proxy::Errors do
6
-
7
- before(:each) do
8
- @errors = Warden::Proxy::Errors.new
9
- end
10
-
11
- it "should report that it is empty on first creation" do
12
- expect(@errors).to be_empty
13
- end
14
-
15
- it "should continue to report that it is empty even after being checked" do
16
- @errors.on(:foo)
17
- expect(@errors).to be_empty
18
- end
19
-
20
- it "should add an error" do
21
- @errors.add(:login, "Login or password incorrect")
22
- expect(@errors[:login]).to eq(["Login or password incorrect"])
23
- end
24
-
25
- it "should allow many errors to be added to the same field" do
26
- @errors.add(:login, "bad 1")
27
- @errors.add(:login, "bad 2")
28
- expect(@errors.on(:login)).to eq(["bad 1", "bad 2"])
29
- end
30
-
31
- it "should give the full messages for an error" do
32
- @errors.add(:login, "login wrong")
33
- @errors.add(:password, "password wrong")
34
- ["password wrong", "login wrong"].each do |msg|
35
- expect(@errors.full_messages).to include(msg)
36
- end
37
- end
38
-
39
- it "should return the error for a specific field / label" do
40
- @errors.add(:login, "wrong")
41
- expect(@errors.on(:login)).to eq(["wrong"])
42
- end
43
-
44
- it "should return nil for a specific field if it's not been set" do
45
- expect(@errors.on(:not_there)).to be_nil
46
- end
47
-
48
- end