Skip to content
Snippets Groups Projects
Commit 2e59dff7 authored by renater.salaun's avatar renater.salaun
Browse files

Fix verification of input parameters + create errors and notices templates

git-svn-id: https://svn.geant.net/GEANT/edugain_testidp_account_manager/trunk@12 047e039d-479c-447e-8a29-aa6bf4a09bab
parent 0ea81de7
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ my $domains_regex = '[\w\.\-]+(,[\w\.\-]+)*';
my %format = (
## URL
#'attributeauthority' => $url_regex,
'sp_entityid' => $urn_or_url_regex,
);
my %actions = ('select_sp' => {'title_en' => 'Select your Service Provider' },
......@@ -50,6 +51,8 @@ package WebRequest;
sub new {
my $pkg = shift;
my $request = {};
&IdPAccountManager::Tools::do_log('info', "");
my $http_query = new CGI;
......@@ -117,7 +120,7 @@ sub execute {
my $status;
## Check input parameters format
foreach my $key (keys %{$request->{'param_in'}}) {
foreach my $key (keys %{$self->{'param_in'}}) {
if ($self->{'param_in'}{$key} !~ /^\s*$/ &&
defined $format{$key} &&
! ref($format{$key})) {
......@@ -222,7 +225,8 @@ sub respond {
## Return the list of known SPs
sub req_get_sp_list {
my $self = shift;
&IdPAccountManager::Tools::do_log('info', "");
my $federation_metadata = new IdPAccountManager::SAMLMetadata;
unless ($federation_metadata->load(federation_metadata_file_path => $IdPAccountManager::Conf::global{'federation_metadata_file_path'})) {
push @{$self->{'param_out'}{'errors'}}, "internal";
......@@ -245,6 +249,7 @@ sub req_get_sp_list {
## Sample URL : https://dev-edugain.renater.fr/accountmanager?action=select_sp&sp_entityid=http%3A%2F%2Fsp.lat.csc.fi
sub req_select_sp {
my $self = shift;
&IdPAccountManager::Tools::do_log('info', "");
unless ($self->{'param_in'}{'sp_entityid'}) {
push @{$self->{'param_out'}{'errors'}}, "missing_sp_entityid";
......
......@@ -131,7 +131,7 @@ sub do_log {
my $ip = $ENV{'REMOTE_HOST'}.'/'.$ENV{'REMOTE_ADDR'} || 'NOIP';
my $date = POSIX::strftime ("%Y:%m:%d %H:%M:%S", localtime(time));
my $user = lc($ENV{'mail'}) || 'NOEMAIL';
open TMP, ">>".$IdPAccountManager::Conf::global{'log_file'}; printf TMP "$date - ($level) - $ip - $user - $caller_string $message\n", @_; close TMP;
open LOG, ">>".$IdPAccountManager::Conf::global{'log_file'}; printf LOG "$date - ($level) - $ip - $user - $caller_string $message\n", @_; close LOG;
}
return 1;
}
......
[% 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 (matches = err.match('missing_(\w+)')) %]
missing parameter '[% matches.0 %]'
[% ELSE %]
[% err %]
[% END %] <!-- autorisation -->
</p>
<br/>
[% END %] <!-- FOREACH -->
......@@ -87,48 +87,14 @@ div.important{border-style:solid;border-color:black;border-width:1px;background-
[% IF errors %]
<div class="ui-widget">
[% 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 (matches = err.match('missing_(\w+)')) %]
missing parameter '[% matches.0 %]'
[% ELSE %]
[% err %]
[% END %] <!-- autorisation -->
</p>
<br/>
[% END %] <!-- FOREACH -->
[% PROCESS 'templates/web/errors.tt2.html' %]
</div>
[% ELSE %]
[% IF notifications %]
<div class="ui-widget">
[% 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 -->
[% PROCESS 'templates/web/notices.tt2.html' %]
</b></div>
[% END %] <!-- notifications -->
......
[% 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 -->
\ No newline at end of file
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