synapses-cas 0.1.0 → 0.1.1
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/bin/cas_config.yml +595 -0
- data/bin/synapses-cas +1 -2
- data/lib/casserver/authenticators/sql.rb +1 -1
- data/lib/casserver/model.rb +4 -4
- data/lib/casserver/server.rb +17 -10
- data/lib/casserver/views/layout.erb +6 -5
- data/lib/casserver/views/login.erb +36 -27
- data/locales/en.yml +2 -2
- data/locales/pt.yml +3 -3
- data/public/flags/en.png +0 -0
- data/public/flags/es.png +0 -0
- data/public/flags/pt.png +0 -0
- data/public/js/bootstrap.js +1835 -0
- data/public/js/bootstrap.min.js +7 -0
- data/public/js/jquery-1.7.1.min.js +4 -0
- data/public/themes/bootstrap/css/extra.css +34 -0
- data/public/themes/bootstrap/css/theme.css +729 -0
- data/public/themes/{urbacon → bootstrap/img}/bg.png +0 -0
- data/public/themes/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/public/themes/bootstrap/img/glyphicons-halflings.png +0 -0
- data/public/themes/bootstrap/img/logo.png +0 -0
- data/resources/init.d.sh +1 -1
- data/synapses-cas.gemspec +50 -0
- data/tasks/bundler.rake +1 -1
- metadata +17 -26
- data/locales/de.yml +0 -27
- data/locales/es.yml +0 -26
- data/locales/es_ar.yml +0 -26
- data/locales/fr.yml +0 -26
- data/locales/jp.yml +0 -26
- data/locales/pl.yml +0 -26
- data/locales/ru.yml +0 -26
- data/locales/zh.yml +0 -26
- data/locales/zh_tw.yml +0 -26
- data/public/themes/simple/bg.png +0 -0
- data/public/themes/simple/favicon.png +0 -0
- data/public/themes/simple/login_box_bg.png +0 -0
- data/public/themes/simple/logo.png +0 -0
- data/public/themes/simple/theme.css +0 -28
- data/public/themes/urbacon/login_box_bg.png +0 -0
- data/public/themes/urbacon/logo.png +0 -0
- data/public/themes/urbacon/theme.css +0 -33
data/lib/casserver/server.rb
CHANGED
@@ -288,6 +288,8 @@ module CASServer
|
|
288
288
|
init_authenticators!
|
289
289
|
end
|
290
290
|
|
291
|
+
enable :sessions
|
292
|
+
|
291
293
|
before do
|
292
294
|
content_type :html, 'charset' => 'utf-8'
|
293
295
|
@theme = settings.config[:theme]
|
@@ -295,11 +297,16 @@ module CASServer
|
|
295
297
|
@uri_path = settings.config[:uri_path]
|
296
298
|
@infoline = settings.config[:infoline]
|
297
299
|
@custom_views = settings.config[:custom_views]
|
300
|
+
@default_locale = settings.config[:default_locale]
|
298
301
|
@template_engine = settings.config[:template_engine] || :erb
|
299
302
|
if @template_engine != :erb
|
300
303
|
require @template_engine
|
301
304
|
@template_engine = @template_engine.to_sym
|
302
305
|
end
|
306
|
+
|
307
|
+
# Synapses CAS 0.1.1
|
308
|
+
session[:locale] = params[:locale] || session[:locale] || @default_locale
|
309
|
+
|
303
310
|
end
|
304
311
|
|
305
312
|
# The #.#.# comments (e.g. "2.1.3") refer to section numbers in the CAS protocol spec
|
@@ -326,7 +333,7 @@ module CASServer
|
|
326
333
|
end
|
327
334
|
|
328
335
|
if tgt and !tgt_error
|
329
|
-
@message = {:type => '
|
336
|
+
@message = {:type => 'info',
|
330
337
|
:message => t.notice.logged_in_as(tgt.username)}
|
331
338
|
elsif tgt_error
|
332
339
|
$LOG.debug("Ticket granting cookie could not be validated: #{tgt_error}")
|
@@ -335,7 +342,7 @@ module CASServer
|
|
335
342
|
end
|
336
343
|
|
337
344
|
if params['redirection_loop_intercepted']
|
338
|
-
@message = {:type => '
|
345
|
+
@message = {:type => 'error',
|
339
346
|
:message => t.error.unable_to_authenticate}
|
340
347
|
end
|
341
348
|
|
@@ -357,14 +364,14 @@ module CASServer
|
|
357
364
|
end
|
358
365
|
elsif @gateway
|
359
366
|
$LOG.error("This is a gateway request but no service parameter was given!")
|
360
|
-
@message = {:type => '
|
367
|
+
@message = {:type => 'error',
|
361
368
|
:message => t.error.no_service_parameter_given}
|
362
369
|
else
|
363
370
|
$LOG.info("Proceeding with CAS login without a target service.")
|
364
371
|
end
|
365
372
|
rescue URI::InvalidURIError
|
366
373
|
$LOG.error("The service '#{@service}' is not a valid URI!")
|
367
|
-
@message = {:type => '
|
374
|
+
@message = {:type => 'error',
|
368
375
|
:message => t.error.invalid_target_service}
|
369
376
|
end
|
370
377
|
|
@@ -423,7 +430,7 @@ module CASServer
|
|
423
430
|
end
|
424
431
|
|
425
432
|
if error = validate_login_ticket(@lt)
|
426
|
-
@message = {:type => '
|
433
|
+
@message = {:type => 'error', :message => error}
|
427
434
|
# generate another login ticket to allow for re-submitting the form
|
428
435
|
@lt = generate_login_ticket.ticket
|
429
436
|
status 500
|
@@ -475,7 +482,7 @@ module CASServer
|
|
475
482
|
|
476
483
|
if @service.blank?
|
477
484
|
$LOG.info("Successfully authenticated user '#{@username}' at '#{tgt.client_hostname}'. No service param was given, so we will not redirect.")
|
478
|
-
@message = {:type => '
|
485
|
+
@message = {:type => 'success', :message => t.notice.success_logged_in}
|
479
486
|
else
|
480
487
|
@st = generate_service_ticket(@service, @username, tgt)
|
481
488
|
|
@@ -487,21 +494,21 @@ module CASServer
|
|
487
494
|
rescue URI::InvalidURIError
|
488
495
|
$LOG.error("The service '#{@service}' is not a valid URI!")
|
489
496
|
@message = {
|
490
|
-
:type => '
|
497
|
+
:type => 'error',
|
491
498
|
:message => t.error.invalid_target_service
|
492
499
|
}
|
493
500
|
end
|
494
501
|
end
|
495
502
|
else
|
496
503
|
$LOG.warn("Invalid credentials given for user '#{@username}'")
|
497
|
-
@message = {:type => '
|
504
|
+
@message = {:type => 'error', :message => t.error.incorrect_username_or_password}
|
498
505
|
status 401
|
499
506
|
end
|
500
507
|
rescue CASServer::AuthenticatorError => e
|
501
508
|
$LOG.error(e)
|
502
509
|
# generate another login ticket to allow for re-submitting the form
|
503
510
|
@lt = generate_login_ticket.ticket
|
504
|
-
@message = {:type => '
|
511
|
+
@message = {:type => 'error', :message => e.to_s}
|
505
512
|
status 401
|
506
513
|
end
|
507
514
|
|
@@ -560,7 +567,7 @@ module CASServer
|
|
560
567
|
$LOG.warn("User tried to log out without a valid ticket-granting ticket.")
|
561
568
|
end
|
562
569
|
|
563
|
-
@message = {:type => '
|
570
|
+
@message = {:type => 'success', :message => t.notice.success_logged_out}
|
564
571
|
|
565
572
|
@message[:message] += t.notice.click_to_continue if @continue_url
|
566
573
|
|
@@ -1,18 +1,19 @@
|
|
1
1
|
<%# coding: UTF-8 -%>
|
2
|
-
<?xml version="1.0" ?>
|
3
2
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
4
3
|
"XHTML1-s.dtd" >
|
5
4
|
<html xmlns="http://www.w3.org/TR/1999/REC-html-in-xml"
|
6
5
|
xml:lang="en" lang="en" >
|
7
6
|
|
8
7
|
<head>
|
9
|
-
<title><%= escape_html @organization
|
10
|
-
<link rel="stylesheet" type="text/css" href="<%= escape_html @uri_path %>/themes/
|
11
|
-
<link rel="stylesheet" type="text/css" href="<%= escape_html @uri_path %>/themes/<%= escape_html @theme %>/
|
8
|
+
<title><%= escape_html @organization %> <%= t.label.central_login_title %></title>
|
9
|
+
<link rel="stylesheet" type="text/css" href="<%= escape_html @uri_path %>/themes/<%= escape_html @theme %>/css/theme.css" />
|
10
|
+
<link rel="stylesheet" type="text/css" href="<%= escape_html @uri_path %>/themes/<%= escape_html @theme %>/css/extra.css" />
|
12
11
|
<link rel="icon" type="image/png" href="<%= escape_html @uri_path %>/themes/<%= escape_html @theme %>/favicon.png" />
|
12
|
+
<script src="<%= escape_html @uri_path %>/js/jquery-1.7.1.min.js"></script>
|
13
|
+
<script src="<%= escape_html @uri_path %>/js/bootstrap.min.js"></script>
|
13
14
|
</head>
|
14
15
|
|
15
|
-
|
16
|
+
<body>
|
16
17
|
<%= yield %>
|
17
18
|
</body>
|
18
19
|
</html>
|
@@ -1,30 +1,39 @@
|
|
1
1
|
<%# coding: UTF-8 -%>
|
2
|
-
<
|
3
|
-
<
|
4
|
-
<
|
5
|
-
<div
|
6
|
-
<
|
7
|
-
<%=
|
2
|
+
<div class="container">
|
3
|
+
<div class="content">
|
4
|
+
<div class="row">
|
5
|
+
<div class="login-form">
|
6
|
+
<div style="padding-bottom:15px;">
|
7
|
+
<img id="logo" src="<%= escape_html @uri_path %>/themes/<%= @theme %>/img/logo.png"/>
|
8
|
+
</div>
|
9
|
+
<% if @message %>
|
10
|
+
<div class="alert alert-<%= escape_html @message[:type] %>">
|
11
|
+
<button class="close" data-dismiss="alert">×</button>
|
12
|
+
<%= escape_html @message[:message] %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
<form method="post" action="<%= @form_action || "login" %>" id="login-form"
|
16
|
+
onsubmit="submitbutton = document.getElementById('login-submit'); submitbutton.value='<%= t.notice.please_wait %>'; submitbutton.disabled=true; return true;">
|
17
|
+
<fieldset>
|
18
|
+
<div class="clearfix">
|
19
|
+
<input type="text" id="username" name="username" tabindex="1" accesskey="u" placeholder="<%= t.label.username %>"/>
|
20
|
+
</div>
|
21
|
+
<div class="clearfix">
|
22
|
+
<input type="password" id="password" name="password" size="32" tabindex="2" accesskey="p" autocomplete="off" placeholder="<%= t.label.password %>" />
|
23
|
+
</div>
|
24
|
+
<input type="hidden" id="lt" name="lt" value="<%= escape_html @lt %>" />
|
25
|
+
<input type="hidden" id="service" name="service" value="<%= escape_html @service %>" />
|
26
|
+
<input type="submit" accesskey="l" value="<%= t.button.login %>" tabindex="4" id="login-submit" class="btn btn-primary"/>
|
27
|
+
</fieldset>
|
28
|
+
</form>
|
8
29
|
</div>
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<td colspan="2" id="messagebox-container">
|
15
|
-
<div class="messagebox <%= escape_html @message[:type] %>">
|
16
|
-
<%= escape_html @message[:message] %>
|
30
|
+
<div style="text-align:center">
|
31
|
+
<%= @infoline %><br/>
|
32
|
+
<% r18n.available_locales.each do |locale| %>
|
33
|
+
<a href="<%= @uri_path %>/login?locale=<%= locale.code%>"><img src="<%= escape_html @uri_path %>/flags/<%= locale.code %>.png"/></a>
|
34
|
+
<% end %>
|
17
35
|
</div>
|
18
|
-
</
|
19
|
-
</
|
20
|
-
|
21
|
-
|
22
|
-
<tr>
|
23
|
-
<td id="logo-container">
|
24
|
-
<img id="logo" src="<%= escape_html @uri_path %>/themes/<%= @theme %>/logo.png" />
|
25
|
-
</td>
|
26
|
-
<td id="login-form-container">
|
27
|
-
<%= erb(:_login_form, :layout => false) %>
|
28
|
-
</td>
|
29
|
-
</tr>
|
30
|
-
</table>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
<!-- /container -->
|
data/locales/en.yml
CHANGED
data/locales/pt.yml
CHANGED
@@ -11,16 +11,16 @@ error:
|
|
11
11
|
no_service_parameter_given: "O servidor não pode completar a solicitação porque não foi enviado o paramêtro do serviço."
|
12
12
|
|
13
13
|
notice:
|
14
|
-
logged_in_as: "Você está logado como '%1'.
|
14
|
+
logged_in_as: "Você está logado como '%1'."
|
15
15
|
click_to_continue: "Por favor, clique no seguinte link para continuar:"
|
16
16
|
success_logged_out: "Você saiu do sistema com sucesso."
|
17
17
|
success_logged_in: "Login efetuado com sucesso."
|
18
18
|
please_wait: "Aguarde ..."
|
19
19
|
|
20
20
|
label:
|
21
|
-
username: "
|
21
|
+
username: "Email"
|
22
22
|
password: "Senha"
|
23
23
|
central_login_title: "Central de Autenticação"
|
24
24
|
|
25
25
|
button:
|
26
|
-
login: "
|
26
|
+
login: "Entrar"
|
data/public/flags/en.png
ADDED
Binary file
|
data/public/flags/es.png
ADDED
Binary file
|
data/public/flags/pt.png
ADDED
Binary file
|