diff --git a/conf/manager.conf.in b/conf/manager.conf.in index d95e7c380242e00d3b1a29b32544cb546249bc32..922fe20f9d844b8ccf32a36ff25fc916927da5f8 100644 --- a/conf/manager.conf.in +++ b/conf/manager.conf.in @@ -11,12 +11,23 @@ templates_dir = @templatesdir@ templates_theme = edugain accounts_file = /var/lib/access-check/accounts.php -[federations] -list = edugain +[groups] +list = self, renater, edugain + +[self] +type = organization +label = my own organization + +[renater] +type = metadata +file = /var/lib/access-check/renater.xml +label = fédération Education-Recherche [edugain] -metadata = /var/lib/access-check/edugain.xml +type = link +url = https://access-check.edugain.org label = eduGAIN +message = eduGAIN Access Check [logger] file = /var/log/access-check/manager.log diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm index 41d689b308abc9771ec8c66e4eb2116bfe7715ff..f7af532142b8c3d7138d035964e1b063aff7e8e2 100644 --- a/lib/AccountManager/App.pm +++ b/lib/AccountManager/App.pm @@ -112,7 +112,7 @@ sub new { ); } - if (!$self->{configuration}->{federations}->{list}) { + if (!$self->{configuration}->{groups}->{list}) { $self->{logger}->fatal( "No federations defined in configuration, aborting" ); @@ -202,8 +202,6 @@ sub respond { $theme_templates_dir : $default_templates_dir; - $Template::Stash::PRIVATE = undef; - my $tt2 = Template->new({ ENCODING => 'utf8', PRE_CHOMP => CHOMP_ONE, @@ -255,18 +253,17 @@ sub req_select_sp { $self->check_authentication(action => 'select_sp') if $self->{configuration}->{app}->{login_url}; - my @federations = split(/, */, $self->{configuration}->{federations}->{list}); - my @groups; - my @self_entities; - foreach my $federation (@federations) { - if ($self->{configuration}->{$federation}->{metadata}) { - my $file = $self->get_metadata_file(federation => $federation); + my @organization_entities; + + foreach my $id (split(/, */, $self->{configuration}->{groups}->{list})) { + my $spec = $self->{configuration}->{$id}; + if ($spec->{type} eq 'metadata') { my $metadata; eval { $metadata = AccountManager::Metadata->new( - file => $file + file => $spec->{file} ); }; $self->abort( @@ -276,13 +273,14 @@ sub req_select_sp { my $entities = $metadata->parse(type => 'sp'); push @groups, { - id => $federation, - label => $self->{configuration}->{$federation}->{label}, + id => $id, + label => $spec->{label}, + type => 'list', entities => [ map { { id => $_->{entityid}, name => $_->{display_name}, - federation => $federation + federation => $id } } @$entities ] }; @@ -297,36 +295,37 @@ sub req_select_sp { $self->{logger}->debugf( "idp %s found in federation %s metadata with organization %s", $ENV{HTTP_SHIB_IDENTITY_PROVIDER}, - $federation, + $id, $organization ); - push @self_entities, + push @organization_entities, map { { id => $_->{entityid}, name => $_->{display_name}, - federation => $federation + federation => $id } } grep { $_->{organization} eq $organization } @$entities; } } - } elsif ($self->{configuration}->{$federation}->{link}) { + } elsif ($spec->{type} eq 'organization') { + push @groups, { + id => $id, + label => $spec->{label}, + type => 'list', + entities => \@organization_entities, + }; + } elsif ($spec->{type} eq 'link') { push @groups, { - id => $federation, - label => $self->{configuration}->{$federation}->{label}, - link => $self->{configuration}->{$federation}->{link}, + id => $id, + label => $spec->{label}, + type => 'link', + url => $spec->{url}, + message => $spec->{message}, }; } } - if (@self_entities) { - unshift @groups, { - id => '_self', - label => $self->{lh}->maketext("My organization"), - entities => \@self_entities, - }; - } - $self->respond( template => 'select_sp.tt2.html', data => { diff --git a/templates/web/edugain/select_sp.tt2.html b/templates/web/edugain/select_sp.tt2.html index b6e4eb87f90415c6034e2017414d5da289a4d383..49a16a3bdb12effc9563f8f4c6a6c7d1d33c70f9 100644 --- a/templates/web/edugain/select_sp.tt2.html +++ b/templates/web/edugain/select_sp.tt2.html @@ -15,22 +15,22 @@ [% lh.maketext("You must be an administrator of that service to continue afterwards.") %] </p> - [% FOREACH group IN groups() %] +[% FOREACH group IN groups() %] <fieldset> - [% IF group.entities %] <legend>[% group.label %]</legend> + [% SWITCH group.type %] + [% CASE 'list' %] <select id="[% group.id %]" name="[% group.id %]"> <option value=""></option> [% FOREACH entity IN group.entities.sort('name') %] <option value="[% entity.id %]" data-federation="[% entity.federation %]">[% entity.name %]</option> [% END %] </select> - [% END %] - [% IF group.link %] - <a class="button" href="[% group.link %]">[% group.label %]</a> - [% END %] + [% CASE 'link' %] + <a class="button" href="[% group.url %]">[% group.label %]</a> + [% END %] </fieldset> - [% END %] +[% END %] <input type="hidden" id="federation" name="federation"/> <input type="hidden" id="entityid" name="entityid"/> diff --git a/templates/web/renater/select_sp.tt2.html b/templates/web/renater/select_sp.tt2.html index 0f682a93c75c3470ed0c970cf42e07948b61aee4..b1226edadc25f69c43d4124abadb4cd61b8696d4 100644 --- a/templates/web/renater/select_sp.tt2.html +++ b/templates/web/renater/select_sp.tt2.html @@ -15,22 +15,22 @@ [% lh.maketext("You must be an administrator of that service to continue afterwards.") %] </p> - [% FOREACH group IN groups %] +[% FOREACH group IN groups %] <fieldset> - [% IF group.entities %] <legend>[% group.label %]</legend> + [% SWITCH group.type %] + [% CASE 'list' %] <select id="[% group.id %]" name="[% group.id %]"> <option value=""></option> [% FOREACH entity IN group.entities.sort('name') %] <option value="[% entity.id %]" data-federation="[% entity.federation %]">[% entity.name %]</option> [% END %] </select> - [% END %] - [% IF group.link %] - <a class="button" href="[% group.link %]">[% group.label %]</a> - [% END %] + [% CASE 'link' %] + <a class="button" href="[% group.url %]">[% group.message %]</a> + [% END %] </fieldset> - [% END %] +[% END %] <input type="hidden" id="federation" name="federation"/> <input type="hidden" id="entityid" name="entityid"/>