clavem 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis-gemfile +2 -1
- data/.travis.yml +1 -2
- data/Gemfile +3 -2
- data/README.md +13 -6
- data/Rakefile +1 -1
- data/bin/clavem +29 -18
- data/clavem.gemspec +5 -4
- data/doc/Clavem.html +6 -6
- data/doc/Clavem/Authorizer.html +1141 -2216
- data/doc/Clavem/Exceptions.html +4 -4
- data/doc/Clavem/Exceptions/Failure.html +5 -5
- data/doc/Clavem/Server.html +370 -0
- data/doc/Clavem/Version.html +5 -5
- data/doc/_index.html +8 -15
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +21 -14
- data/doc/frames.html +1 -1
- data/doc/index.html +21 -14
- data/doc/method_list.html +32 -14
- data/doc/top-level-namespace.html +3 -3
- data/lib/clavem.rb +4 -3
- data/lib/clavem/authorizer.rb +75 -121
- data/lib/clavem/server.rb +52 -0
- data/lib/clavem/version.rb +3 -3
- data/locales/en.yml +15 -6
- data/locales/it.yml +15 -6
- data/spec/clavem/authorizer_spec.rb +86 -244
- data/spec/clavem/server_spec.rb +40 -0
- data/spec/coverage_helper.rb +2 -2
- data/spec/spec_helper.rb +2 -1
- data/test_server.rb +28 -10
- metadata +32 -27
- data/doc/Clavem/Exceptions/AuthorizationDenied.html +0 -133
- data/doc/Clavem/Exceptions/Timeout.html +0 -133
- data/doc/index.html.save +0 -133
- data/lib/clavem/template.html.erb +0 -25
data/doc/Clavem/Exceptions.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Clavem::Exceptions
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.7
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -100,7 +100,7 @@
|
|
100
100
|
|
101
101
|
|
102
102
|
|
103
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Exceptions/
|
103
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Exceptions/Failure.html" title="Clavem::Exceptions::Failure (class)">Failure</a></span>
|
104
104
|
|
105
105
|
|
106
106
|
</p>
|
@@ -116,9 +116,9 @@
|
|
116
116
|
</div>
|
117
117
|
|
118
118
|
<div id="footer">
|
119
|
-
Generated on
|
119
|
+
Generated on Wed Aug 21 16:17:53 2013 by
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
121
|
-
0.8.
|
121
|
+
0.8.7 (ruby-2.0.0).
|
122
122
|
</div>
|
123
123
|
|
124
124
|
</body>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Exception: Clavem::Exceptions::Failure
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.7
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -73,12 +73,12 @@
|
|
73
73
|
|
74
74
|
<dt class="r1">Inherits:</dt>
|
75
75
|
<dd class="r1">
|
76
|
-
<span class="inheritName">
|
76
|
+
<span class="inheritName">StandardError</span>
|
77
77
|
|
78
78
|
<ul class="fullTree">
|
79
79
|
<li>Object</li>
|
80
80
|
|
81
|
-
<li class="next">
|
81
|
+
<li class="next">StandardError</li>
|
82
82
|
|
83
83
|
<li class="next">Clavem::Exceptions::Failure</li>
|
84
84
|
|
@@ -124,9 +124,9 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Wed Aug 21 16:17:53 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
|
-
0.8.
|
129
|
+
0.8.7 (ruby-2.0.0).
|
130
130
|
</div>
|
131
131
|
|
132
132
|
</body>
|
@@ -0,0 +1,370 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: Clavem::Server
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../_index.html">Index (S)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../Clavem.html" title="Clavem (module)">Clavem</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Server</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: Clavem::Server
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">EM::Connection</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">EM::Connection</li>
|
82
|
+
|
83
|
+
<li class="next">Clavem::Server</li>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
<a href="#" class="inheritanceTree">show all</a>
|
87
|
+
|
88
|
+
</dd>
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dt class="r2">Includes:</dt>
|
96
|
+
<dd class="r2">EM::HttpServer</dd>
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
<dt class="r1 last">Defined in:</dt>
|
103
|
+
<dd class="r1 last">lib/clavem/server.rb</dd>
|
104
|
+
|
105
|
+
</dl>
|
106
|
+
<div class="clear"></div>
|
107
|
+
|
108
|
+
<h2>Overview</h2><div class="docstring">
|
109
|
+
<div class="discussion">
|
110
|
+
<p>A class to handle oAuth callbacks on the browser via HTTP.</p>
|
111
|
+
|
112
|
+
|
113
|
+
</div>
|
114
|
+
</div>
|
115
|
+
<div class="tags">
|
116
|
+
|
117
|
+
|
118
|
+
</div>
|
119
|
+
<h2>Constant Summary</h2>
|
120
|
+
|
121
|
+
<dl class="constants">
|
122
|
+
|
123
|
+
<dt id="TEMPLATE-constant" class="">TEMPLATE =
|
124
|
+
<div class="docstring">
|
125
|
+
<div class="discussion">
|
126
|
+
<p>The template to send to the browser.</p>
|
127
|
+
|
128
|
+
|
129
|
+
</div>
|
130
|
+
</div>
|
131
|
+
<div class="tags">
|
132
|
+
|
133
|
+
|
134
|
+
</div>
|
135
|
+
</dt>
|
136
|
+
<dd><pre class="code"><span class='heredoc_beg'><<-EOTEMPLATE</span>
|
137
|
+
<span class='tstring_content'><html>
|
138
|
+
<head>
|
139
|
+
<title>Clavem</title>
|
140
|
+
<script type="text/javascript"> close_window = (function(){ window.open("", "_self", ""); window.close(); })(); </script>
|
141
|
+
</head>
|
142
|
+
<body><h4>%s</h4></body>
|
143
|
+
</html>
|
144
|
+
</span><span class='heredoc_end'>EOTEMPLATE</span></pre></dd>
|
145
|
+
|
146
|
+
</dl>
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
<h2>
|
157
|
+
Instance Method Summary
|
158
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
159
|
+
</h2>
|
160
|
+
|
161
|
+
<ul class="summary">
|
162
|
+
|
163
|
+
<li class="public ">
|
164
|
+
<span class="summary_signature">
|
165
|
+
|
166
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Server) <strong>initialize</strong>(authorizer) </a>
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
</span>
|
171
|
+
|
172
|
+
|
173
|
+
<span class="note title constructor">constructor</span>
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
<span class="summary_desc"><div class='inline'><p>Creates a new server.</p>
|
183
|
+
</div></span>
|
184
|
+
|
185
|
+
</li>
|
186
|
+
|
187
|
+
|
188
|
+
<li class="public ">
|
189
|
+
<span class="summary_signature">
|
190
|
+
|
191
|
+
<a href="#process_http_request-instance_method" title="#process_http_request (instance method)">- (Object) <strong>process_http_request</strong> </a>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
</span>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
<span class="summary_desc"><div class='inline'><p>Save the token and sends a response back to the user.</p>
|
206
|
+
</div></span>
|
207
|
+
|
208
|
+
</li>
|
209
|
+
|
210
|
+
|
211
|
+
</ul>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
<div id="constructor_details" class="method_details_list">
|
217
|
+
<h2>Constructor Details</h2>
|
218
|
+
|
219
|
+
<div class="method_details first">
|
220
|
+
<h3 class="signature first" id="initialize-instance_method">
|
221
|
+
|
222
|
+
- (<tt><span class='object_link'><a href="" title="Clavem::Server (class)">Server</a></span></tt>) <strong>initialize</strong>(authorizer)
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
</h3><div class="docstring">
|
229
|
+
<div class="discussion">
|
230
|
+
<p>Creates a new server.</p>
|
231
|
+
|
232
|
+
|
233
|
+
</div>
|
234
|
+
</div>
|
235
|
+
<div class="tags">
|
236
|
+
<p class="tag_title">Parameters:</p>
|
237
|
+
<ul class="param">
|
238
|
+
|
239
|
+
<li>
|
240
|
+
|
241
|
+
<span class='name'>authorizer</span>
|
242
|
+
|
243
|
+
|
244
|
+
<span class='type'>(<tt><span class='object_link'><a href="Authorizer.html" title="Clavem::Authorizer (class)">Authorizer</a></span></tt>)</span>
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
—
|
249
|
+
<div class='inline'><p>The authorizer of this server.</p>
|
250
|
+
</div>
|
251
|
+
|
252
|
+
</li>
|
253
|
+
|
254
|
+
</ul>
|
255
|
+
|
256
|
+
|
257
|
+
</div><table class="source_code">
|
258
|
+
<tr>
|
259
|
+
<td>
|
260
|
+
<pre class="lines">
|
261
|
+
|
262
|
+
|
263
|
+
26
|
264
|
+
27
|
265
|
+
28</pre>
|
266
|
+
</td>
|
267
|
+
<td>
|
268
|
+
<pre class="code"><span class="info file"># File 'lib/clavem/server.rb', line 26</span>
|
269
|
+
|
270
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_authorizer'>authorizer</span><span class='rparen'>)</span>
|
271
|
+
<span class='ivar'>@authorizer</span> <span class='op'>=</span> <span class='id identifier rubyid_authorizer'>authorizer</span>
|
272
|
+
<span class='kw'>end</span></pre>
|
273
|
+
</td>
|
274
|
+
</tr>
|
275
|
+
</table>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
</div>
|
279
|
+
|
280
|
+
|
281
|
+
<div id="instance_method_details" class="method_details_list">
|
282
|
+
<h2>Instance Method Details</h2>
|
283
|
+
|
284
|
+
|
285
|
+
<div class="method_details first">
|
286
|
+
<h3 class="signature first" id="process_http_request-instance_method">
|
287
|
+
|
288
|
+
- (<tt>Object</tt>) <strong>process_http_request</strong>
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
</h3><div class="docstring">
|
295
|
+
<div class="discussion">
|
296
|
+
<p>Save the token and sends a response back to the user.</p>
|
297
|
+
|
298
|
+
|
299
|
+
</div>
|
300
|
+
</div>
|
301
|
+
<div class="tags">
|
302
|
+
|
303
|
+
|
304
|
+
</div><table class="source_code">
|
305
|
+
<tr>
|
306
|
+
<td>
|
307
|
+
<pre class="lines">
|
308
|
+
|
309
|
+
|
310
|
+
31
|
311
|
+
32
|
312
|
+
33
|
313
|
+
34
|
314
|
+
35
|
315
|
+
36
|
316
|
+
37
|
317
|
+
38
|
318
|
+
39
|
319
|
+
40
|
320
|
+
41
|
321
|
+
42
|
322
|
+
43
|
323
|
+
44
|
324
|
+
45
|
325
|
+
46
|
326
|
+
47
|
327
|
+
48
|
328
|
+
49
|
329
|
+
50</pre>
|
330
|
+
</td>
|
331
|
+
<td>
|
332
|
+
<pre class="code"><span class="info file"># File 'lib/clavem/server.rb', line 31</span>
|
333
|
+
|
334
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_process_http_request'>process_http_request</span>
|
335
|
+
<span class='comment'># Handle the token
|
336
|
+
</span> <span class='id identifier rubyid_token'>token</span> <span class='op'>=</span> <span class='ivar'>@authorizer</span><span class='period'>.</span><span class='id identifier rubyid_response_handler'>response_handler</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='const'>CGI</span><span class='op'>::</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='ivar'>@http_query_string</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
337
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_token'>token</span> <span class='kw'>then</span>
|
338
|
+
<span class='ivar'>@authorizer</span><span class='period'>.</span><span class='id identifier rubyid_token'>token</span> <span class='op'>=</span> <span class='id identifier rubyid_token'>token</span>
|
339
|
+
<span class='ivar'>@authorizer</span><span class='period'>.</span><span class='id identifier rubyid_status'>status</span> <span class='op'>=</span> <span class='symbol'>:succeeded</span>
|
340
|
+
<span class='kw'>else</span>
|
341
|
+
<span class='ivar'>@authorizer</span><span class='period'>.</span><span class='id identifier rubyid_status'>status</span> <span class='op'>=</span> <span class='symbol'>:denied</span>
|
342
|
+
<span class='kw'>end</span>
|
343
|
+
|
344
|
+
<span class='comment'># Build the request
|
345
|
+
</span> <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='const'>EM</span><span class='op'>::</span><span class='const'>DelegatedHttpResponse</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
|
346
|
+
<span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_status'>status</span> <span class='op'>=</span> <span class='int'>200</span>
|
347
|
+
<span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_content_type'>content_type</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>text/html</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
348
|
+
<span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='const'>TEMPLATE</span> <span class='op'>%</span> <span class='lbracket'>[</span><span class='ivar'>@authorizer</span><span class='period'>.</span><span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_template'>template</span><span class='rbracket'>]</span>
|
349
|
+
<span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_send_response'>send_response</span>
|
350
|
+
|
351
|
+
<span class='comment'># Stop after serving the request.
|
352
|
+
</span> <span class='const'>EM</span><span class='period'>.</span><span class='id identifier rubyid_add_timer'>add_timer</span><span class='lparen'>(</span><span class='float'>0.1</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='const'>EM</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span> <span class='rbrace'>}</span>
|
353
|
+
<span class='kw'>end</span></pre>
|
354
|
+
</td>
|
355
|
+
</tr>
|
356
|
+
</table>
|
357
|
+
</div>
|
358
|
+
|
359
|
+
</div>
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
<div id="footer">
|
364
|
+
Generated on Wed Aug 21 16:17:53 2013 by
|
365
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
366
|
+
0.8.7 (ruby-2.0.0).
|
367
|
+
</div>
|
368
|
+
|
369
|
+
</body>
|
370
|
+
</html>
|
data/doc/Clavem/Version.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Clavem::Version
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.7
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -119,7 +119,7 @@
|
|
119
119
|
|
120
120
|
</div>
|
121
121
|
</dt>
|
122
|
-
<dd><pre class="code"><span class='int'>
|
122
|
+
<dd><pre class="code"><span class='int'>2</span></pre></dd>
|
123
123
|
|
124
124
|
<dt id="MINOR-constant" class="">MINOR =
|
125
125
|
<div class="docstring">
|
@@ -134,7 +134,7 @@
|
|
134
134
|
|
135
135
|
</div>
|
136
136
|
</dt>
|
137
|
-
<dd><pre class="code"><span class='int'>
|
137
|
+
<dd><pre class="code"><span class='int'>0</span></pre></dd>
|
138
138
|
|
139
139
|
<dt id="PATCH-constant" class="">PATCH =
|
140
140
|
<div class="docstring">
|
@@ -180,9 +180,9 @@
|
|
180
180
|
</div>
|
181
181
|
|
182
182
|
<div id="footer">
|
183
|
-
Generated on
|
183
|
+
Generated on Wed Aug 21 16:17:53 2013 by
|
184
184
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
185
|
-
0.8.
|
185
|
+
0.8.7 (ruby-2.0.0).
|
186
186
|
</div>
|
187
187
|
|
188
188
|
</body>
|