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.
Files changed (42) hide show
  1. data/bin/cas_config.yml +595 -0
  2. data/bin/synapses-cas +1 -2
  3. data/lib/casserver/authenticators/sql.rb +1 -1
  4. data/lib/casserver/model.rb +4 -4
  5. data/lib/casserver/server.rb +17 -10
  6. data/lib/casserver/views/layout.erb +6 -5
  7. data/lib/casserver/views/login.erb +36 -27
  8. data/locales/en.yml +2 -2
  9. data/locales/pt.yml +3 -3
  10. data/public/flags/en.png +0 -0
  11. data/public/flags/es.png +0 -0
  12. data/public/flags/pt.png +0 -0
  13. data/public/js/bootstrap.js +1835 -0
  14. data/public/js/bootstrap.min.js +7 -0
  15. data/public/js/jquery-1.7.1.min.js +4 -0
  16. data/public/themes/bootstrap/css/extra.css +34 -0
  17. data/public/themes/bootstrap/css/theme.css +729 -0
  18. data/public/themes/{urbacon → bootstrap/img}/bg.png +0 -0
  19. data/public/themes/bootstrap/img/glyphicons-halflings-white.png +0 -0
  20. data/public/themes/bootstrap/img/glyphicons-halflings.png +0 -0
  21. data/public/themes/bootstrap/img/logo.png +0 -0
  22. data/resources/init.d.sh +1 -1
  23. data/synapses-cas.gemspec +50 -0
  24. data/tasks/bundler.rake +1 -1
  25. metadata +17 -26
  26. data/locales/de.yml +0 -27
  27. data/locales/es.yml +0 -26
  28. data/locales/es_ar.yml +0 -26
  29. data/locales/fr.yml +0 -26
  30. data/locales/jp.yml +0 -26
  31. data/locales/pl.yml +0 -26
  32. data/locales/ru.yml +0 -26
  33. data/locales/zh.yml +0 -26
  34. data/locales/zh_tw.yml +0 -26
  35. data/public/themes/simple/bg.png +0 -0
  36. data/public/themes/simple/favicon.png +0 -0
  37. data/public/themes/simple/login_box_bg.png +0 -0
  38. data/public/themes/simple/logo.png +0 -0
  39. data/public/themes/simple/theme.css +0 -28
  40. data/public/themes/urbacon/login_box_bg.png +0 -0
  41. data/public/themes/urbacon/logo.png +0 -0
  42. data/public/themes/urbacon/theme.css +0 -33
@@ -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 => 'notice',
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 => 'mistake',
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 => 'mistake',
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 => 'mistake',
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 => 'mistake', :message => error}
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 => 'confirmation', :message => t.notice.success_logged_in}
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 => 'mistake',
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 => 'mistake', :message => t.error.incorrect_username_or_password}
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 => 'mistake', :message => e.to_s}
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 => 'confirmation', :message => t.notice.success_logged_out}
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 %><%= t.label.central_login_title %></title>
10
- <link rel="stylesheet" type="text/css" href="<%= escape_html @uri_path %>/themes/cas.css" />
11
- <link rel="stylesheet" type="text/css" href="<%= escape_html @uri_path %>/themes/<%= escape_html @theme %>/theme.css" />
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
- <body onload="if (document.getElementById('username')) document.getElementById('username').focus()">
16
+ <body>
16
17
  <%= yield %>
17
18
  </body>
18
19
  </html>
@@ -1,30 +1,39 @@
1
1
  <%# coding: UTF-8 -%>
2
- <table id="login-box">
3
- <tr>
4
- <td colspan="2">
5
- <div id="headline-container">
6
- <strong><%= escape_html @organization %></strong>
7
- <%= t.label.central_login_title %>
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
- </td>
10
- </tr>
11
-
12
- <% if @message %>
13
- <tr>
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
- </td>
19
- </tr>
20
- <% end %>
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
@@ -18,9 +18,9 @@ notice:
18
18
  please_wait: "Please wait..."
19
19
 
20
20
  label:
21
- username: "Username"
21
+ username: "Email"
22
22
  password: "Password"
23
23
  central_login_title: "Central Login"
24
24
 
25
25
  button:
26
- login: "LOGIN"
26
+ login: "Login"
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'. Se este não for você, Por favor, faça o login a baixo."
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: "Usuário"
21
+ username: "Email"
22
22
  password: "Senha"
23
23
  central_login_title: "Central de Autenticação"
24
24
 
25
25
  button:
26
- login: "ENTRAR"
26
+ login: "Entrar"
Binary file
Binary file
Binary file