Skip to content
Snippets Groups Projects
Commit f85b05b1 authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

automatic language selection, based on Accept-Language HTTP header

parent 58717daa
No related branches found
No related tags found
No related merge requests found
Showing
with 320 additions and 38 deletions
......@@ -9,6 +9,7 @@ use English qw(-no_match_vars);
use Template;
use Log::Any::Adapter;
use List::MoreUtils qw(uniq);
use HTTP::AcceptLanguage;
use AccountManager::Account;
use AccountManager::Account::Manager;
......@@ -134,18 +135,20 @@ sub respond {
version => $self->{configuration}->{app}->{version},
};
my $lang = HTTP::AcceptLanguage->new($ENV{HTTP_ACCEPT_LANGUAGE})->match(qw/en fr/) || 'en';
## Parse template
my $tt2 = Template->new({
INCLUDE_PATH => $self->{configuration}->{_}->{templates_dir}
INCLUDE_PATH => $self->{configuration}->{_}->{templates_dir} . "/web/$lang"
});
my $template;
## nobanner is used to do AJAX to get only pieces of HTML to load in the web client
if ($self->{in}->{style} && $self->{in}->{style} eq 'nobanner') {
$template = 'web/index-nobanner.tt2.html';
$template = 'index-nobanner.tt2.html';
} else {
$template = 'web/index.tt2.html';
$template = 'index.tt2.html';
}
binmode(STDOUT, ":utf8");
......
nobase_templates_DATA = \
accountProfiles/valid-accounts.php.tt2 \
mail/send_authentication_token.tt2.eml \
web/content.tt2.html \
web/errors.tt2.html \
web/home.tt2.html \
web/index.tt2.html \
web/index-nobanner.tt2.html \
web/notices.tt2.html \
web/select_sp.tt2.html \
web/select_email.tt2.html \
web/complete_challenge.tt2.html \
web/create_accounts.tt2.html
web/en/content.tt2.html \
web/en/errors.tt2.html \
web/en/home.tt2.html \
web/en/index.tt2.html \
web/en/index-nobanner.tt2.html \
web/en/notices.tt2.html \
web/en/select_sp.tt2.html \
web/en/select_email.tt2.html \
web/en/complete_challenge.tt2.html \
web/en/create_accounts.tt2.html \
web/fr/content.tt2.html \
web/fr/errors.tt2.html \
web/fr/home.tt2.html \
web/fr/index.tt2.html \
web/fr/index-nobanner.tt2.html \
web/fr/notices.tt2.html \
web/fr/select_sp.tt2.html \
web/fr/select_email.tt2.html \
web/fr/complete_challenge.tt2.html \
web/fr/create_accounts.tt2.html
EXTRA_DIST = $(nobase_templates_DATA)
......@@ -2,35 +2,35 @@
[% IF action == 'select_sp' %]
[% TRY %]
[% PROCESS 'web/select_sp.tt2.html' %]
[% PROCESS 'select_sp.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
[% ELSIF action == 'select_email' %]
[% TRY %]
[% PROCESS 'web/select_email.tt2.html' %]
[% PROCESS 'select_email.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
[% ELSIF action == 'complete_challenge' %]
[% TRY %]
[% PROCESS 'web/complete_challenge.tt2.html' %]
[% PROCESS 'complete_challenge.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
[% ELSIF action == 'create_accounts' %]
[% TRY %]
[% PROCESS 'web/create_accounts.tt2.html' %]
[% PROCESS 'create_accounts.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
[% ELSIF action == 'home' %]
[% TRY %]
[% PROCESS 'web/home.tt2.html' %]
[% PROCESS 'home.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
......
......@@ -55,8 +55,6 @@
[% END %]
</div>
<p><strong>Please keep a record of the above user names and passwords</strong> because currently there is no mecanism to retrieve the above credentials once you close this page. If you forget the username and passwords, you can however request new test accounts.</p>
<div class="alert-box warning radius">
<p>Note that these test accounts will automatically expire in [% accounts_validity_period %] days and that they can only be used to test federated login to your eduGAIN-enabled Service Provider with entityID <strong>[% entityid %]</strong>.</p>
</div>
......
......@@ -2,7 +2,7 @@
[% FOREACH err IN errors %]
<p class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;"><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
Error:
Error:
[% IF err == 'unknown_action' %]
unknown action
......@@ -18,7 +18,7 @@
[% ELSIF err == 'accounts_creation_failed' %]
failed to create your test accounts
[% ELSIF (matches = err.match('missing_(\w+)')) %]
missing parameter '[% matches.0 %]'
......@@ -29,6 +29,6 @@
</p>
<br/>
[% END %] <!-- FOREACH -->
You can report the issue to the administrators (<a href="mailto:[% app.support_email %]>">[% app.support_email %]</a>).
[% END %]
<script type="text/javascript">
$(function() {
$('#start_testing').on('click',function() {
window.location.href='[% app.url %]?action=select_sp';
});
......
......@@ -2,8 +2,8 @@
[% IF errors %]
<div class="ui-widget">
[% PROCESS 'web/errors.tt2.html' %]
[% PROCESS 'errors.tt2.html' %]
</div>
[% ELSE %]
[% PROCESS 'web/content.tt2.html' %]
[% PROCESS 'content.tt2.html' %]
[% END %]
......@@ -39,17 +39,17 @@
[% IF errors %]
<div class="ui-widget">
[% PROCESS 'web/errors.tt2.html' %]
[% PROCESS 'errors.tt2.html' %]
</div>
[% ELSE %]
[% IF notifications %]
<div class="ui-widget">
[% PROCESS 'web/notices.tt2.html' %]
[% PROCESS 'notices.tt2.html' %]
</b>
</div>
[% END %]
[% PROCESS 'web/content.tt2.html' %]
[% PROCESS 'content.tt2.html' %]
[% END %]
</div>
......@@ -62,6 +62,6 @@
<script src="foundation/js/foundation/foundation.tooltip.js"></script>
<script>
$(document).foundation();
</script>
</script>
</body>
</html>
[% FOREACH notif IN notifications %]
<p class="ui-state-highlight ui-corner-all" style="border: 2px solid #10427a; background: #DFF1EE;padding: 0.7em;"><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
Notice:
Notice:
[% IF notif == 'done' %]
......@@ -12,4 +12,4 @@
[% END %]
[% END %] <!-- FOREACH -->
\ No newline at end of file
[% END %] <!-- FOREACH -->
......@@ -3,7 +3,7 @@
jQuery(document).ready(function($){
var form = $("#create-account-form").show();
form.steps({
headerTag: "h3",
bodyTag: "fieldset",
......@@ -61,7 +61,7 @@ jQuery(document).ready(function($){
}
form.validate().settings.ignore = ":disabled,:hidden";
return form.valid();
},
onStepChanged: function (event, currentIndex, priorIndex)
{
......@@ -76,7 +76,7 @@ jQuery(document).ready(function($){
alert("Submitted!");
}
});
form.validate({
errorPlacement: function errorPlacement(error, element) { element.before(error); },
});
......
<h3>Complete email challenge</h3>
<div>
An email challenge including a validation token has been emailed to you at [% email %]. Please copy and paste the validation token in the form below to proof that you are administrator of this service.</div>
<fieldset>
<legend>Validation Token</legend>
<label for="token">Please provide the validation token here:</label>
<input name="token" value="" id="token" type="text" class="required error"/>
<input type="hidden" name="entityid" value="[% entityid %]" id="entityid"/>
<input type="hidden" name="email" value="[% email %]" id="email"/>
</fieldset>
[% IF action == 'select_sp' %]
[% TRY %]
[% PROCESS 'select_sp.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
[% ELSIF action == 'select_email' %]
[% TRY %]
[% PROCESS 'select_email.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
[% ELSIF action == 'complete_challenge' %]
[% TRY %]
[% PROCESS 'complete_challenge.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
[% ELSIF action == 'create_accounts' %]
[% TRY %]
[% PROCESS 'create_accounts.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
[% ELSIF action == 'home' %]
[% TRY %]
[% PROCESS 'home.tt2.html' %]
[% CATCH %]
An error occured
[% END %]
[% ELSE %]
Error: unknown action
[% END %]
<div class="row">
<div class="alert-box success radius">
<strong>Success:</strong> Your identity as administrator of the Service Provider with entityID <strong>[% entityid %]</strong> could successfully be validated!
</div>
<h3>The following test accounts with different profiles were created for you:</h3>
<p>You can now use these test accounts to login at your federated service.<br/>
<strong>To do so, select the "[% idp_displayname %]" when choosing an organisation to login at.</strong></p>
</div>
<div class="accounts_profile">
[% FOREACH account IN accounts %]
<div class="tbl">
<table>
<caption>Account profile: [% account.profile() %]</caption>
<tr>
<th>user name:</th><td> user[% account.id() %]</td>
</tr>
<tr>
<th>user password:</th><td>[% account.password() %]</td>
</tr>
<tr>
<td colspan="2"><strong>comment:</strong><div><p>[% account.comment() %]</p></div></td>
</tr>
<tr>
<td colspan=2 class="align-center" ><button data-reveal-id="account_details_[% account.id() %]" class="show_account_details" id="show_account_details_[% account.id() %]">show account details</button></td>
</tr>
</table>
</div>
<div class="accounts_profile reveal-modal" data-reveal id="account_details_[% account.id() %]"> <!-- old version : class="account_details"-->
<h3>List of user attributes associated</h3>
<p>Below is the list of user attributes associated to this test account. After a successfull authentication process these attributes are transmited
via the SAML protocol from [% app.name %] Identity Provider to your Service Provider.</p>
<div>
<table>
<caption>List of user attributes</caption>
[% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName', 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] -%]
<tr>
<th>[% attribute %]</th><td> [% account.$attribute %]</td>
</tr>
[% END %]
<tr>
<th>eduPersonTargetedID:</th><td><i>value dynamically generated by the SP</i></td>
</tr>
</table>
</div>
<div class="alert-box info radius">If you need a customized test account with additional user attributes, you should contact <a href="mailto:[% app.support_email %]">[% app.support_email %]</a>.</div>
<div>(1) eduPersonAffiliation and eduPersonScoppedAffilisation attributes are assigned quite differently from federation to federation. <a href="http://tnc2010.terena.org/files/ePSA%20comparison%20v0%2006.ppt">This usage comparison of eduPersonAffiliation accross different countries</a> discusses these differences. Therefore its values should be handled with great care.</div>
<a class="close-reveal-modal">&#215;</a>
</div>
[% END %]
</div>
<div class="alert-box warning radius">
<p>Note that these test accounts will automatically expire in [% accounts_validity_period %] days and that they can only be used to test federated login to your eduGAIN-enabled Service Provider with entityID <strong>[% entityid %]</strong>.</p>
</div>
<p class="align-center"><Strong>Thank you for using the [% app.name %]</strong></p>
[% IF errors %]
[% FOREACH err IN errors %]
<p class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;"><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
Error:
[% IF err == 'unknown_action' %]
unknown action
[% ELSIF err == 'internal' %]
internal error; administrators of the federation registry have been notified.
[% ELSIF err == 'wrong_token' %]
the validation token you provided is incorrect or it has already been used
[% ELSIF err == 'wrong_token_for_sp' %]
the validation token you provided cannot be used to obtain test accounts for this service provider ([% entityid %])
[% ELSIF err == 'accounts_creation_failed' %]
failed to create your test accounts
[% ELSIF (matches = err.match('missing_(\w+)')) %]
missing parameter '[% matches.0 %]'
[% ELSE %]
[% err %]
[% END %] <!-- autorisation -->
</p>
<br/>
[% END %] <!-- FOREACH -->
You can report the issue to the administrators (<a href="mailto:[% app.support_email %]>">[% app.support_email %]</a>).
[% END %]
<script type="text/javascript">
$(function() {
$('#start_testing').on('click',function() {
window.location.href='[% app.url %]?action=select_sp';
});
});
</script>
<div class="row">
<h2>[% app.name %]?</h2>
<p>[% app.name %] allows administrators of a Service
Provider (SP) registered in <a href="http://www.geant.net/service/eduGAIN/Pages/home.aspx">eduGAIN</a> to create test
accounts with different profiles to validate the behaviour and test
federated login. The test accounts can only be used to access own services. <a href="presentation.html">Learn more about this service...</a>
</p>
<h3>Start testing your eduGAIN service</h3>
<p>
To start testing your own eduGAIN service, start by selecting the
Service Provider you are administrator for.
</p>
<p class="align-center"><button id="start_testing">Go on testing the service</button></p>
<h3>[% app.name %] basics</h3>
<p>
<br/><img alt="[% app.name %] Basics" src="images/edugain_test_idp_basics.png"/>
</p>
</div>
<DOCTYPE! html>
[% IF errors %]
<div class="ui-widget">
[% PROCESS 'errors.tt2.html' %]
</div>
[% ELSE %]
[% PROCESS 'content.tt2.html' %]
[% END %]
<DOCTYPE! html>
<html lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta charset="utf-8">
<link rel="icon" type="image/png" href="images/favicon.png" />
<link rel="stylesheet" type="text/css" href="foundation/css/foundation.css">
<link rel="stylesheet" type="text/css" href="jquery.steps.css">
<link rel="stylesheet" type="text/css" href="jquery-ui-1.11.1/jquery-ui.min.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.11.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery.validate.1.13.0.min.js"></script>
<script type="text/javascript" src="jquery.cookie-1.4.1.min.js"></script>
<script type="text/javascript" src="jquery.steps.1.1.0.min.js"></script>
<script type="text/javascript" src="account-manager.js"></script>
<title>[% app.name %]</title>
</head>
<body>
<header>
<div class="clearfix">
<a href="http://www.edugain.org" title="eduGAIN home page" target="_blank" class="left"><img alt="eduGAIN logo" width="200" src="images/edugain_logo.png"/></a>
<a href="http://www.geant.net" title="Geant home page" target="_blank" class="right"><img alt="GEANT logo" width="100" src="images/geant_logo_rgb_300dpi.jpg"/></a>
</div>
<div class="title">
<h1>[% app.name %]</h1>
</div>
</header>
<div id="content">
[% IF errors %]
<div class="ui-widget">
[% PROCESS 'errors.tt2.html' %]
</div>
[% ELSE %]
[% IF notifications %]
<div class="ui-widget">
[% PROCESS 'notices.tt2.html' %]
</b>
</div>
[% END %]
[% PROCESS 'content.tt2.html' %]
[% END %]
</div>
<footer>
<span class="align-center">[% app.name %] [% app.version %] - <a href="mailto:[% app.support_email %]">contactez nous</a></span>
</footer>
<script src="foundation/js/foundation.min.js"></script>
<script src="foundation/js/foundation/foundation.tooltip.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>
[% FOREACH notif IN notifications %]
<p class="ui-state-highlight ui-corner-all" style="border: 2px solid #10427a; background: #DFF1EE;padding: 0.7em;"><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
Notice:
[% IF notif == 'done' %]
Operation has been performed
[% ELSE %]
[% notif %]<br/>
[% END %]
[% END %] <!-- FOREACH -->
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment