warden 1.2.6 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +27 -0
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/{History.rdoc → CHANGELOG.md} +76 -38
- data/Gemfile +3 -2
- data/LICENSE +2 -1
- data/README.md +18 -0
- data/Rakefile +4 -8
- data/lib/warden.rb +1 -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 +5 -4
- data/lib/warden/test/warden_helpers.rb +1 -0
- data/lib/warden/version.rb +2 -1
- data/warden.gemspec +19 -18
- metadata +18 -37
- 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 -25
- 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/mock_spec.rb +0 -15
- 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,77 +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
|
+
|
2
25
|
* Separate test helpers to encapsulate Warden object mocking inside it's own class
|
3
26
|
|
4
|
-
|
27
|
+
## Version 1.2.5 / 2016-01-28
|
28
|
+
|
5
29
|
* Expands on the test helpers available to make it easier for testing gems
|
6
30
|
|
7
|
-
|
31
|
+
## Version 1.2.3 / 2013-07-14
|
32
|
+
|
8
33
|
* Fix an issue with lazy loaded sessions
|
9
34
|
|
10
|
-
|
35
|
+
## Version 1.2.2 / 2013-07-12
|
36
|
+
|
11
37
|
* Support nil session stores on logout
|
12
38
|
* Fix strategies blowing up with undefined method base
|
13
39
|
|
14
|
-
|
40
|
+
## Version 1.2.1 / 2012-06-16
|
41
|
+
|
15
42
|
* Minor caching and speed improvements
|
16
43
|
* Add support to #lock in the proxy
|
17
44
|
* Add support to after_failed_fetch callback
|
18
45
|
|
19
|
-
|
46
|
+
## Version 1.2.0 / 2012-05-08
|
47
|
+
|
20
48
|
* Deprecate warden_cookies since it was never functional
|
21
49
|
* Add support to serialize_from_session and serialize_into_session per scope
|
22
50
|
|
23
|
-
|
51
|
+
## Version 1.1.1 / 2012-02-16
|
52
|
+
|
24
53
|
* Allow run_callbacks as an option to set_user and user
|
25
54
|
|
26
|
-
|
55
|
+
## Version 1.1.0 / 2011-11-02
|
56
|
+
|
27
57
|
* Use the default scopes action when using a bare throw(:warden)
|
28
58
|
|
29
|
-
|
59
|
+
## Version 1.0.6
|
60
|
+
|
30
61
|
* Remove gem files from the packaged gem
|
31
62
|
|
32
|
-
|
63
|
+
## Version 1.0.3
|
64
|
+
|
33
65
|
* Do not renew session on user fetch
|
34
66
|
|
35
|
-
|
67
|
+
## Version 1.0.2
|
68
|
+
|
36
69
|
* Added :intercept_401 to Warden::Config
|
37
70
|
|
38
|
-
|
71
|
+
## Version 1.0.1
|
72
|
+
|
39
73
|
* Bug fix on strategies errors handler
|
40
74
|
|
41
|
-
|
75
|
+
## Version 1.0.0
|
76
|
+
|
42
77
|
* Bump!
|
43
78
|
* Allow strategies to configure if user should be stored or not
|
44
79
|
* Force session id renewal when user is set
|
45
80
|
|
46
|
-
|
81
|
+
## Version 0.10.7
|
82
|
+
|
47
83
|
* Performance boost. config object to use raw accessors
|
48
84
|
* Add per strategy storage option
|
49
85
|
|
50
|
-
|
86
|
+
## Version 0.10.6 / 0.10.7 / 2010-05-22
|
87
|
+
|
51
88
|
* Bugfix set_user was not respecting logouts in hooks
|
52
89
|
|
53
|
-
|
90
|
+
## Version 0.10.4 / 0.10.5 / 2010-05-20
|
54
91
|
* Add action specifying in scope_defaults
|
55
92
|
|
56
|
-
|
93
|
+
## Version 0.10.3 / 2010-03-01
|
57
94
|
* Bugfix prevent halted winning strategy from being skipped in subsequent runs
|
58
95
|
|
59
|
-
|
96
|
+
## Version 0.10.2 / 2010-03-26
|
60
97
|
* Halt on fail!. Add fail to allow cascading
|
61
98
|
* cache the winning strategy
|
62
99
|
* Make the config object Dupable
|
63
100
|
|
64
|
-
|
101
|
+
## Version 0.10.1 / 2010-03-23
|
65
102
|
* Merge previous from master
|
66
103
|
* tag
|
67
104
|
|
68
|
-
|
105
|
+
## Version 0.10.0 / 2010-03-22
|
69
106
|
* Allow default strategies to be set on the proxy
|
70
107
|
* Provide each scope with it's own default strategies
|
71
108
|
* Provide each scope with default set_user opts
|
72
109
|
* depricate the Proxy#default_strategies= method
|
73
110
|
|
74
|
-
|
111
|
+
## Version 0.9.5 / 2010-02-28
|
75
112
|
|
76
113
|
* Add Warden.test_mode!
|
77
114
|
* Add Warden.on_next_request
|
@@ -79,42 +116,42 @@
|
|
79
116
|
** login_as
|
80
117
|
** logout
|
81
118
|
|
82
|
-
|
119
|
+
## Version 0.9.4 / 2010-02-23
|
83
120
|
|
84
121
|
* Fix an issue where winning_strategy was not cleaned, allowing multiple scopes to sign in, even when the second one should not
|
85
122
|
|
86
|
-
|
123
|
+
## Version 0.9.3 / 2010-02-17
|
87
124
|
|
88
125
|
* Add prepend_ to all hooks (josevalim)
|
89
126
|
|
90
|
-
|
127
|
+
## Version 0.9.2 / 2010-02-10
|
91
128
|
|
92
129
|
* Ruby 1.9 compatibility changes (grimen)
|
93
130
|
|
94
|
-
|
131
|
+
## Version 0.9.1 / 2010-02-09
|
95
132
|
|
96
133
|
* Support for passing a custom message with Warden::Strategy::Base#success! as second optional (grimen)
|
97
134
|
|
98
|
-
|
135
|
+
## Version 0.9.0 / 2010-01-21
|
99
136
|
|
100
137
|
* Remove serializers and make strategies more powerful, including cache behavior (josevalim)
|
101
138
|
|
102
|
-
|
139
|
+
## Version 0.8.1 / 2010-01-06
|
103
140
|
|
104
141
|
* Fix a bug when silence missing serializers is set (josevalim)
|
105
142
|
|
106
|
-
|
143
|
+
## Version 0.8.0 / 2010-01-06
|
107
144
|
|
108
145
|
* enhancements
|
109
146
|
* Add conditionals to callbacks (josevalim)
|
110
147
|
* Extract Warden::Config from Warden::Manager (josevalim)
|
111
148
|
|
112
|
-
|
149
|
+
## Version 0.7.0 / 2010-01-04
|
113
150
|
|
114
151
|
* enhancements
|
115
152
|
* Expose config in warden proxy (hassox)
|
116
153
|
|
117
|
-
|
154
|
+
## Version 0.6.0 / 2009-11-16
|
118
155
|
|
119
156
|
* enhancements
|
120
157
|
* added serializers, including session serializer (set by default) and a cookie serializer (josevalim)
|
@@ -122,24 +159,27 @@
|
|
122
159
|
* deprecation
|
123
160
|
* serializer_into_session and serializer_from_session are deprecated, overwrite serialize and deserializer in Warden::Serializers::Session instead (josevalim)
|
124
161
|
|
125
|
-
|
162
|
+
## Version 0.5.3 / 2009-11-10
|
163
|
+
|
126
164
|
* bug fixes
|
127
165
|
* authenticated? and unauthenticated? should return true or false, not the user or false. (hassox)
|
128
166
|
|
129
|
-
|
167
|
+
## Version 0.5.2 / 2009-11-09
|
168
|
+
|
130
169
|
* enhancements
|
131
170
|
* authenticated? always try to serialize the user from session (josevalim)
|
132
171
|
* stored_in_session? checks if user information is stored in session, without serializing (josevalim)
|
133
172
|
* 401 behaves exactly like throw :warden (staugaard)
|
134
173
|
|
135
|
-
|
174
|
+
## Version 0.5.1 / 2009-10-25
|
175
|
+
|
136
176
|
* enhancements
|
137
|
-
* Adds
|
177
|
+
* Adds yielding to authenticated? and unauthenticated? methods (hassox)
|
138
178
|
* Adds an option to silence missing strategies (josevalim)
|
139
179
|
* Add an option to authenticate(!) to prevent storage of a user into the session (hassox)
|
140
180
|
* allow custom :action to be thrown (josevalim)
|
141
181
|
|
142
|
-
|
182
|
+
## Version 0.4.0 / 2009-10-12
|
143
183
|
|
144
184
|
* enhancements
|
145
185
|
* add Content-Type header to redirects (staugaard)
|
@@ -148,9 +188,7 @@
|
|
148
188
|
* bug fixes
|
149
189
|
* Do not consume opts twice, otherwise just the first will parse the scope (josevalim)
|
150
190
|
|
151
|
-
|
191
|
+
## Version 0.3.2 / 2009-09-15
|
152
192
|
|
153
193
|
* enhancements
|
154
194
|
* add a hook for plugins to specify how they can clear the whole section
|
155
|
-
|
156
|
-
|
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
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
|