From 7f2be3eab58f883eea03ef2acdc4b26441a4001e Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Wed, 5 Dec 2018 15:54:14 +0100
Subject: [PATCH] skip explicit federation selection step

and allow user to select a service provider from multiple lists
---
 conf/manager.conf.in                          |  1 -
 lib/AccountManager/App.pm                     | 90 ++++++-------------
 lib/AccountManager/L10N/fr.pm                 | 71 +++++++--------
 templates/Makefile.am                         |  2 -
 .../web/edugain/complete_challenge.tt2.html   |  3 +-
 .../web/edugain/create_accounts.tt2.html      |  2 +-
 templates/web/edugain/home.tt2.html           |  2 +-
 templates/web/edugain/select_email.tt2.html   |  3 +-
 .../web/edugain/select_federation.tt2.html    | 38 --------
 templates/web/edugain/select_sp.tt2.html      | 44 ++++++---
 .../web/renater/complete_challenge.tt2.html   |  3 +-
 .../web/renater/create_accounts.tt2.html      |  2 +-
 templates/web/renater/home.tt2.html           |  2 +-
 templates/web/renater/select_email.tt2.html   |  3 +-
 .../web/renater/select_federation.tt2.html    | 38 --------
 templates/web/renater/select_sp.tt2.html      | 44 ++++++---
 16 files changed, 128 insertions(+), 220 deletions(-)
 delete mode 100644 templates/web/edugain/select_federation.tt2.html
 delete mode 100644 templates/web/renater/select_federation.tt2.html

diff --git a/conf/manager.conf.in b/conf/manager.conf.in
index 3b13b32..d95e7c3 100644
--- a/conf/manager.conf.in
+++ b/conf/manager.conf.in
@@ -13,7 +13,6 @@ accounts_file = /var/lib/access-check/accounts.php
 
 [federations]
 list = edugain
-merge = 0
 
 [edugain]
 metadata = /var/lib/access-check/edugain.xml
diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index 6ea6c2e..b00462e 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -35,7 +35,6 @@ my %patterns = (
 
 my %actions = (
     home               => 'req_home',
-    select_federation  => 'req_select_federation',
     select_sp          => 'req_select_sp',
     select_email       => 'req_select_email',
     complete_challenge => 'req_complete_challenge',
@@ -247,34 +246,6 @@ sub abort {
     );
 }
 
-sub req_select_federation {
-    my ($self, %args) = @_;
-
-    $self->check_authentication(action => 'select_federation')
-        if $self->{configuration}->{app}->{login_url};
-
-    my $federations = $self->{configuration}->{federations}->{list};
-    my @federations = split(/, */, $federations);
-
-    # skip this step if there is only one federation,
-    # or if no explicit distinction is required
-    if (
-        @federations == 1 ||
-        $self->{configuration}->{federations}->{merge}
-    ) {
-        $self->req_select_sp();
-    }
-
-    my %federations = map { $_ => $self->{configuration}->{$_}->{label} } @federations;
-
-    $self->respond(
-        template => 'select_federation.tt2.html',
-        data     => {
-            action      => 'select_federation',
-            federations => \%federations
-        }
-    );
-}
 
 sub req_select_sp {
     my ($self, %args) = @_;
@@ -282,14 +253,10 @@ sub req_select_sp {
     $self->check_authentication(action => 'select_sp')
         if $self->{configuration}->{app}->{login_url};
 
-    my $federation  = $self->{cgi}->param('federation'); # not mandatory
-
-    my @federations = $federation ?
-        $federation :
-        split(/, */, $self->{configuration}->{federations}->{list});
+    my @federations = split(/, */, $self->{configuration}->{federations}->{list});
 
-    my @entities;
-    foreach $federation (@federations) {
+    my %federations;
+    foreach my $federation (@federations) {
         my $file = $self->get_metadata_file(federation => $federation);
 
         my $metadata;
@@ -304,15 +271,17 @@ sub req_select_sp {
         ) if $EVAL_ERROR;
 
         my $entities = $metadata->parse(type => 'sp');
-        push @entities, @$entities;
+        $federations{$federation} = {
+            label    => $self->{configuration}->{$federation}->{label},
+            entities => $entities
+        };
     }
 
     $self->respond(
         template => 'select_sp.tt2.html',
         data     => {
-            action     => 'select_sp',
-            entities   => \@entities,
-            federation => $federation,
+            action      => 'select_sp',
+            federations => \%federations,
         }
     );
 }
@@ -324,7 +293,7 @@ sub req_select_email {
         if $self->{configuration}->{app}->{login_url};
 
     my $entityid   = $self->get_parameter(name => 'entityid');
-    my $federation = $self->{cgi}->param('federation'); # not mandatory
+    my $federation = $self->get_parameter(name => 'federation');
 
     # Create a persistent service provider object
     my $sp = AccountManager::ServiceProvider->new(
@@ -336,29 +305,22 @@ sub req_select_email {
         # already present in DB, nothing todo
     } else {
         # extract information from metadata
-        my @federations = $federation ?
-            $federation :
-            split(/, */, $self->{configuration}->{federations}->{list});
-
-        my $entity;
-        foreach $federation (@federations) {
-            my $file = $self->get_metadata_file(federation => $federation);
-            my $metadata;
-
-            eval {
-                $metadata = AccountManager::Metadata->new(
-                    file => $file
-                );
-            };
-            $self->abort(
-                log  => "Failed to load federation metadata: $EVAL_ERROR",
-                user => "internal"
-            ) if $EVAL_ERROR;
-
-            my $entities = $metadata->parse(id => $entityid);
-            $entity = $entities->[0];
-            last if $entity;
-        }
+        my $file = $self->get_metadata_file(federation => $federation);
+        my $metadata;
+
+        eval {
+            $metadata = AccountManager::Metadata->new(
+                file => $file
+            );
+        };
+        $self->abort(
+            log  => "Failed to load federation metadata: $EVAL_ERROR",
+            user => "internal"
+        ) if $EVAL_ERROR;
+
+        my $entities = $metadata->parse(id => $entityid);
+        my $entity = $entities->[0];
+
         $self->abort(
             log  => "No such SP $entityid in metadata",
             user => "no_such_entity"
diff --git a/lib/AccountManager/L10N/fr.pm b/lib/AccountManager/L10N/fr.pm
index 5aad649..d0cdcc9 100644
--- a/lib/AccountManager/L10N/fr.pm
+++ b/lib/AccountManager/L10N/fr.pm
@@ -49,7 +49,7 @@ msgid "All rights reserved"
 msgstr "Tous droits réservés"
 
 #. (email)
-#: templates/web/edugain/complete_challenge.tt2.html:15 templates/web/renater/complete_challenge.tt2.html:15
+#: templates/web/edugain/complete_challenge.tt2.html:14 templates/web/renater/complete_challenge.tt2.html:14
 msgid "An email challenge including a validation token has been emailed to you at %1."
 msgstr "Un message incluant un code de validation vous a été envoyé à %1."
 
@@ -58,7 +58,7 @@ msgid "As part of the GÉANT 2020 Framework Partnership Agreement (FPA), this pr
 msgstr "En tant que membre de l'accord GÉANT 2020 Framework Partnership Agreement (FPA), ce projet bénéficie d'un financement du programme de recherche de l'Union Européenne Horizon 2020 sous l'agrément No. 731122 (GN4-2)."
 
 #. (sp.displayname)
-#: templates/web/edugain/select_email.tt2.html:14 templates/web/renater/select_email.tt2.html:14
+#: templates/web/edugain/select_email.tt2.html:13 templates/web/renater/select_email.tt2.html:13
 msgid "Before you can create test accounts at this Identity Provider, we need to ensure you are a legitimate administrator of '%1'."
 msgstr "Avant de pouvoir créer des comptes de test sur ce fournisseur d'identité, nous devons nous assurer que vous êtes un administateur légitime de '%1'."
 
@@ -71,7 +71,7 @@ msgstr "Voici la liste des attributs utilisateur associés à ce compte de test.
 msgid "Challenge URL: %1"
 msgstr "URL du challenge: %1"
 
-#: templates/web/edugain/complete_challenge.tt2.html:13 templates/web/edugain/complete_challenge.tt2.html:8 templates/web/edugain/select_email.tt2.html:8 templates/web/edugain/select_federation.tt2.html:8 templates/web/edugain/select_sp.tt2.html:8 templates/web/renater/complete_challenge.tt2.html:13 templates/web/renater/complete_challenge.tt2.html:8 templates/web/renater/select_email.tt2.html:8 templates/web/renater/select_federation.tt2.html:8 templates/web/renater/select_sp.tt2.html:8
+#: templates/web/edugain/complete_challenge.tt2.html:12 templates/web/edugain/complete_challenge.tt2.html:7 templates/web/edugain/select_email.tt2.html:7 templates/web/edugain/select_sp.tt2.html:7 templates/web/renater/complete_challenge.tt2.html:12 templates/web/renater/complete_challenge.tt2.html:7 templates/web/renater/select_email.tt2.html:7 templates/web/renater/select_sp.tt2.html:7
 msgid "Complete email challenge"
 msgstr "Validez le challenge e-mail"
 
@@ -117,11 +117,11 @@ msgstr "Liste des attributs utilisateur"
 msgid "More information"
 msgstr "Plus d'information"
 
-#: templates/web/edugain/complete_challenge.tt2.html:30 templates/web/edugain/select_email.tt2.html:39 templates/web/edugain/select_federation.tt2.html:28 templates/web/edugain/select_sp.tt2.html:35 templates/web/renater/complete_challenge.tt2.html:30 templates/web/renater/select_email.tt2.html:39 templates/web/renater/select_federation.tt2.html:28 templates/web/renater/select_sp.tt2.html:35
+#: 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"
 
-#: templates/web/edugain/select_email.tt2.html:31 templates/web/renater/select_email.tt2.html:31
+#: templates/web/edugain/select_email.tt2.html:30 templates/web/renater/select_email.tt2.html:30
 msgid "No ContactPerson element could be found in your service metadata, therefore we are unable to provide test accounts for this service."
 msgstr "Aucun élément ContactPerson n'a pu être trouvées das les métadonnées de votre fournisseur de service, c'est pourquoi nous sommes incapable de fournir des comptes de test pour ce service."
 
@@ -134,23 +134,23 @@ msgstr "Veuillez noter que ces comptes de test expirent automatiquement dans %1
 msgid "Objective"
 msgstr "Objectif"
 
-#: templates/web/edugain/select_email.tt2.html:32 templates/web/renater/select_email.tt2.html:32
+#: templates/web/edugain/select_email.tt2.html:31 templates/web/renater/select_email.tt2.html:31
 msgid "Please contact your federation administrators to add needed information to the metadata."
 msgstr "Veuillez contacter les administrateurs de votre fédération pour ajouter les informations nécessaires aux métadonnées."
 
-#: templates/web/edugain/complete_challenge.tt2.html:16 templates/web/renater/complete_challenge.tt2.html:16
+#: templates/web/edugain/complete_challenge.tt2.html:15 templates/web/renater/complete_challenge.tt2.html:15
 msgid "Please copy and paste the validation token in the form below to proof that you are administrator of this service."
 msgstr "Veuillez recopier ce code dans le formulaire ci-dessous pour prouver que vous êtes l'administatreur de ce service."
 
-#: templates/web/edugain/complete_challenge.tt2.html:19 templates/web/renater/complete_challenge.tt2.html:19
+#: templates/web/edugain/complete_challenge.tt2.html:18 templates/web/renater/complete_challenge.tt2.html:18
 msgid "Please provide the validation token here:"
 msgstr "Veuillez fournir le code de validation:"
 
-#: templates/web/edugain/select_sp.tt2.html:15 templates/web/renater/select_sp.tt2.html:15
-msgid "Please select the service that you want to test in the list below."
-msgstr "Veuillez sélectionner le service que vous désirez tester dans la liste ci-dessous."
+#: templates/web/edugain/select_sp.tt2.html:14 templates/web/renater/select_sp.tt2.html:14
+msgid "Please select the service provider you want to test in one of the lists below."
+msgstr "Veuillez sélectionner le fournisseur de service que vous désirez tester dans une des liste ci-dessous."
 
-#: templates/web/edugain/complete_challenge.tt2.html:29 templates/web/edugain/select_email.tt2.html:38 templates/web/edugain/select_federation.tt2.html:27 templates/web/edugain/select_sp.tt2.html:34 templates/web/renater/complete_challenge.tt2.html:29 templates/web/renater/select_email.tt2.html:38 templates/web/renater/select_federation.tt2.html:27 templates/web/renater/select_sp.tt2.html:34
+#: templates/web/edugain/complete_challenge.tt2.html:28 templates/web/edugain/select_email.tt2.html:37 templates/web/edugain/select_sp.tt2.html:36 templates/web/renater/complete_challenge.tt2.html:28 templates/web/renater/select_email.tt2.html:37 templates/web/renater/select_sp.tt2.html:36
 msgid "Previous"
 msgstr "Précédent"
 
@@ -158,36 +158,23 @@ msgstr "Précédent"
 msgid "RENATER Access Check is a service based on eduGAIN Access Check software, allowing administrators of service providers registered in Education-Research Federation to safely test their service behavior."
 msgstr "RENATER Access Check est un service basé sur le logiciel eduGAIN Access Check, permettant aux administrateurs de fournisseurs de service enregistrés dans la Fédération Éducation-Recherche de tester de façon sécurisée le fonctionnement de leur service."
 
-#: templates/web/edugain/complete_challenge.tt2.html:5 templates/web/edugain/select_email.tt2.html:5 templates/web/edugain/select_federation.tt2.html:13 templates/web/edugain/select_federation.tt2.html:5 templates/web/edugain/select_sp.tt2.html:5 templates/web/renater/complete_challenge.tt2.html:5 templates/web/renater/select_email.tt2.html:5 templates/web/renater/select_federation.tt2.html:13 templates/web/renater/select_federation.tt2.html:5 templates/web/renater/select_sp.tt2.html:5
-msgid "Select a federation"
-msgstr "Sélectionnez une fédération"
-
-#: templates/web/edugain/select_email.tt2.html:18 templates/web/renater/select_email.tt2.html:18
+#: templates/web/edugain/select_email.tt2.html:17 templates/web/renater/select_email.tt2.html:17
 msgid "Select the email address where an email challenge can be sent to validate your identity:"
 msgstr "Sélectionner l'adresse e-mail où envoyer un message pour valider votre identité:"
 
-#: templates/web/edugain/select_federation.tt2.html:16 templates/web/renater/select_federation.tt2.html:16
-msgid "Select the federation corresponding to the service you want to test:"
-msgstr "Sélectionner la fédération correspondant au service à tester:"
-
-#: templates/web/edugain/complete_challenge.tt2.html:7 templates/web/edugain/select_email.tt2.html:13 templates/web/edugain/select_email.tt2.html:7 templates/web/edugain/select_federation.tt2.html:7 templates/web/edugain/select_sp.tt2.html:7 templates/web/renater/complete_challenge.tt2.html:7 templates/web/renater/select_email.tt2.html:13 templates/web/renater/select_email.tt2.html:7 templates/web/renater/select_federation.tt2.html:7 templates/web/renater/select_sp.tt2.html:7
+#: templates/web/edugain/complete_challenge.tt2.html:6 templates/web/edugain/select_email.tt2.html:12 templates/web/edugain/select_email.tt2.html:6 templates/web/edugain/select_sp.tt2.html:6 templates/web/renater/complete_challenge.tt2.html:6 templates/web/renater/select_email.tt2.html:12 templates/web/renater/select_email.tt2.html:6 templates/web/renater/select_sp.tt2.html:6
 msgid "Select your email address"
 msgstr "Sélectionnez votre adresse e-mail"
 
-#: templates/web/edugain/complete_challenge.tt2.html:6 templates/web/edugain/select_email.tt2.html:6 templates/web/edugain/select_federation.tt2.html:6 templates/web/edugain/select_sp.tt2.html:13 templates/web/edugain/select_sp.tt2.html:6 templates/web/renater/complete_challenge.tt2.html:6 templates/web/renater/select_email.tt2.html:6 templates/web/renater/select_federation.tt2.html:6 templates/web/renater/select_sp.tt2.html:13 templates/web/renater/select_sp.tt2.html:6
-msgid "Select your service"
-msgstr "Sélectionnez votre service"
-
-#. (sourceip, entityid)
-#: templates/mail/send_authentication_token.tt2.html:3 templates/mail/send_authentication_token.tt2.txt:2
-msgid "User %1, authenticated by Identity Provider %2, has requested creation of test accounts for Service Provider %3."
-msgstr "L'utilisateur %1, authentifié par le fournisseur d'identité %2, a demandé la création de comptes de test pour le fournisseur de service %3."
+#: templates/web/edugain/complete_challenge.tt2.html:5 templates/web/edugain/select_email.tt2.html:5 templates/web/edugain/select_sp.tt2.html:12 templates/web/edugain/select_sp.tt2.html:5 templates/web/renater/complete_challenge.tt2.html:5 templates/web/renater/select_email.tt2.html:5 templates/web/renater/select_sp.tt2.html:12 templates/web/renater/select_sp.tt2.html:5
+msgid "Select your service provider"
+msgstr "Sélectionnez votre fournisseur de service"
 
 #: templates/web/edugain/create_accounts.tt2.html:8 templates/web/renater/create_accounts.tt2.html:10
 msgid "Test accounts created"
 msgstr "Comptes de test créés"
 
-#: lib/AccountManager/App.pm:504
+#: lib/AccountManager/App.pm:502
 msgid "Test accounts request"
 msgstr "Demande de comptes de test"
 
@@ -209,7 +196,7 @@ msgstr "L'addresse %1 est mentionnée dans les métadonnées de la fédération
 msgid "Therefore its values should be handled with great care."
 msgstr "C'est pourquoi ces valeurs doivent être traitées avec prudence."
 
-#: templates/web/edugain/complete_challenge.tt2.html:36 templates/web/edugain/select_email.tt2.html:45 templates/web/edugain/select_federation.tt2.html:34 templates/web/edugain/select_sp.tt2.html:173 templates/web/renater/complete_challenge.tt2.html:36 templates/web/renater/select_email.tt2.html:45 templates/web/renater/select_federation.tt2.html:34 templates/web/renater/select_sp.tt2.html:173
+#: templates/web/edugain/complete_challenge.tt2.html:35 templates/web/edugain/select_email.tt2.html:44 templates/web/edugain/select_sp.tt2.html:193 templates/web/renater/complete_challenge.tt2.html:35 templates/web/renater/select_email.tt2.html:44 templates/web/renater/select_sp.tt2.html:193
 msgid "This information is required"
 msgstr "Cette information est nécessaire"
 
@@ -218,11 +205,11 @@ msgstr "Cette information est nécessaire"
 msgid "This is an email challenge automatically sent to you by %1."
 msgstr "Ceci est un message envoyé automatiquement par %1."
 
-#: templates/web/edugain/select_email.tt2.html:28 templates/web/renater/select_email.tt2.html:28
+#: templates/web/edugain/select_email.tt2.html:27 templates/web/renater/select_email.tt2.html:27
 msgid "Those email addresses have been extracted from your service metadata."
 msgstr "Ces addresses e-mail ont été extraites des métadonnées pour votre service."
 
-#: templates/web/edugain/select_sp.tt2.html:30 templates/web/renater/select_sp.tt2.html:30
+#: templates/web/edugain/select_sp.tt2.html:32 templates/web/renater/select_sp.tt2.html:32
 msgid "Those service providers have been extracted from the selected federation metadata."
 msgstr "Ces fournisseurs de service ont été extrait des métadonnées de la fédération sélectionnée."
 
@@ -245,9 +232,10 @@ msgstr "Pour ce faire, sélectionnez <strong>%1</strong> lors du choix du founis
 msgid "To start testing your own services, start by selecting one your are administrator for."
 msgstr "Pour commencer à tester vos propres services, commencez par en sélectionner un dont vous êtes l'administrateur."
 
-#: templates/web/edugain/select_sp.tt2.html:20 templates/web/renater/select_sp.tt2.html:20
-msgid "Type the name or entityID of service to test:"
-msgstr "Entrez le nom ou l'identifiant (entityID) du service à tester:"
+#. (user, idp, sp)
+#: templates/mail/send_authentication_token.tt2.html:3 templates/mail/send_authentication_token.tt2.txt:2
+msgid "User %1, authenticated by Identity Provider %2, has requested creation of test accounts for Service Provider %3."
+msgstr "L'utilisateur %1, authentifié par le fournisseur d'identité %2, a demandé la création de comptes de test pour le fournisseur de service %3."
 
 #: templates/web/renater/index.tt2.html:132
 msgid "Users feedback"
@@ -258,15 +246,16 @@ msgstr "Retour utilisateurs"
 msgid "Validation token: %1"
 msgstr "Code de validation: %1"
 
+#. (url)
 #: templates/web/edugain/create_accounts.tt2.html:10 templates/web/renater/create_accounts.tt2.html:12
 msgid "You can now use these test accounts to login at your <a href=\"%1\">service provider</a>."
 msgstr "Vous pouvez maintenant utiliser ces comptes pour vous identifier sur votre <a href=\"%1\">fournisseur de service</a>."
 
-#: templates/web/edugain/errors.tt2.html:38 templates/web/renater/errors.tt2.html:37
+#: templates/web/edugain/errors.tt2.html:40 templates/web/renater/errors.tt2.html:39
 msgid "You can report the issue to the administrators"
 msgstr "Vous pouvez informer les administrateurs du problème"
 
-#: templates/web/edugain/select_sp.tt2.html:16 templates/web/renater/select_sp.tt2.html:16
+#: templates/web/edugain/select_sp.tt2.html:15 templates/web/renater/select_sp.tt2.html:15
 msgid "You must be an administrator of that service to continue afterwards."
 msgstr "Vous devez être administrateur de ce service pour continuer ensuite."
 
@@ -291,7 +280,7 @@ msgid "mail notification failure"
 msgstr "échec de notification par mail"
 
 #. (matches.0)
-#: templates/web/edugain/errors.tt2.html:28 templates/web/renater/errors.tt2.html:28
+#: templates/web/edugain/errors.tt2.html:30 templates/web/renater/errors.tt2.html:30
 msgid "missing parameter '%1'"
 msgstr "paramètre manquant '%1'"
 
@@ -328,6 +317,6 @@ msgstr "nom d'utilisateur:"
 msgid "value dynamically generated by the SP"
 msgstr "valeur générée dynamiquement par le SP"
 
-#: templates/web/edugain/errors.tt2.html:27
+#: templates/web/edugain/errors.tt2.html:27 templates/web/renater/errors.tt2.html:27
 msgid "you need to authenticate to access this page"
 msgstr "vous devez vous authentifier pour accéder à cette page"
diff --git a/templates/Makefile.am b/templates/Makefile.am
index 68d46c6..c190276 100644
--- a/templates/Makefile.am
+++ b/templates/Makefile.am
@@ -5,7 +5,6 @@ nobase_templates_DATA = \
 	web/edugain/errors.tt2.html \
 	web/edugain/home.tt2.html \
 	web/edugain/index.tt2.html \
-	web/edugain/select_federation.tt2.html \
 	web/edugain/select_sp.tt2.html \
 	web/edugain/select_email.tt2.html \
 	web/edugain/complete_challenge.tt2.html \
@@ -13,7 +12,6 @@ nobase_templates_DATA = \
 	web/renater/errors.tt2.html \
 	web/renater/home.tt2.html \
 	web/renater/index.tt2.html \
-	web/renater/select_federation.tt2.html \
 	web/renater/select_sp.tt2.html \
 	web/renater/select_email.tt2.html \
 	web/renater/complete_challenge.tt2.html \
diff --git a/templates/web/edugain/complete_challenge.tt2.html b/templates/web/edugain/complete_challenge.tt2.html
index dc5b39b..a1e0d5c 100644
--- a/templates/web/edugain/complete_challenge.tt2.html
+++ b/templates/web/edugain/complete_challenge.tt2.html
@@ -2,8 +2,7 @@
 <form class="wizard clearfix" action="[% app.url %]" method="get">
     <div class="steps clearfix">
         <ol>
-            <li class="done">[% lh.maketext("Select a federation") %]</li>
-            <li class="done">[% lh.maketext("Select your service") %]</li>
+            <li class="done">[% lh.maketext("Select your service provider") %]</li>
             <li class="done">[% lh.maketext("Select your email address") %]</li>
             <li class="current">[% lh.maketext("Complete email challenge") %]</li>
         </ol>
diff --git a/templates/web/edugain/create_accounts.tt2.html b/templates/web/edugain/create_accounts.tt2.html
index 082c372..3310ef7 100644
--- a/templates/web/edugain/create_accounts.tt2.html
+++ b/templates/web/edugain/create_accounts.tt2.html
@@ -91,5 +91,5 @@
     </div>
 </div>
 
-<p class="text-center"><a href="[% app.url %]?action=select_federation" class="button">[% lh.maketext("Test another service") %]</a></p>
+<p class="text-center"><a href="[% app.url %]?action=select_sp" class="button">[% lh.maketext("Test another service") %]</a></p>
 [% END %]
diff --git a/templates/web/edugain/home.tt2.html b/templates/web/edugain/home.tt2.html
index 30d958e..bc28cb4 100644
--- a/templates/web/edugain/home.tt2.html
+++ b/templates/web/edugain/home.tt2.html
@@ -9,6 +9,6 @@
 
 <h2>[% lh.maketext("Get started") %]</h2>
 <p>[% lh.maketext("To start testing your own services, start by selecting one your are administrator for.") %]</p>
-<p class="text-center"><a href="[% IF app.login_url %][% app.login_url %]?target=[% app.url %]%3Faction%3Dselect_federation[% ELSE %][% app.url %]?action=select_federation[% END %]" class="button">[% lh.maketext("Get started") %]</a></p>
+<p class="text-center"><a href="[% IF app.login_url %][% app.login_url %]?target=[% app.url %]%3Faction%3Dselect_sp[% ELSE %][% app.url %]?action=select_sp[% END %]" class="button">[% lh.maketext("Get started") %]</a></p>
 
 [% END %]
diff --git a/templates/web/edugain/select_email.tt2.html b/templates/web/edugain/select_email.tt2.html
index 5534885..73260ca 100644
--- a/templates/web/edugain/select_email.tt2.html
+++ b/templates/web/edugain/select_email.tt2.html
@@ -2,8 +2,7 @@
 <form class="wizard clearfix" action="[% app.url %]" method="get">
     <div class="steps clearfix">
         <ol>
-            <li class="done">[% lh.maketext("Select a federation") %]</li>
-            <li class="done">[% lh.maketext("Select your service") %]</li>
+            <li class="done">[% lh.maketext("Select your service provider") %]</li>
             <li class="current">[% lh.maketext("Select your email address") %]</li>
             <li class="disabled">[% lh.maketext("Complete email challenge") %]</li>
         </ol>
diff --git a/templates/web/edugain/select_federation.tt2.html b/templates/web/edugain/select_federation.tt2.html
deleted file mode 100644
index 061c094..0000000
--- a/templates/web/edugain/select_federation.tt2.html
+++ /dev/null
@@ -1,38 +0,0 @@
-[% WRAPPER index.tt2.html %]
-<form class="wizard clearfix" action="[% app.url %]" method="get">
-    <div class="steps clearfix">
-        <ol>
-            <li class="current">[% lh.maketext("Select a federation") %]</li>
-            <li class="disabled">[% lh.maketext("Select your service") %]</li>
-            <li class="disabled">[% lh.maketext("Select your email address") %]</li>
-            <li class="disabled">[% lh.maketext("Complete email challenge") %]</li>
-        </ol>
-    </div>
-
-    <div class="content clearfix">
-        <h2>[% lh.maketext("Select a federation") %]</h2>
-
-        <fieldset>
-            <legend>[% lh.maketext("Select the federation corresponding to the service you want to test:") %]</legend>
-        [% FOREACH key IN federations.keys.sort %]
-            <input id="[% key %]" name="federation" value="[% key %]" type="radio" class="required"/>
-            <label for="[% key %]">[% federations.$key %]</label>
-            <br/>
-        [% END %]
-            <label for="federation" class="error"></label>
-        </fieldset>
-    </div>
-
-    <div class="actions clearfix">
-        <button type="submit" class="button" name="action" value="" formnovalidate>[% lh.maketext("Previous") %]</button>
-        <button type="submit" class="button" name="action" value="select_sp">[% lh.maketext("Next") %]</button>
-    </div>
-</form>
-
-<script type="text/javascript">
-$( document ).ready(function() {
-    $.validator.messages.required = "[% lh.maketext("This information is required") %]";
-    $("form").validate();
-});
-</script>
-[% END %]
diff --git a/templates/web/edugain/select_sp.tt2.html b/templates/web/edugain/select_sp.tt2.html
index cdac884..35d5d90 100644
--- a/templates/web/edugain/select_sp.tt2.html
+++ b/templates/web/edugain/select_sp.tt2.html
@@ -2,36 +2,38 @@
 <form class="wizard clearfix" action="[% app.url %]" method="get">
     <div class="steps clearfix">
         <ol>
-            <li class="done">[% lh.maketext("Select a federation") %]</li>
-            <li class="current">[% lh.maketext("Select your service") %]</li>
+            <li class="current">[% lh.maketext("Select your service provider") %]</li>
             <li class="disabled">[% lh.maketext("Select your email address") %]</li>
             <li class="disabled">[% lh.maketext("Complete email challenge") %]</li>
         </ol>
     </div>
 
     <div class="content clearfix">
-        <h2>[% lh.maketext("Select your service") %]</h2>
+        <h2>[% lh.maketext("Select your service provider") %]</h2>
         <p>
-            [% lh.maketext("Please select the service that you want to test in the list below.") %]
+            [% lh.maketext("Please select the service provider you want to test in one of the lists below.") %]&nbsp;
             [% lh.maketext("You must be an administrator of that service to continue afterwards.") %]
         </p>
 
+        [% FOREACH federation IN federations.keys.sort() %]
         <fieldset>
-            <legend for="entityid">[% lh.maketext("Type the name or entityID of service to test:") %]</legend>
-            <select id="entityid" name="entityid" class="required">
+            <label for="[% federation %]_entityid">[% federations.$federation.label %]</label>
+            <select id="[% federation %]_entityid" name="[% federation %]_entityid">
                 <option value=""></option>
-            [% FOREACH entity IN entities.sort('display_name') %]
+            [% FOREACH entity IN federations.$federation.entities.sort('display_name') %]
                 <option value="[% entity.entityid %]">[% entity.display_name %]</option>
             [% END %]
             </select>
-            <label for="entityid_combobox" class="error"></label>
-            <input type="hidden" name="federation" value="[% federation %]"/>
         </fieldset>
+        [% END %]
+        <input type="hidden" id="federation" name="federation"/>
+        <input type="hidden" id="entityid" name="entityid"/>
+
         <div class="callout primary">[% lh.maketext("Those service providers have been extracted from the selected federation metadata.") %]</div>
     </div>
 
     <div class="actions clearfix">
-        <button type="submit" class="button" name="action" value="select_federation" formnovalidate>[% lh.maketext("Previous") %]</button>
+        <button type="submit" class="button" name="action" value="" formnovalidate>[% lh.maketext("Previous") %]</button>
         <button type="submit" class="button" name="action" value="select_email">[% lh.maketext("Next") %]</button>
     </div>
 </form>
@@ -60,7 +62,7 @@ $( document ).ready(function() {
                 .attr( "title", "" )
                 .attr('id', id + '_combobox')
                 .attr('name', id + '_combobox')
-                .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left required" )
+                .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
                 .autocomplete({
                     delay: 0,
                     minLength: 0,
@@ -72,10 +74,25 @@ $( document ).ready(function() {
 
             this._on( this.input, {
                 autocompleteselect: function( event, ui ) {
+                    // sync hidden list widget
                     ui.item.option.selected = true;
                     this._trigger( "select", event, {
                         item: ui.item.option
                     });
+
+                    // retrieve federation and entityid
+                    var id = this.element.attr('id');
+                    var id_parts = id.split('_');
+                    var federation = id_parts[0];
+                    var entity = this.element.val();
+
+                    // reset other comboboxes
+                    $("input[id!='" + id + "_combobox']").val("");
+                    $("select[id!='" + id + "']  option:selected").prop('selected', false);
+
+                    // set federation
+                    $("#federation").val(federation);
+                    $("#entityid").val(entity);
                 },
  
                 autocompletechange: "_removeIfInvalid"
@@ -168,7 +185,10 @@ $( document ).ready(function() {
             this.element.show();
         }
     });
-    $( "#entityid" ).combobox();
+
+[% FOREACH federation IN federations.keys() %]
+    $( "#[% federation %]_entityid" ).combobox();
+[% END %]
 
     $.validator.messages.required = "[% lh.maketext("This information is required") %]";
     $("form").validate();
diff --git a/templates/web/renater/complete_challenge.tt2.html b/templates/web/renater/complete_challenge.tt2.html
index dc5b39b..a1e0d5c 100644
--- a/templates/web/renater/complete_challenge.tt2.html
+++ b/templates/web/renater/complete_challenge.tt2.html
@@ -2,8 +2,7 @@
 <form class="wizard clearfix" action="[% app.url %]" method="get">
     <div class="steps clearfix">
         <ol>
-            <li class="done">[% lh.maketext("Select a federation") %]</li>
-            <li class="done">[% lh.maketext("Select your service") %]</li>
+            <li class="done">[% lh.maketext("Select your service provider") %]</li>
             <li class="done">[% lh.maketext("Select your email address") %]</li>
             <li class="current">[% lh.maketext("Complete email challenge") %]</li>
         </ol>
diff --git a/templates/web/renater/create_accounts.tt2.html b/templates/web/renater/create_accounts.tt2.html
index c8e60f1..0ddddce 100644
--- a/templates/web/renater/create_accounts.tt2.html
+++ b/templates/web/renater/create_accounts.tt2.html
@@ -95,5 +95,5 @@
     </div>
 </div>
 
-<p class="text-center"><a href="[% app.url %]?action=select_federation" class="button">[% lh.maketext("Test another service") %]</a></p>
+<p class="text-center"><a href="[% app.url %]?action=select_sp" class="button">[% lh.maketext("Test another service") %]</a></p>
 [% END %]
diff --git a/templates/web/renater/home.tt2.html b/templates/web/renater/home.tt2.html
index f701225..18b8919 100644
--- a/templates/web/renater/home.tt2.html
+++ b/templates/web/renater/home.tt2.html
@@ -9,6 +9,6 @@
 
 <h2>[% lh.maketext("Get started") %]</h2>
 <p>[% lh.maketext("To start testing your own services, start by selecting one your are administrator for.") %]</p>
-<p class="text-center"><a href="[% IF app.login_url %][% app.login_url %]?target=[% app.url %]%3Faction%3Dselect_federation[% ELSE %][% app.url %]?action=select_federation[% END %]" class="button">[% lh.maketext("Get started") %]</a></p>
+<p class="text-center"><a href="[% IF app.login_url %][% app.login_url %]?target=[% app.url %]%3Faction%3Dselect_sp[% ELSE %][% app.url %]?action=select_sp[% END %]" class="button">[% lh.maketext("Get started") %]</a></p>
 
 [% END %]
diff --git a/templates/web/renater/select_email.tt2.html b/templates/web/renater/select_email.tt2.html
index 97394f8..4f426e7 100644
--- a/templates/web/renater/select_email.tt2.html
+++ b/templates/web/renater/select_email.tt2.html
@@ -2,8 +2,7 @@
 <form class="wizard clearfix" action="[% app.url %]" method="get">
     <div class="steps clearfix">
         <ol>
-            <li class="done">[% lh.maketext("Select a federation") %]</li>
-            <li class="done">[% lh.maketext("Select your service") %]</li>
+            <li class="done">[% lh.maketext("Select your service provider") %]</li>
             <li class="current">[% lh.maketext("Select your email address") %]</li>
             <li class="disabled">[% lh.maketext("Complete email challenge") %]</li>
         </ol>
diff --git a/templates/web/renater/select_federation.tt2.html b/templates/web/renater/select_federation.tt2.html
deleted file mode 100644
index 061c094..0000000
--- a/templates/web/renater/select_federation.tt2.html
+++ /dev/null
@@ -1,38 +0,0 @@
-[% WRAPPER index.tt2.html %]
-<form class="wizard clearfix" action="[% app.url %]" method="get">
-    <div class="steps clearfix">
-        <ol>
-            <li class="current">[% lh.maketext("Select a federation") %]</li>
-            <li class="disabled">[% lh.maketext("Select your service") %]</li>
-            <li class="disabled">[% lh.maketext("Select your email address") %]</li>
-            <li class="disabled">[% lh.maketext("Complete email challenge") %]</li>
-        </ol>
-    </div>
-
-    <div class="content clearfix">
-        <h2>[% lh.maketext("Select a federation") %]</h2>
-
-        <fieldset>
-            <legend>[% lh.maketext("Select the federation corresponding to the service you want to test:") %]</legend>
-        [% FOREACH key IN federations.keys.sort %]
-            <input id="[% key %]" name="federation" value="[% key %]" type="radio" class="required"/>
-            <label for="[% key %]">[% federations.$key %]</label>
-            <br/>
-        [% END %]
-            <label for="federation" class="error"></label>
-        </fieldset>
-    </div>
-
-    <div class="actions clearfix">
-        <button type="submit" class="button" name="action" value="" formnovalidate>[% lh.maketext("Previous") %]</button>
-        <button type="submit" class="button" name="action" value="select_sp">[% lh.maketext("Next") %]</button>
-    </div>
-</form>
-
-<script type="text/javascript">
-$( document ).ready(function() {
-    $.validator.messages.required = "[% lh.maketext("This information is required") %]";
-    $("form").validate();
-});
-</script>
-[% END %]
diff --git a/templates/web/renater/select_sp.tt2.html b/templates/web/renater/select_sp.tt2.html
index 7ba0781..b193c1f 100644
--- a/templates/web/renater/select_sp.tt2.html
+++ b/templates/web/renater/select_sp.tt2.html
@@ -2,36 +2,38 @@
 <form class="wizard clearfix" action="[% app.url %]" method="get">
     <div class="steps clearfix">
         <ol>
-            <li class="done">[% lh.maketext("Select a federation") %]</li>
-            <li class="current">[% lh.maketext("Select your service") %]</li>
+            <li class="current">[% lh.maketext("Select your service provider") %]</li>
             <li class="disabled">[% lh.maketext("Select your email address") %]</li>
             <li class="disabled">[% lh.maketext("Complete email challenge") %]</li>
         </ol>
     </div>
 
     <div class="content clearfix">
-        <h2>[% lh.maketext("Select your service") %]</h2>
+        <h2>[% lh.maketext("Select your service provider") %]</h2>
         <p>
-            [% lh.maketext("Please select the service that you want to test in the list below.") %]
+            [% lh.maketext("Please select the service provider you want to test in one of the lists below.") %]&nbsp;
             [% lh.maketext("You must be an administrator of that service to continue afterwards.") %]
         </p>
 
+        [% FOREACH federation IN federations.keys.sort() %]
         <fieldset>
-            <legend for="entityid">[% lh.maketext("Type the name or entityID of service to test:") %]</legend>
-            <select id="entityid" name="entityid" class="required">
+            <label for="[% federation %]_entityid">[% federations.$federation.label %]</label>
+            <select id="[% federation %]_entityid" name="[% federation %]_entityid">
                 <option value=""></option>
-            [% FOREACH entity IN entities.sort('display_name') %]
+            [% FOREACH entity IN federations.$federation.entities.sort('display_name') %]
                 <option value="[% entity.entityid %]">[% entity.display_name %]</option>
             [% END %]
             </select>
-            <label for="entityid_combobox" class="error"></label>
-            <input type="hidden" name="federation" value="[% federation %]"/>
         </fieldset>
+        [% END %]
+        <input type="hidden" id="federation" name="federation"/>
+        <input type="hidden" id="entityid" name="entityid"/>
+
         <div class="callout alert-callout-border primary">[% lh.maketext("Those service providers have been extracted from the selected federation metadata.") %]</div>
     </div>
 
     <div class="actions clearfix">
-        <button type="submit" class="button" name="action" value="select_federation" formnovalidate>[% lh.maketext("Previous") %]</button>
+        <button type="submit" class="button" name="action" value="" formnovalidate>[% lh.maketext("Previous") %]</button>
         <button type="submit" class="button" name="action" value="select_email">[% lh.maketext("Next") %]</button>
     </div>
 </form>
@@ -60,7 +62,7 @@ $( document ).ready(function() {
                 .attr( "title", "" )
                 .attr('id', id + '_combobox')
                 .attr('name', id + '_combobox')
-                .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left required" )
+                .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
                 .autocomplete({
                     delay: 0,
                     minLength: 0,
@@ -72,10 +74,25 @@ $( document ).ready(function() {
 
             this._on( this.input, {
                 autocompleteselect: function( event, ui ) {
+                    // sync hidden list widget
                     ui.item.option.selected = true;
                     this._trigger( "select", event, {
                         item: ui.item.option
                     });
+
+                    // retrieve federation and entityid
+                    var id = this.element.attr('id');
+                    var id_parts = id.split('_');
+                    var federation = id_parts[0];
+                    var entity = this.element.val();
+
+                    // reset other comboboxes
+                    $("input[id!='" + id + "_combobox']").val("");
+                    $("select[id!='" + id + "']  option:selected").prop('selected', false);
+
+                    // set federation
+                    $("#federation").val(federation);
+                    $("#entityid").val(entity);
                 },
  
                 autocompletechange: "_removeIfInvalid"
@@ -168,7 +185,10 @@ $( document ).ready(function() {
             this.element.show();
         }
     });
-    $( "#entityid" ).combobox();
+
+[% FOREACH federation IN federations.keys() %]
+    $( "#[% federation %]_entityid" ).combobox();
+[% END %]
 
     $.validator.messages.required = "[% lh.maketext("This information is required") %]";
     $("form").validate();
-- 
GitLab