strelka 0.0.1.pre148 → 0.0.1.pre177
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1294 -0
- data/IDEAS.rdoc +6 -0
- data/Manifest.txt +20 -0
- data/README.rdoc +8 -2
- data/Rakefile +9 -7
- data/examples/auth-demo.rb +32 -0
- data/examples/auth-demo2.rb +37 -0
- data/examples/auth-form.tmpl +10 -0
- data/examples/auth-success.tmpl +3 -0
- data/examples/config.yml +12 -0
- data/examples/examples.css +4 -0
- data/examples/examples.html +31 -0
- data/examples/gen-config.rb +5 -2
- data/examples/layout.tmpl +31 -0
- data/lib/strelka/app/auth.rb +480 -0
- data/lib/strelka/app/sessions.rb +8 -6
- data/lib/strelka/app/templating.rb +78 -17
- data/lib/strelka/app.rb +13 -5
- data/lib/strelka/authprovider/basic.rb +134 -0
- data/lib/strelka/authprovider/hostaccess.rb +91 -0
- data/lib/strelka/authprovider.rb +122 -0
- data/lib/strelka/cookie.rb +1 -1
- data/lib/strelka/cookieset.rb +1 -1
- data/lib/strelka/httprequest/auth.rb +31 -0
- data/lib/strelka/logging.rb +69 -14
- data/lib/strelka/mixins.rb +35 -65
- data/lib/strelka/session/db.rb +115 -0
- data/lib/strelka/session/default.rb +38 -49
- data/lib/strelka/session.rb +1 -1
- data/lib/strelka.rb +4 -1
- data/spec/lib/helpers.rb +8 -3
- data/spec/strelka/app/auth_spec.rb +367 -0
- data/spec/strelka/authprovider/basic_spec.rb +192 -0
- data/spec/strelka/authprovider/hostaccess_spec.rb +70 -0
- data/spec/strelka/authprovider_spec.rb +99 -0
- data/spec/strelka/cookie_spec.rb +1 -1
- data/spec/strelka/httprequest/auth_spec.rb +55 -0
- data/spec/strelka/httprequest/session_spec.rb +63 -3
- data/spec/strelka/session/db_spec.rb +85 -0
- data/spec/strelka/session/default_spec.rb +5 -51
- data.tar.gz.sig +0 -0
- metadata +88 -57
- metadata.gz.sig +0 -0
data/IDEAS.rdoc
CHANGED
data/Manifest.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
.gemtest
|
2
|
+
ChangeLog
|
2
3
|
History.rdoc
|
3
4
|
IDEAS.rdoc
|
4
5
|
Manifest.txt
|
@@ -15,11 +16,19 @@ contrib/hoetemplate/data/project/templates/top.tmpl.erb
|
|
15
16
|
contrib/hoetemplate/lib/file_name.rb.erb
|
16
17
|
contrib/hoetemplate/spec/file_name_spec.rb.erb
|
17
18
|
data/strelka/apps/hello-world
|
19
|
+
examples/auth-demo.rb
|
20
|
+
examples/auth-demo2.rb
|
21
|
+
examples/auth-form.tmpl
|
22
|
+
examples/auth-success.tmpl
|
18
23
|
examples/config.yml
|
24
|
+
examples/examples.css
|
25
|
+
examples/examples.html
|
19
26
|
examples/gen-config.rb
|
27
|
+
examples/layout.tmpl
|
20
28
|
examples/sessions-demo.rb
|
21
29
|
lib/strelka.rb
|
22
30
|
lib/strelka/app.rb
|
31
|
+
lib/strelka/app/auth.rb
|
23
32
|
lib/strelka/app/errors.rb
|
24
33
|
lib/strelka/app/filters.rb
|
25
34
|
lib/strelka/app/negotiation.rb
|
@@ -29,6 +38,9 @@ lib/strelka/app/restresources.rb
|
|
29
38
|
lib/strelka/app/routing.rb
|
30
39
|
lib/strelka/app/sessions.rb
|
31
40
|
lib/strelka/app/templating.rb
|
41
|
+
lib/strelka/authprovider.rb
|
42
|
+
lib/strelka/authprovider/basic.rb
|
43
|
+
lib/strelka/authprovider/hostaccess.rb
|
32
44
|
lib/strelka/behavior/plugin.rb
|
33
45
|
lib/strelka/constants.rb
|
34
46
|
lib/strelka/cookie.rb
|
@@ -36,6 +48,7 @@ lib/strelka/cookieset.rb
|
|
36
48
|
lib/strelka/exceptions.rb
|
37
49
|
lib/strelka/httprequest.rb
|
38
50
|
lib/strelka/httprequest/acceptparams.rb
|
51
|
+
lib/strelka/httprequest/auth.rb
|
39
52
|
lib/strelka/httprequest/negotiation.rb
|
40
53
|
lib/strelka/httprequest/session.rb
|
41
54
|
lib/strelka/httpresponse.rb
|
@@ -48,12 +61,14 @@ lib/strelka/router.rb
|
|
48
61
|
lib/strelka/router/default.rb
|
49
62
|
lib/strelka/router/exclusive.rb
|
50
63
|
lib/strelka/session.rb
|
64
|
+
lib/strelka/session/db.rb
|
51
65
|
lib/strelka/session/default.rb
|
52
66
|
spec/data/error.tmpl
|
53
67
|
spec/data/layout.tmpl
|
54
68
|
spec/data/main.tmpl
|
55
69
|
spec/lib/constants.rb
|
56
70
|
spec/lib/helpers.rb
|
71
|
+
spec/strelka/app/auth_spec.rb
|
57
72
|
spec/strelka/app/errors_spec.rb
|
58
73
|
spec/strelka/app/filters_spec.rb
|
59
74
|
spec/strelka/app/negotiation_spec.rb
|
@@ -64,10 +79,14 @@ spec/strelka/app/routing_spec.rb
|
|
64
79
|
spec/strelka/app/sessions_spec.rb
|
65
80
|
spec/strelka/app/templating_spec.rb
|
66
81
|
spec/strelka/app_spec.rb
|
82
|
+
spec/strelka/authprovider/basic_spec.rb
|
83
|
+
spec/strelka/authprovider/hostaccess_spec.rb
|
84
|
+
spec/strelka/authprovider_spec.rb
|
67
85
|
spec/strelka/cookie_spec.rb
|
68
86
|
spec/strelka/cookieset_spec.rb
|
69
87
|
spec/strelka/exceptions_spec.rb
|
70
88
|
spec/strelka/httprequest/acceptparams_spec.rb
|
89
|
+
spec/strelka/httprequest/auth_spec.rb
|
71
90
|
spec/strelka/httprequest/negotiation_spec.rb
|
72
91
|
spec/strelka/httprequest/session_spec.rb
|
73
92
|
spec/strelka/httprequest_spec.rb
|
@@ -79,6 +98,7 @@ spec/strelka/paramvalidator_spec.rb
|
|
79
98
|
spec/strelka/router/default_spec.rb
|
80
99
|
spec/strelka/router/exclusive_spec.rb
|
81
100
|
spec/strelka/router_spec.rb
|
101
|
+
spec/strelka/session/db_spec.rb
|
82
102
|
spec/strelka/session/default_spec.rb
|
83
103
|
spec/strelka/session_spec.rb
|
84
104
|
spec/strelka_spec.rb
|
data/README.rdoc
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
= Strelka
|
1
|
+
= Strelka (Стрелка)
|
2
|
+
|
3
|
+
home :: http://deveiate.org/projects/Strelka
|
4
|
+
code :: http://repo.deveiate.org/Strelka
|
5
|
+
github :: https://github.com/ged/strelka
|
6
|
+
docs :: http://deveiate.org/code/strelka
|
2
7
|
|
3
|
-
* http://deveiate.org/projects/Strelka
|
4
8
|
|
5
9
|
== Description
|
6
10
|
|
@@ -117,6 +121,7 @@ Here's a tentative list of what kinds of stuff we have planned:
|
|
117
121
|
|
118
122
|
=== More Plugins
|
119
123
|
|
124
|
+
* Auth -- authentication framework
|
120
125
|
* CORS -- manage {Cross-Origin Resource Sharing}[http://www.html5rocks.com/en/tutorials/cors/]
|
121
126
|
headers, especially for service applications
|
122
127
|
* caching -- utilities for easy HTTP caching
|
@@ -179,3 +184,4 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
179
184
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
180
185
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
181
186
|
|
187
|
+
|
data/Rakefile
CHANGED
@@ -21,17 +21,19 @@ hoespec = Hoe.spec 'strelka' do
|
|
21
21
|
|
22
22
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
23
23
|
|
24
|
-
self.dependency 'mongrel2', '~> 0.16'
|
25
|
-
self.dependency 'configurability', '~> 1.0'
|
26
|
-
self.dependency 'inversion', '~> 0.2'
|
27
24
|
self.dependency 'trollop', '~> 1.16'
|
28
25
|
self.dependency 'highline', '~> 1.6'
|
29
|
-
self.dependency 'formvalidator', '~> 0.1.5'
|
30
|
-
self.dependency 'uuidtools', '~> 2.1.2'
|
31
26
|
self.dependency 'sysexits', '~> 1.0'
|
32
|
-
self.dependency '
|
27
|
+
self.dependency 'formvalidator', '~> 0.1'
|
28
|
+
self.dependency 'inversion ', '~> 0.8'
|
29
|
+
self.dependency 'mongrel2', '~> 0.20'
|
30
|
+
self.dependency 'uuidtools ', '~> 2.1'
|
31
|
+
self.dependency 'configurability', '~> 1.0'
|
32
|
+
self.dependency 'pluginfactory ', '~> 1.0'
|
33
33
|
|
34
|
-
self.dependency '
|
34
|
+
self.dependency 'hoe-deveiate', '~> 0.1', :developer
|
35
|
+
self.dependency 'hoe-manualgen', '~> 0.3', :developer
|
36
|
+
self.dependency 'simplecov', '~> 0.6', :developer
|
35
37
|
|
36
38
|
self.spec_extras[:licenses] = ["BSD"]
|
37
39
|
self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Strelka Web Application Toolkit']
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
#encoding: utf-8
|
4
|
+
|
5
|
+
require 'strelka'
|
6
|
+
|
7
|
+
class AuthDemo < Strelka::App
|
8
|
+
|
9
|
+
# The Mongrel2 appid of this app
|
10
|
+
ID = 'auth-demo'
|
11
|
+
|
12
|
+
plugins :routing, :auth
|
13
|
+
auth_provider :basic
|
14
|
+
|
15
|
+
### Handle any (authenticated) HTTP request
|
16
|
+
get do |req|
|
17
|
+
res = req.response
|
18
|
+
res.content_type = 'text/plain'
|
19
|
+
res.status = HTTP::OK
|
20
|
+
|
21
|
+
self.log.debug "Authenticated user is: %p" % [ req.authenticated_user ]
|
22
|
+
res.puts "You authenticated successfully (as %p)." % [ req.authenticated_user ]
|
23
|
+
|
24
|
+
return res
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end # class AuthDemo
|
29
|
+
|
30
|
+
|
31
|
+
Strelka.load_config( 'examples/config.yml' )
|
32
|
+
AuthDemo.run
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
#encoding: utf-8
|
4
|
+
|
5
|
+
require 'strelka'
|
6
|
+
|
7
|
+
# Another demo of the :auth plugin, this time implemented as form-based session
|
8
|
+
# auth.
|
9
|
+
|
10
|
+
class AuthDemo2 < Strelka::App
|
11
|
+
|
12
|
+
# The Mongrel2 appid of this app
|
13
|
+
ID = 'auth-demo2'
|
14
|
+
|
15
|
+
plugins :auth, :errors, :templating
|
16
|
+
auth_provider :session
|
17
|
+
|
18
|
+
layout 'examples/layout.tmpl'
|
19
|
+
templates \
|
20
|
+
form: 'examples/auth-form.tmpl',
|
21
|
+
success: 'examples/auth-success.tmpl'
|
22
|
+
|
23
|
+
on_status AUTH_REQUIRED, :form
|
24
|
+
|
25
|
+
|
26
|
+
### Handle any (authenticated) HTTP request
|
27
|
+
def handle_request( req )
|
28
|
+
return :success
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
end # class AuthDemo2
|
33
|
+
|
34
|
+
|
35
|
+
Strelka.load_config( 'examples/config.yml' )
|
36
|
+
AuthDemo2.run
|
37
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<form action="[?call request.uri ?]" method="post" accept-charset="utf-8">
|
2
|
+
<label for="username">Username</label>
|
3
|
+
<input type="text" name="username" value="" id="username-input" />
|
4
|
+
|
5
|
+
<label for="password">Password</label>
|
6
|
+
<input type="password" name="password" value="" id="password-input" />
|
7
|
+
|
8
|
+
<p><input type="submit" value="Login →"></p>
|
9
|
+
</form>
|
10
|
+
|
data/examples/config.yml
CHANGED
@@ -1,3 +1,15 @@
|
|
1
1
|
mongrel2:
|
2
2
|
configdb: examples/mongrel2.sqlite
|
3
3
|
|
4
|
+
auth:
|
5
|
+
realm: Examples
|
6
|
+
users:
|
7
|
+
ged: "iEPX+SQWIR3p67lj/0zigSWTKHg="
|
8
|
+
jblack: "1pAnQNSVtpL1z88QwXV4sG8NMP8="
|
9
|
+
kmurgen: "MZj9+VhZ8C9+aJhmwp+kWBL76Vs="
|
10
|
+
|
11
|
+
sessions:
|
12
|
+
type: default
|
13
|
+
options:
|
14
|
+
cookie-name: "session-demo"
|
15
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
+
|
8
|
+
<title>Strelka Examples</title>
|
9
|
+
|
10
|
+
<link rel="shortcut icon" type="image/png" href="/images/21d1-16.png" />
|
11
|
+
<link rel="stylesheet" href="/examples.css" type="text/css" media="screen"
|
12
|
+
title="no title" charset="utf-8" />
|
13
|
+
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
|
17
|
+
<header>
|
18
|
+
<hgroup>
|
19
|
+
<h1>Strelka Examples</h1>
|
20
|
+
</hgroup>
|
21
|
+
</header>
|
22
|
+
|
23
|
+
<ul>
|
24
|
+
<li><a href="/hello">Hello World</a> - A super-basic handler.</li>
|
25
|
+
<li><a href="/sessions">Sessions Demo</a> - Demo of the <code>:sessions</code> plugin.</li>
|
26
|
+
<li><a href="/auth">Auth Demo</a> - Demo of the <code>:auth</code> plugin.</li>
|
27
|
+
</ul>
|
28
|
+
|
29
|
+
</body>
|
30
|
+
</html>
|
31
|
+
|
data/examples/gen-config.rb
CHANGED
@@ -29,12 +29,15 @@ server 'examples' do
|
|
29
29
|
|
30
30
|
host 'localhost' do
|
31
31
|
|
32
|
-
route '/', directory( '
|
33
|
-
|
32
|
+
route '/', directory( 'examples/', 'examples.html', 'text/html' )
|
33
|
+
|
34
|
+
authdemo = handler( 'tcp://127.0.0.1:9910', 'auth-demo' )
|
34
35
|
|
35
36
|
# Handlers
|
36
37
|
route '/hello', handler( 'tcp://127.0.0.1:9900', 'helloworld-handler' )
|
37
38
|
route '/sessions', handler( 'tcp://127.0.0.1:9905', 'sessions-demo' )
|
39
|
+
route '/auth', authdemo
|
40
|
+
route '/chunkers', authdemo
|
38
41
|
|
39
42
|
end
|
40
43
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title><?subscribe title || Demo ?></title>
|
6
|
+
|
7
|
+
<style type="text/css" media="screen">
|
8
|
+
html {
|
9
|
+
background: #eee;
|
10
|
+
color: #333;
|
11
|
+
margin: 0;
|
12
|
+
padding: 4em 2em;
|
13
|
+
font-family: sans-serif;
|
14
|
+
}
|
15
|
+
</style>
|
16
|
+
</head>
|
17
|
+
<body>
|
18
|
+
|
19
|
+
<header>
|
20
|
+
<h1><?subscribe title || Demo ?></h1>
|
21
|
+
</header>
|
22
|
+
|
23
|
+
<section id="body"><?attr body ?></section>
|
24
|
+
|
25
|
+
<footer>
|
26
|
+
<p>Copyright © 2012, Michael Granger</p>
|
27
|
+
</footer>
|
28
|
+
|
29
|
+
</body>
|
30
|
+
</html>
|
31
|
+
|