rack-cerberus 0.1.4 → 0.1.5
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.
- data/README.rdoc +4 -2
- data/cerberus.gemspec +1 -1
- data/cerberus.rb +8 -4
- data/example.ru +1 -1
- data/spec.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -12,7 +12,7 @@ Install with:
|
|
12
12
|
You can use it almost the same way you use <tt>Rack::Auth::Basic</tt>:
|
13
13
|
|
14
14
|
require 'cerberus'
|
15
|
-
use Rack::Session::Cookie
|
15
|
+
use Rack::Session::Cookie, :secret => 'change_me'
|
16
16
|
use Cerberus do |login, pass|
|
17
17
|
pass=='secret'
|
18
18
|
end
|
@@ -58,7 +58,9 @@ If you want to help me, don't hesitate to fork that project on Github or send pa
|
|
58
58
|
0.1.0 Make it possible to authenticate through GET request (for restful APIs)
|
59
59
|
0.1.1 Documentation improvement
|
60
60
|
0.1.2 Raise message when using without session
|
61
|
-
0.1.3
|
61
|
+
0.1.3 Don't go to page /logout when signing in after a logout (redirect to / instead)
|
62
|
+
0.1.4 Fix /logout redirect so that it works with mapping
|
63
|
+
0.1.5 Fix CSS and Javascript for IE (Yes I'm too kind)
|
62
64
|
|
63
65
|
=== Copyright
|
64
66
|
|
data/cerberus.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'rack-cerberus'
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.5"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.summary = "A Rack middleware for form-based authentication"
|
6
6
|
s.description = "A Rack middleware for form-based authentication. Aim is a compromise between fonctionality, beauty and customization."
|
data/cerberus.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
class Cerberus
|
2
2
|
|
3
|
+
class NoSessionError < RuntimeError
|
4
|
+
end
|
5
|
+
|
3
6
|
AUTH_PAGE = <<-PAGE
|
4
7
|
<html><head>
|
5
8
|
<title>%s Authentication</title>
|
6
9
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
10
|
<style type='text/css'>
|
8
|
-
body { background-color: %s; font-family: sans-serif; }
|
11
|
+
body { background-color: %s; font-family: sans-serif; text-align: center; }
|
9
12
|
h1, p { color: %s; }
|
10
13
|
.err {
|
11
14
|
padding: 5px;
|
@@ -16,6 +19,7 @@ class Cerberus
|
|
16
19
|
background-color: red;
|
17
20
|
}
|
18
21
|
div {
|
22
|
+
text-align: left;
|
19
23
|
width: 400px;
|
20
24
|
margin: 30px auto;
|
21
25
|
padding: 10px;
|
@@ -39,10 +43,10 @@ class Cerberus
|
|
39
43
|
<script type="text/javascript" charset="utf-8">
|
40
44
|
var login = document.getElementById('login');
|
41
45
|
var pass = document.getElementById('pass');
|
42
|
-
focus = function() {
|
46
|
+
var focus = function() {
|
43
47
|
if (this.value==this.id) this.value = '';
|
44
48
|
}
|
45
|
-
blur = function() {
|
49
|
+
var blur = function() {
|
46
50
|
if (this.value=='') this.value = this.id;
|
47
51
|
}
|
48
52
|
login.onfocus = focus;
|
@@ -66,7 +70,7 @@ PAGE
|
|
66
70
|
end
|
67
71
|
|
68
72
|
def _call(env)
|
69
|
-
raise 'Cerberus cannot work without Session' if env['rack.session'].nil?
|
73
|
+
raise(NoSessionError, 'Cerberus cannot work without Session') if env['rack.session'].nil?
|
70
74
|
req = Rack::Request.new(env)
|
71
75
|
login = req['cerberus_login']
|
72
76
|
pass = req['cerberus_pass']
|
data/example.ru
CHANGED
data/spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe 'cerberus' do
|
|
16
16
|
should 'Raise if there is no session' do
|
17
17
|
no_session_app = Cerberus.new(secret_app, {}) {|login,pass| [login,pass]==['mario','bros']}
|
18
18
|
no_session_req = Rack::MockRequest.new(no_session_app)
|
19
|
-
lambda { no_session_req.get('/') }.should.raise(
|
19
|
+
lambda { no_session_req.get('/') }.should.raise(Cerberus::NoSessionError).message.should=='Cerberus cannot work without Session'
|
20
20
|
end
|
21
21
|
|
22
22
|
should 'Stop request if you are not already logged in or currently successfully logging' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-cerberus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mickael Riga
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-29 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|