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
data/lib/warden/strategies.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
module Warden
|
3
4
|
module Strategies
|
4
5
|
# A strategy is a place where you can put logic related to authentication. Any strategy inherits
|
@@ -44,6 +45,7 @@ module Warden
|
|
44
45
|
@env, @scope = env, scope
|
45
46
|
@status, @headers = nil, {}
|
46
47
|
@halted, @performed = false, false
|
48
|
+
@result = nil
|
47
49
|
end
|
48
50
|
|
49
51
|
# The method that is called from above. This method calls the underlying authenticate! method
|
@@ -157,7 +159,7 @@ module Warden
|
|
157
159
|
def redirect!(url, params = {}, opts = {})
|
158
160
|
halt!
|
159
161
|
@status = opts[:permanent] ? 301 : 302
|
160
|
-
headers["Location"] = url
|
162
|
+
headers["Location"] = url.dup
|
161
163
|
headers["Location"] << "?" << Rack::Utils.build_query(params) unless params.empty?
|
162
164
|
headers["Content-Type"] = opts[:content_type] || 'text/plain'
|
163
165
|
|
data/lib/warden/test/helpers.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Warden
|
4
5
|
module Test
|
@@ -6,7 +7,7 @@ module Warden
|
|
6
7
|
# These provide the ability to login and logout on any given request
|
7
8
|
# Note: During the teardown phase of your specs you should include: Warden.test_reset!
|
8
9
|
module Helpers
|
9
|
-
def self.included(
|
10
|
+
def self.included(_base)
|
10
11
|
::Warden.test_mode!
|
11
12
|
end
|
12
13
|
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'rack'
|
5
|
+
|
6
|
+
module Warden
|
7
|
+
module Test
|
8
|
+
# A mock of an application to get a Warden object to test on
|
9
|
+
# Note: During the teardown phase of your specs you should include: Warden.test_reset!
|
10
|
+
module Mock
|
11
|
+
def self.included(_base)
|
12
|
+
::Warden.test_mode!
|
13
|
+
end
|
14
|
+
|
15
|
+
# A helper method that provides the warden object by mocking the env variable.
|
16
|
+
# @api public
|
17
|
+
def warden
|
18
|
+
@warden ||= begin
|
19
|
+
env['warden']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def env
|
26
|
+
@env ||= begin
|
27
|
+
request = Rack::MockRequest.env_for(
|
28
|
+
"/?#{Rack::Utils.build_query({})}",
|
29
|
+
{ 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => 'GET' }
|
30
|
+
)
|
31
|
+
app.call(request)
|
32
|
+
|
33
|
+
request
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def app
|
38
|
+
@app ||= begin
|
39
|
+
opts = {
|
40
|
+
failure_app: lambda { |_e|
|
41
|
+
[401, { 'Content-Type' => 'text/plain' }, ['You Fail!']]
|
42
|
+
},
|
43
|
+
default_strategies: :password,
|
44
|
+
default_serializers: :session
|
45
|
+
}
|
46
|
+
Rack::Builder.new do
|
47
|
+
use Warden::Test::Mock::Session
|
48
|
+
use Warden::Manager, opts, &proc {}
|
49
|
+
run lambda { |_e|
|
50
|
+
[200, { 'Content-Type' => 'text/plain' }, ['You Win']]
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Session
|
57
|
+
attr_accessor :app
|
58
|
+
def initialize(app, _configs={})
|
59
|
+
@app = app
|
60
|
+
end
|
61
|
+
|
62
|
+
def call(e)
|
63
|
+
e['rack.session'] ||= {}
|
64
|
+
@app.call(e)
|
65
|
+
end
|
66
|
+
end # session
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/warden/version.rb
CHANGED
data/warden.gemspec
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
|
4
|
+
lib = File.expand_path("../lib", __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'warden/version'
|
4
7
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "warden"
|
10
|
+
spec.version = Warden::VERSION
|
11
|
+
spec.authors = ["Daniel Neighman", "Justin Smestad", "Whitney Smestad", "José Valim"]
|
12
|
+
spec.email = %q{hasox.sox@gmail.com justin.smestad@gmail.com whitcolorado@gmail.com}
|
13
|
+
spec.homepage = "https://github.com/hassox/warden"
|
14
|
+
spec.summary = "An authentication library compatible with all Rack-based frameworks"
|
15
|
+
spec.license = "MIT"
|
16
|
+
spec.extra_rdoc_files = [
|
12
17
|
"LICENSE",
|
13
|
-
|
18
|
+
"README.md"
|
14
19
|
]
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
s.rubygems_version = %q{1.3.7}
|
21
|
-
s.summary = %q{Rack middleware that provides authentication for rack applications}
|
22
|
-
s.add_dependency "rack", ">= 1.0"
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
21
|
+
f.match(%r{^(test|spec|features)/})
|
22
|
+
end
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
spec.add_dependency "rack", ">= 2.0.9"
|
23
25
|
end
|
24
|
-
|
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.
|
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:
|
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:
|
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:
|
29
|
+
version: 2.0.9
|
27
30
|
description:
|
28
|
-
email:
|
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.
|
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.
|
44
|
+
- README.md
|
39
45
|
- Rakefile
|
40
46
|
- lib/warden.rb
|
41
47
|
- lib/warden/config.rb
|
@@ -48,37 +54,16 @@ files:
|
|
48
54
|
- lib/warden/strategies.rb
|
49
55
|
- lib/warden/strategies/base.rb
|
50
56
|
- lib/warden/test/helpers.rb
|
57
|
+
- lib/warden/test/mock.rb
|
51
58
|
- lib/warden/test/warden_helpers.rb
|
52
59
|
- lib/warden/version.rb
|
53
|
-
- spec/helpers/request_helper.rb
|
54
|
-
- spec/helpers/strategies/fail_with_user.rb
|
55
|
-
- spec/helpers/strategies/failz.rb
|
56
|
-
- spec/helpers/strategies/invalid.rb
|
57
|
-
- spec/helpers/strategies/pass.rb
|
58
|
-
- spec/helpers/strategies/pass_with_message.rb
|
59
|
-
- spec/helpers/strategies/password.rb
|
60
|
-
- spec/helpers/strategies/single.rb
|
61
|
-
- spec/spec_helper.rb
|
62
|
-
- spec/warden/authenticated_data_store_spec.rb
|
63
|
-
- spec/warden/config_spec.rb
|
64
|
-
- spec/warden/errors_spec.rb
|
65
|
-
- spec/warden/hooks_spec.rb
|
66
|
-
- spec/warden/manager_spec.rb
|
67
|
-
- spec/warden/proxy_spec.rb
|
68
|
-
- spec/warden/scoped_session_serializer.rb
|
69
|
-
- spec/warden/session_serializer_spec.rb
|
70
|
-
- spec/warden/strategies/base_spec.rb
|
71
|
-
- spec/warden/strategies_spec.rb
|
72
|
-
- spec/warden/test/helpers_spec.rb
|
73
|
-
- spec/warden/test/test_mode_spec.rb
|
74
60
|
- warden.gemspec
|
75
|
-
homepage:
|
61
|
+
homepage: https://github.com/hassox/warden
|
76
62
|
licenses:
|
77
63
|
- MIT
|
78
64
|
metadata: {}
|
79
65
|
post_install_message:
|
80
|
-
rdoc_options:
|
81
|
-
- "--charset=UTF-8"
|
66
|
+
rdoc_options: []
|
82
67
|
require_paths:
|
83
68
|
- lib
|
84
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -92,9 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
77
|
- !ruby/object:Gem::Version
|
93
78
|
version: '0'
|
94
79
|
requirements: []
|
95
|
-
|
96
|
-
rubygems_version: 2.4.5.1
|
80
|
+
rubygems_version: 3.1.2
|
97
81
|
signing_key:
|
98
82
|
specification_version: 4
|
99
|
-
summary:
|
83
|
+
summary: An authentication library compatible with all Rack-based frameworks
|
100
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,51 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Warden::Spec
|
3
|
-
module Helpers
|
4
|
-
FAILURE_APP = lambda{|e|[401, {"Content-Type" => "text/plain"}, ["You Fail!"]] }
|
5
|
-
|
6
|
-
def env_with_params(path = "/", params = {}, env = {})
|
7
|
-
method = params.delete(:method) || "GET"
|
8
|
-
env = { 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => "#{method}" }.merge(env)
|
9
|
-
Rack::MockRequest.env_for("#{path}?#{Rack::Utils.build_query(params)}", env)
|
10
|
-
end
|
11
|
-
|
12
|
-
def setup_rack(app = nil, opts = {}, &block)
|
13
|
-
app ||= block if block_given?
|
14
|
-
|
15
|
-
opts[:failure_app] ||= failure_app
|
16
|
-
opts[:default_strategies] ||= [:password]
|
17
|
-
opts[:default_serializers] ||= [:session]
|
18
|
-
blk = opts[:configurator] || proc{}
|
19
|
-
|
20
|
-
Rack::Builder.new do
|
21
|
-
use opts[:session] || Warden::Spec::Helpers::Session unless opts[:nil_session]
|
22
|
-
use Warden::Manager, opts, &blk
|
23
|
-
run app
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def valid_response
|
28
|
-
Rack::Response.new("OK").finish
|
29
|
-
end
|
30
|
-
|
31
|
-
def failure_app
|
32
|
-
Warden::Spec::Helpers::FAILURE_APP
|
33
|
-
end
|
34
|
-
|
35
|
-
def success_app
|
36
|
-
lambda{|e| [200, {"Content-Type" => "text/plain"}, ["You Win"]]}
|
37
|
-
end
|
38
|
-
|
39
|
-
class Session
|
40
|
-
attr_accessor :app
|
41
|
-
def initialize(app,configs = {})
|
42
|
-
@app = app
|
43
|
-
end
|
44
|
-
|
45
|
-
def call(e)
|
46
|
-
e['rack.session'] ||= {}
|
47
|
-
@app.call(e)
|
48
|
-
end
|
49
|
-
end # session
|
50
|
-
end
|
51
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
Warden::Strategies.add(:pass_with_message) do
|
3
|
-
def authenticate!
|
4
|
-
request.env['warden.spec.strategies'] ||= []
|
5
|
-
request.env['warden.spec.strategies'] << :pass_with_message
|
6
|
-
success!("Valid User", "The Success Strategy Has Accepted You") unless scope == :failz
|
7
|
-
end
|
8
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
Warden::Strategies.add(:password) do
|
3
|
-
def authenticate!
|
4
|
-
request.env['warden.spec.strategies'] ||= []
|
5
|
-
request.env['warden.spec.strategies'] << :password
|
6
|
-
if params["password"] || params["username"]
|
7
|
-
params["password"] == "sekrit" && params["username"] == "fred" ?
|
8
|
-
success!("Authenticated User") : fail!("Username or password is incorrect")
|
9
|
-
else
|
10
|
-
pass
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
$TESTING=true
|
3
|
-
|
4
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
5
|
-
$:.unshift File.expand_path(File.join(File.dirname(__FILE__)))
|
6
|
-
require 'warden'
|
7
|
-
|
8
|
-
require 'rubygems'
|
9
|
-
require 'rack'
|
10
|
-
|
11
|
-
Dir[File.join(File.dirname(__FILE__), "helpers", "**/*.rb")].each do |f|
|
12
|
-
require f
|
13
|
-
end
|
14
|
-
|
15
|
-
RSpec.configure do |config|
|
16
|
-
config.include(Warden::Spec::Helpers)
|
17
|
-
config.include(Warden::Test::Helpers)
|
18
|
-
|
19
|
-
def load_strategies
|
20
|
-
Dir[File.join(File.dirname(__FILE__), "helpers", "strategies", "**/*.rb")].each do |f|
|
21
|
-
load f
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|