From e16cdcc8a10818dedc98d7059c908d375333c898 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Wed, 5 Dec 2018 17:11:04 +0100 Subject: [PATCH] add organization-filtered list for authenticated users --- lib/AccountManager/App.pm | 20 ++++++++++++++++++++ lib/AccountManager/L10N/fr.pm | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm index b00462e..f017125 100644 --- a/lib/AccountManager/App.pm +++ b/lib/AccountManager/App.pm @@ -256,6 +256,7 @@ sub req_select_sp { my @federations = split(/, */, $self->{configuration}->{federations}->{list}); my %federations; + my @self_entities; foreach my $federation (@federations) { my $file = $self->get_metadata_file(federation => $federation); @@ -275,6 +276,25 @@ sub req_select_sp { label => $self->{configuration}->{$federation}->{label}, entities => $entities }; + + # if user is authenticated, and its IdP is found in metadata, + # push all entities with the same organization URL in a list + if ($ENV{HTTP_SHIB_IDENTITY_PROVIDER}) { + my $idp = $metadata->parse(entityid => $ENV{HTTP_SHIB_IDENTITY_PROVIDER}); + if ($idp) { + my $organization = $idp->organization(); + push @self_entities, + grep { $_->{organization} eq $organization } + @$entities; + } + } + } + + if (@self_entities) { + $federations{self} = { + label => $self->{lh}->maketext("My organization"), + entities => \@self_entities, + }; } $self->respond( diff --git a/lib/AccountManager/L10N/fr.pm b/lib/AccountManager/L10N/fr.pm index d0cdcc9..1a085a5 100644 --- a/lib/AccountManager/L10N/fr.pm +++ b/lib/AccountManager/L10N/fr.pm @@ -117,6 +117,10 @@ msgstr "Liste des attributs utilisateur" msgid "More information" msgstr "Plus d'information" +#: lib/AccountManager/App.pm:295 +msgid "My organization" +msgstr "Mon organisme" + #: templates/web/edugain/complete_challenge.tt2.html:29 templates/web/edugain/select_email.tt2.html:38 templates/web/edugain/select_sp.tt2.html:37 templates/web/renater/complete_challenge.tt2.html:29 templates/web/renater/select_email.tt2.html:38 templates/web/renater/select_sp.tt2.html:37 msgid "Next" msgstr "Suivant" -- GitLab