warden 1.2.4 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +27 -0
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/{History.rdoc → CHANGELOG.md} +80 -36
- data/Gemfile +3 -2
- data/LICENSE +2 -1
- data/README.md +18 -0
- data/Rakefile +4 -8
- data/lib/warden.rb +2 -0
- data/lib/warden/config.rb +1 -0
- data/lib/warden/errors.rb +2 -1
- data/lib/warden/hooks.rb +1 -0
- data/lib/warden/manager.rb +2 -1
- data/lib/warden/mixins/common.rb +1 -0
- data/lib/warden/proxy.rb +24 -4
- data/lib/warden/session_serializer.rb +1 -0
- data/lib/warden/strategies.rb +1 -0
- data/lib/warden/strategies/base.rb +3 -1
- data/lib/warden/test/helpers.rb +2 -1
- data/lib/warden/test/mock.rb +69 -0
- data/lib/warden/test/warden_helpers.rb +1 -0
- data/lib/warden/version.rb +2 -1
- data/warden.gemspec +19 -18
- metadata +19 -35
- data/README.textile +0 -9
- data/spec/helpers/request_helper.rb +0 -51
- data/spec/helpers/strategies/fail_with_user.rb +0 -10
- data/spec/helpers/strategies/failz.rb +0 -8
- data/spec/helpers/strategies/invalid.rb +0 -8
- data/spec/helpers/strategies/pass.rb +0 -8
- data/spec/helpers/strategies/pass_with_message.rb +0 -8
- data/spec/helpers/strategies/password.rb +0 -13
- data/spec/helpers/strategies/single.rb +0 -12
- data/spec/spec_helper.rb +0 -24
- data/spec/warden/authenticated_data_store_spec.rb +0 -114
- data/spec/warden/config_spec.rb +0 -48
- data/spec/warden/errors_spec.rb +0 -47
- data/spec/warden/hooks_spec.rb +0 -373
- data/spec/warden/manager_spec.rb +0 -340
- data/spec/warden/proxy_spec.rb +0 -1050
- data/spec/warden/scoped_session_serializer.rb +0 -123
- data/spec/warden/session_serializer_spec.rb +0 -53
- data/spec/warden/strategies/base_spec.rb +0 -313
- data/spec/warden/strategies_spec.rb +0 -94
- data/spec/warden/test/helpers_spec.rb +0 -93
- data/spec/warden/test/test_mode_spec.rb +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b7e6c341f27479e6f36339e5d2c211277b4c0e664c960827c2044dd36b5c1c23
|
4
|
+
data.tar.gz: 62e22ba4d81a887444d60ff033c7a6b0a0a8e723771d15cee045ee83baece801
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6b602f560ebc6f04848c0c7e2d9017af8bf55c6cd6e6fec978e28e0463960761eaf488fabdba1b14d78bcf16e352a97d9b95b361142c3a4c14672517ca9e5b5
|
7
|
+
data.tar.gz: 9a6397e9d84063c8f7cf221c878b0657151a0cf01a6f98172b2ca0dfd1d5e7eddf7da9ce616f550928f5f14dcb073553379add7a006acc875fb162a7ce2a8210
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Tests
|
9
|
+
on: [push, pull_request]
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby: [ '2.5', '2.6', '2.7' ]
|
17
|
+
name: Ruby ${{ matrix.ruby }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: 2.6
|
24
|
+
- name: Install dependencies
|
25
|
+
run: bundle install
|
26
|
+
- name: Run tests
|
27
|
+
run: bundle exec rake
|
data/.rspec
ADDED
@@ -1,71 +1,114 @@
|
|
1
|
-
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## Version 1.2.9 / 2020-08-31
|
4
|
+
* Avoid warning on uninitialized instance variable (#188)
|
5
|
+
* Bump rack to 2.2.3 (#190)
|
6
|
+
* Remove Gemfile.lock
|
7
|
+
* Resolve outstanding TODO entries (#179)
|
8
|
+
* A bunch of gem structure cleanup (thanks @olleolleolle)
|
9
|
+
* Set winning strategy when :warden is thrown (#174)
|
10
|
+
* Bump rack dependency to >= 2.0.9 due to CVEs
|
11
|
+
|
12
|
+
## Version 1.2.8 / 2018-11-15
|
13
|
+
|
14
|
+
* Bugfix: Flips two lines to allow scopes authenticating from another without stepping on each other's toes. (PR #144)
|
15
|
+
* Update `rack` dependency to >= 2.0.6 due to security vulnerability
|
16
|
+
* Internal: Add Rubocop Lint checking
|
17
|
+
* Internal: Update RSpec to use `.rspec` file
|
18
|
+
|
19
|
+
## Version 1.2.7 / 2016-10-12
|
20
|
+
|
21
|
+
* Added 'frozen_string_literal' comment, bump ruby to 2.3
|
22
|
+
|
23
|
+
## Version 1.2.6 / 2016-01-31
|
24
|
+
|
25
|
+
* Separate test helpers to encapsulate Warden object mocking inside it's own class
|
26
|
+
|
27
|
+
## Version 1.2.5 / 2016-01-28
|
28
|
+
|
29
|
+
* Expands on the test helpers available to make it easier for testing gems
|
30
|
+
|
31
|
+
## Version 1.2.3 / 2013-07-14
|
32
|
+
|
2
33
|
* Fix an issue with lazy loaded sessions
|
3
34
|
|
4
|
-
|
35
|
+
## Version 1.2.2 / 2013-07-12
|
36
|
+
|
5
37
|
* Support nil session stores on logout
|
6
38
|
* Fix strategies blowing up with undefined method base
|
7
39
|
|
8
|
-
|
40
|
+
## Version 1.2.1 / 2012-06-16
|
41
|
+
|
9
42
|
* Minor caching and speed improvements
|
10
43
|
* Add support to #lock in the proxy
|
11
44
|
* Add support to after_failed_fetch callback
|
12
45
|
|
13
|
-
|
46
|
+
## Version 1.2.0 / 2012-05-08
|
47
|
+
|
14
48
|
* Deprecate warden_cookies since it was never functional
|
15
49
|
* Add support to serialize_from_session and serialize_into_session per scope
|
16
50
|
|
17
|
-
|
51
|
+
## Version 1.1.1 / 2012-02-16
|
52
|
+
|
18
53
|
* Allow run_callbacks as an option to set_user and user
|
19
54
|
|
20
|
-
|
55
|
+
## Version 1.1.0 / 2011-11-02
|
56
|
+
|
21
57
|
* Use the default scopes action when using a bare throw(:warden)
|
22
58
|
|
23
|
-
|
59
|
+
## Version 1.0.6
|
60
|
+
|
24
61
|
* Remove gem files from the packaged gem
|
25
62
|
|
26
|
-
|
63
|
+
## Version 1.0.3
|
64
|
+
|
27
65
|
* Do not renew session on user fetch
|
28
66
|
|
29
|
-
|
67
|
+
## Version 1.0.2
|
68
|
+
|
30
69
|
* Added :intercept_401 to Warden::Config
|
31
70
|
|
32
|
-
|
71
|
+
## Version 1.0.1
|
72
|
+
|
33
73
|
* Bug fix on strategies errors handler
|
34
74
|
|
35
|
-
|
75
|
+
## Version 1.0.0
|
76
|
+
|
36
77
|
* Bump!
|
37
78
|
* Allow strategies to configure if user should be stored or not
|
38
79
|
* Force session id renewal when user is set
|
39
80
|
|
40
|
-
|
81
|
+
## Version 0.10.7
|
82
|
+
|
41
83
|
* Performance boost. config object to use raw accessors
|
42
84
|
* Add per strategy storage option
|
43
85
|
|
44
|
-
|
86
|
+
## Version 0.10.6 / 0.10.7 / 2010-05-22
|
87
|
+
|
45
88
|
* Bugfix set_user was not respecting logouts in hooks
|
46
89
|
|
47
|
-
|
90
|
+
## Version 0.10.4 / 0.10.5 / 2010-05-20
|
48
91
|
* Add action specifying in scope_defaults
|
49
92
|
|
50
|
-
|
93
|
+
## Version 0.10.3 / 2010-03-01
|
51
94
|
* Bugfix prevent halted winning strategy from being skipped in subsequent runs
|
52
95
|
|
53
|
-
|
96
|
+
## Version 0.10.2 / 2010-03-26
|
54
97
|
* Halt on fail!. Add fail to allow cascading
|
55
98
|
* cache the winning strategy
|
56
99
|
* Make the config object Dupable
|
57
100
|
|
58
|
-
|
101
|
+
## Version 0.10.1 / 2010-03-23
|
59
102
|
* Merge previous from master
|
60
103
|
* tag
|
61
104
|
|
62
|
-
|
105
|
+
## Version 0.10.0 / 2010-03-22
|
63
106
|
* Allow default strategies to be set on the proxy
|
64
107
|
* Provide each scope with it's own default strategies
|
65
108
|
* Provide each scope with default set_user opts
|
66
109
|
* depricate the Proxy#default_strategies= method
|
67
110
|
|
68
|
-
|
111
|
+
## Version 0.9.5 / 2010-02-28
|
69
112
|
|
70
113
|
* Add Warden.test_mode!
|
71
114
|
* Add Warden.on_next_request
|
@@ -73,42 +116,42 @@
|
|
73
116
|
** login_as
|
74
117
|
** logout
|
75
118
|
|
76
|
-
|
119
|
+
## Version 0.9.4 / 2010-02-23
|
77
120
|
|
78
121
|
* Fix an issue where winning_strategy was not cleaned, allowing multiple scopes to sign in, even when the second one should not
|
79
122
|
|
80
|
-
|
123
|
+
## Version 0.9.3 / 2010-02-17
|
81
124
|
|
82
125
|
* Add prepend_ to all hooks (josevalim)
|
83
126
|
|
84
|
-
|
127
|
+
## Version 0.9.2 / 2010-02-10
|
85
128
|
|
86
129
|
* Ruby 1.9 compatibility changes (grimen)
|
87
130
|
|
88
|
-
|
131
|
+
## Version 0.9.1 / 2010-02-09
|
89
132
|
|
90
133
|
* Support for passing a custom message with Warden::Strategy::Base#success! as second optional (grimen)
|
91
134
|
|
92
|
-
|
135
|
+
## Version 0.9.0 / 2010-01-21
|
93
136
|
|
94
137
|
* Remove serializers and make strategies more powerful, including cache behavior (josevalim)
|
95
138
|
|
96
|
-
|
139
|
+
## Version 0.8.1 / 2010-01-06
|
97
140
|
|
98
141
|
* Fix a bug when silence missing serializers is set (josevalim)
|
99
142
|
|
100
|
-
|
143
|
+
## Version 0.8.0 / 2010-01-06
|
101
144
|
|
102
145
|
* enhancements
|
103
146
|
* Add conditionals to callbacks (josevalim)
|
104
147
|
* Extract Warden::Config from Warden::Manager (josevalim)
|
105
148
|
|
106
|
-
|
149
|
+
## Version 0.7.0 / 2010-01-04
|
107
150
|
|
108
151
|
* enhancements
|
109
152
|
* Expose config in warden proxy (hassox)
|
110
153
|
|
111
|
-
|
154
|
+
## Version 0.6.0 / 2009-11-16
|
112
155
|
|
113
156
|
* enhancements
|
114
157
|
* added serializers, including session serializer (set by default) and a cookie serializer (josevalim)
|
@@ -116,24 +159,27 @@
|
|
116
159
|
* deprecation
|
117
160
|
* serializer_into_session and serializer_from_session are deprecated, overwrite serialize and deserializer in Warden::Serializers::Session instead (josevalim)
|
118
161
|
|
119
|
-
|
162
|
+
## Version 0.5.3 / 2009-11-10
|
163
|
+
|
120
164
|
* bug fixes
|
121
165
|
* authenticated? and unauthenticated? should return true or false, not the user or false. (hassox)
|
122
166
|
|
123
|
-
|
167
|
+
## Version 0.5.2 / 2009-11-09
|
168
|
+
|
124
169
|
* enhancements
|
125
170
|
* authenticated? always try to serialize the user from session (josevalim)
|
126
171
|
* stored_in_session? checks if user information is stored in session, without serializing (josevalim)
|
127
172
|
* 401 behaves exactly like throw :warden (staugaard)
|
128
173
|
|
129
|
-
|
174
|
+
## Version 0.5.1 / 2009-10-25
|
175
|
+
|
130
176
|
* enhancements
|
131
|
-
* Adds
|
177
|
+
* Adds yielding to authenticated? and unauthenticated? methods (hassox)
|
132
178
|
* Adds an option to silence missing strategies (josevalim)
|
133
179
|
* Add an option to authenticate(!) to prevent storage of a user into the session (hassox)
|
134
180
|
* allow custom :action to be thrown (josevalim)
|
135
181
|
|
136
|
-
|
182
|
+
## Version 0.4.0 / 2009-10-12
|
137
183
|
|
138
184
|
* enhancements
|
139
185
|
* add Content-Type header to redirects (staugaard)
|
@@ -142,9 +188,7 @@
|
|
142
188
|
* bug fixes
|
143
189
|
* Do not consume opts twice, otherwise just the first will parse the scope (josevalim)
|
144
190
|
|
145
|
-
|
191
|
+
## Version 0.3.2 / 2009-09-15
|
146
192
|
|
147
193
|
* enhancements
|
148
194
|
* add a hook for plugins to specify how they can clear the whole section
|
149
|
-
|
150
|
-
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Warden
|
2
|
+
|
3
|
+
## Getting Started
|
4
|
+
|
5
|
+
Please see the [Warden Wiki](https://github.com/wardencommunity/warden/wiki) for overview documentation.
|
6
|
+
|
7
|
+
## Maintainers
|
8
|
+
|
9
|
+
* Daniel Neighman (hassox)
|
10
|
+
* José Valim (josevalim)
|
11
|
+
* Justin Smestad (jsmestad)
|
12
|
+
* Whitney Smestad (whithub)
|
13
|
+
|
14
|
+
[A list of all contributors is available on Github.](https://github.com/hassox/warden/contributors)
|
15
|
+
|
16
|
+
## LICENSE
|
17
|
+
|
18
|
+
See `LICENSE` file.
|
data/Rakefile
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require
|
4
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
5
|
|
6
|
-
|
7
|
-
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
7
|
|
9
8
|
task :default => :spec
|
10
|
-
|
11
|
-
desc "Run all specs in spec directory"
|
12
|
-
RSpec::Core::RakeTask.new(:spec)
|
data/lib/warden.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require 'forwardable'
|
3
4
|
|
4
5
|
require 'warden/mixins/common'
|
@@ -15,6 +16,7 @@ module Warden
|
|
15
16
|
module Test
|
16
17
|
autoload :WardenHelpers, 'warden/test/warden_helpers'
|
17
18
|
autoload :Helpers, 'warden/test/helpers'
|
19
|
+
autoload :Mock, 'warden/test/mock'
|
18
20
|
end
|
19
21
|
|
20
22
|
# Provides helper methods to warden for testing.
|
data/lib/warden/config.rb
CHANGED
data/lib/warden/errors.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
module Warden
|
3
4
|
class Proxy
|
4
5
|
# Lifted from DataMapper's dm-validations plugin :)
|
@@ -38,7 +39,7 @@ module Warden
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def each
|
41
|
-
errors.map.each do |
|
42
|
+
errors.map.each do |_k,v|
|
42
43
|
next if blank?(v)
|
43
44
|
yield(v)
|
44
45
|
end
|
data/lib/warden/hooks.rb
CHANGED
data/lib/warden/manager.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require 'warden/hooks'
|
3
4
|
require 'warden/config'
|
4
5
|
|
@@ -21,7 +22,6 @@ module Warden
|
|
21
22
|
@app, @config = app, Warden::Config.new(options)
|
22
23
|
@config.default_strategies(*default_strategies) if default_strategies
|
23
24
|
yield @config if block_given?
|
24
|
-
self
|
25
25
|
end
|
26
26
|
|
27
27
|
# Invoke the application guarding for throw :warden.
|
@@ -32,6 +32,7 @@ module Warden
|
|
32
32
|
|
33
33
|
env['warden'] = Proxy.new(env, self)
|
34
34
|
result = catch(:warden) do
|
35
|
+
env['warden'].on_request
|
35
36
|
@app.call(env)
|
36
37
|
end
|
37
38
|
|
data/lib/warden/mixins/common.rb
CHANGED
data/lib/warden/proxy.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Warden
|
4
5
|
class UserNotSet < RuntimeError; end
|
@@ -28,6 +29,11 @@ module Warden
|
|
28
29
|
@env, @users, @winning_strategies, @locked = env, {}, {}, false
|
29
30
|
@manager, @config = manager, manager.config.dup
|
30
31
|
@strategies = Hash.new { |h,k| h[k] = {} }
|
32
|
+
end
|
33
|
+
|
34
|
+
# Run the on_request callbacks
|
35
|
+
# :api: private
|
36
|
+
def on_request
|
31
37
|
manager._run_callbacks(:on_request, self)
|
32
38
|
end
|
33
39
|
|
@@ -105,7 +111,7 @@ module Warden
|
|
105
111
|
user
|
106
112
|
end
|
107
113
|
|
108
|
-
# Same API as
|
114
|
+
# Same API as authenticate, but returns a boolean instead of a user.
|
109
115
|
# The difference between this method (authenticate?) and authenticated?
|
110
116
|
# is that the former will run strategies if the user has not yet been
|
111
117
|
# authenticated, and the second relies on already performed ones.
|
@@ -171,7 +177,13 @@ module Warden
|
|
171
177
|
|
172
178
|
if opts[:store] != false && opts[:event] != :fetch
|
173
179
|
options = env[ENV_SESSION_OPTIONS]
|
174
|
-
|
180
|
+
if options
|
181
|
+
if options.frozen?
|
182
|
+
env[ENV_SESSION_OPTIONS] = options.merge(:renew => true).freeze
|
183
|
+
else
|
184
|
+
options[:renew] = true
|
185
|
+
end
|
186
|
+
end
|
175
187
|
session_serializer.store(user, scope)
|
176
188
|
end
|
177
189
|
|
@@ -318,7 +330,7 @@ module Warden
|
|
318
330
|
user = nil
|
319
331
|
|
320
332
|
# Look for an existing user in the session for this scope.
|
321
|
-
# If there was no user in the session
|
333
|
+
# If there was no user in the session, see if we can get one from the request.
|
322
334
|
return user, opts if user = user(opts.merge(:scope => scope))
|
323
335
|
_run_strategies_for(scope, args)
|
324
336
|
|
@@ -353,9 +365,12 @@ module Warden
|
|
353
365
|
(strategies || args).each do |name|
|
354
366
|
strategy = _fetch_strategy(name, scope)
|
355
367
|
next unless strategy && !strategy.performed? && strategy.valid?
|
368
|
+
catch(:warden) do
|
369
|
+
_update_winning_strategy(strategy, scope)
|
370
|
+
end
|
356
371
|
|
357
|
-
self.winning_strategy = @winning_strategies[scope] = strategy
|
358
372
|
strategy._run!
|
373
|
+
_update_winning_strategy(strategy, scope)
|
359
374
|
break if strategy.halted?
|
360
375
|
end
|
361
376
|
end
|
@@ -370,6 +385,11 @@ module Warden
|
|
370
385
|
raise "Invalid strategy #{name}"
|
371
386
|
end
|
372
387
|
end
|
388
|
+
|
389
|
+
# Updates the winning strategy for a given scope
|
390
|
+
def _update_winning_strategy(strategy, scope)
|
391
|
+
self.winning_strategy = @winning_strategies[scope] = strategy
|
392
|
+
end
|
373
393
|
end # Proxy
|
374
394
|
|
375
395
|
end # Warden
|