alex-sinatra_warden 0.3.0.1 → 0.3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/alex-sinatra_warden.gemspec +2 -2
- data/lib/sinatra_warden/sinatra.rb +1 -0
- data/spec/fixtures/testing_login.rb +14 -1
- data/spec/sinatra_warden_spec.rb +12 -13
- data/spec/spec_helper.rb +15 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.0.
|
1
|
+
0.3.0.2
|
data/alex-sinatra_warden.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{alex-sinatra_warden}
|
8
|
-
s.version = "0.3.0.
|
8
|
+
s.version = "0.3.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Smestad", "Daniel Neighman"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-25}
|
13
13
|
s.description = %q{basic helpers and authentication methods for using warden with sinatra also providing some hooks into Rack::Flash}
|
14
14
|
s.email = %q{justin.smestad@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -87,6 +87,7 @@ module Sinatra
|
|
87
87
|
|
88
88
|
app.post '/unauthenticated/?' do
|
89
89
|
status 401
|
90
|
+
warden.custom_failure! if warden.config.failure_app == self.class
|
90
91
|
env['x-rack.flash'][:error] = options.auth_error_message if defined?(Rack::Flash)
|
91
92
|
options.auth_use_erb ? erb(options.auth_login_template) : haml(options.auth_login_template)
|
92
93
|
end
|
@@ -52,4 +52,17 @@ end
|
|
52
52
|
|
53
53
|
class TestingLoginWithReferrer < TestingLogin
|
54
54
|
set :auth_use_referrer, true
|
55
|
-
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class TestingLoginAsRackApp < TestingLogin
|
58
|
+
use Rack::Session::Cookie
|
59
|
+
use Warden::Manager do |manager|
|
60
|
+
manager.default_strategies :password
|
61
|
+
manager.failure_app = TestingLoginAsRackApp
|
62
|
+
manager.serialize_into_session { |user| user.id }
|
63
|
+
manager.serialize_from_session { |id| User.get(id) }
|
64
|
+
end
|
65
|
+
use Rack::Flash
|
66
|
+
|
67
|
+
set :auth_failure_path, '/login'
|
68
|
+
end
|
data/spec/sinatra_warden_spec.rb
CHANGED
@@ -45,19 +45,7 @@ describe "Sinatra::Warden" do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
context "when auth_use_referrer is set to true" do
|
48
|
-
def app
|
49
|
-
Rack::Builder.app do
|
50
|
-
use Rack::Session::Cookie
|
51
|
-
use Warden::Manager do |manager|
|
52
|
-
manager.default_strategies :password
|
53
|
-
manager.failure_app = TestingLogin
|
54
|
-
manager.serialize_into_session { |user| user.id }
|
55
|
-
manager.serialize_from_session { |id| User.get(id) }
|
56
|
-
end
|
57
|
-
use Rack::Flash
|
58
|
-
run TestingLoginWithReferrer
|
59
|
-
end
|
60
|
-
end
|
48
|
+
def app; app_with_referrer; end
|
61
49
|
|
62
50
|
it "should store referrer in user's session" do
|
63
51
|
get '/dashboard'
|
@@ -87,6 +75,17 @@ describe "Sinatra::Warden" do
|
|
87
75
|
last_request.path.should == '/welcome'
|
88
76
|
end
|
89
77
|
end
|
78
|
+
|
79
|
+
context "TestingLoginAsRackApp" do
|
80
|
+
def app; @app ||= TestingLoginAsRackApp; end
|
81
|
+
|
82
|
+
# what happens here is you'll eventually get
|
83
|
+
# "stack too deep" error if the following test fails
|
84
|
+
it "should not get in a loop" do
|
85
|
+
post '/login', :email => 'bad', :password => 'password'
|
86
|
+
last_request.path.should == '/unauthenticated'
|
87
|
+
end
|
88
|
+
end
|
90
89
|
end
|
91
90
|
|
92
91
|
context "the helpers" do
|
data/spec/spec_helper.rb
CHANGED
@@ -23,8 +23,21 @@ Spec::Runner.configure do |config|
|
|
23
23
|
DataMapper.auto_migrate!
|
24
24
|
end
|
25
25
|
|
26
|
+
# default app
|
26
27
|
def app
|
27
|
-
@app ||=
|
28
|
+
@app ||= define_app TestingLogin
|
29
|
+
end
|
30
|
+
|
31
|
+
# app with auth_use_referrer enabled
|
32
|
+
def app_with_referrer
|
33
|
+
@app ||= define_app TestingLoginWithReferrer
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# :which should be a sinatra app
|
39
|
+
def define_app(which)
|
40
|
+
Rack::Builder.app do
|
28
41
|
use Rack::Session::Cookie
|
29
42
|
use Warden::Manager do |manager|
|
30
43
|
manager.default_strategies :password
|
@@ -33,7 +46,7 @@ Spec::Runner.configure do |config|
|
|
33
46
|
manager.serialize_from_session { |id| User.get(id) }
|
34
47
|
end
|
35
48
|
use Rack::Flash
|
36
|
-
run
|
49
|
+
run which
|
37
50
|
end
|
38
51
|
end
|
39
52
|
end
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.3.0.
|
9
|
+
- 2
|
10
|
+
version: 0.3.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Smestad
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-04-
|
19
|
+
date: 2010-04-25 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|