From 8a6ff69b6d62d2215027043752e134f3c68cbf7e Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Thu, 26 Jul 2018 15:36:10 +0200 Subject: [PATCH] use text/html messages for email challenge --- lib/AccountManager/App.pm | 33 ++++++++++++++----- lib/AccountManager/L10N/fr.pm | 22 +++++++++---- templates/Makefile.am | 2 ++ .../mail/send_authentication_token.tt2.txt | 8 ++--- .../mail/send_authentication_token.tt2.txt | 8 ++--- 5 files changed, 48 insertions(+), 25 deletions(-) diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm index 73b6296..dac6a93 100644 --- a/lib/AccountManager/App.pm +++ b/lib/AccountManager/App.pm @@ -575,13 +575,11 @@ sub req_complete_challenge { } # build content - my $content; my $tt2 = Template->new({ ENCODING => 'utf8', PRE_CHOMP => CHOMP_ONE, INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/mail", }); - my $template = 'send_authentication_token.tt2.txt'; my $data = { app => { url => $self->{configuration}->{app}->{url}, @@ -592,17 +590,34 @@ sub req_complete_challenge { to => $self->{in}->{email}, entityid => $self->{in}->{entityid}, token => $token->token(), + challenge_url => sprintf( + '%s&action=complete_challenge&federation=%s&entity=%s&email=%s', + $self->{configuration}->{app}->{url}, + $self->{in}->{federation}, + $self->{in}->{entity}, + $self->{in}->{email}, + ), lh => $self->{lh}, }; - $tt2->process($template, $data, \$content); + my $text_content; + my $html_content; + $tt2->process('send_authentication_token.tt2.txt', $data, \$text_content); + $tt2->process('send_authentication_token.tt2.html', $data, \$html_content); - # wrap content in message + # wrap in message my $message = MIME::Lite->new( - From => sprintf('eduGAIN Access Check <%s>', $self->{configuration}->{mailer}->{from}), - To => $self->{in}->{email}, - Subject => encode("MIME-Header", sprintf('[eduGAIN Access Check] %s', $self->{lh}->maketext("Test accounts request"))), - Type =>'text/plain', - Data => $content, + From => sprintf('eduGAIN Access Check <%s>', $self->{configuration}->{mailer}->{from}), + To => $self->{in}->{email}, + Subject => encode("MIME-Header", sprintf('[eduGAIN Access Check] %s', $self->{lh}->maketext("Test accounts request"))), + Type => 'multipart/alternative', + ); + $message->attach( + Type =>'text/plain', + Data => $text_content + ); + $message->attach( + Type =>'text/html', + Data => $html_content ); # send message diff --git a/lib/AccountManager/L10N/fr.pm b/lib/AccountManager/L10N/fr.pm index 6ff6028..3721de8 100644 --- a/lib/AccountManager/L10N/fr.pm +++ b/lib/AccountManager/L10N/fr.pm @@ -66,6 +66,11 @@ msgstr "Voici la liste des attributs utilisateur associés à ce compte de test. msgid "Best Regards" msgstr "Cordialement" +#. (challenge_url) +#: templates/mail/send_authentication_token.tt2.txt:6 templates/renater/mail/send_authentication_token.tt2.txt:6 +msgid "Challenge URL: %1" +msgstr "URL du challenge: %1" + #: templates/renater/web/complete_challenge.tt2.html:13 templates/renater/web/complete_challenge.tt2.html:8 templates/renater/web/select_email.tt2.html:8 templates/renater/web/select_federation.tt2.html:8 templates/renater/web/select_sp.tt2.html:8 templates/web/complete_challenge.tt2.html:13 templates/web/complete_challenge.tt2.html:8 templates/web/select_email.tt2.html:8 templates/web/select_federation.tt2.html:8 templates/web/select_sp.tt2.html:8 msgid "Complete email challenge" msgstr "Validez le challenge e-mail" @@ -219,9 +224,14 @@ msgstr "Ces addresses e-mail ont été extraites des métadonnées pour votre se 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." -#: templates/mail/send_authentication_token.tt2.eml:10 -msgid "To complete the creation of test accounts, paste the following validation token in the eduGAIN Access Check web form." -msgstr "Pour terminer la création de ces comptes de test, recopiez le code de validation suivant dans l'application eduGAIN Access Check." +#. (challenge_url, token) +#: templates/mail/send_authentication_token.tt2.html:7 templates/renater/mail/send_authentication_token.tt2.html:7 +msgid "To complete the creation of test accounts, paste the following validation token in <a href=\"%1\">eduGAIN Access Check</a>: %2." +msgstr "Pour terminer la création de ces comptes de test, recopiez le code de validation suivant dans <a href=\"%1\">eduGAIN Access Check</a>: %2." + +#: templates/mail/send_authentication_token.tt2.txt:5 templates/renater/mail/send_authentication_token.tt2.txt:5 +msgid "To complete the creation of test accounts, paste the following validation token in eduGAIN Access Check:" +msgstr "Pour terminer la création de ces comptes de test, recopiez le code de validation suivant dans eduGAIN Access Check:" #. (idp_displayname) #: templates/renater/web/create_accounts.tt2.html:11 templates/web/create_accounts.tt2.html:11 @@ -236,9 +246,9 @@ msgstr "Pour commencer à tester vos propres services, commencez par en sélecti msgid "Type the name or entityID of service to test:" msgstr "Entrez le nom ou l'identifiant (entityID) du service à tester:" -#: templates/mail/send_authentication_token.tt2.eml:12 -msgid "Validation token:" -msgstr "Code de validation:" +#: templates/renater/mail/send_authentication_token.tt2.html:9 +msgid "Validation token: %1" +msgstr "Code de validation: %1" #: templates/renater/web/create_accounts.tt2.html:10 templates/web/create_accounts.tt2.html:10 msgid "You can now use these test accounts to login at your federated service." diff --git a/templates/Makefile.am b/templates/Makefile.am index 9a18e24..afe1f1f 100644 --- a/templates/Makefile.am +++ b/templates/Makefile.am @@ -1,6 +1,7 @@ nobase_templates_DATA = \ accounts/accounts.php.tt2 \ mail/send_authentication_token.tt2.txt \ + mail/send_authentication_token.tt2.html \ web/errors.tt2.html \ web/home.tt2.html \ web/index.tt2.html \ @@ -11,6 +12,7 @@ nobase_templates_DATA = \ web/create_accounts.tt2.html \ renater/accounts/accounts.php.tt2 \ renater/mail/send_authentication_token.tt2.txt \ + renater/mail/send_authentication_token.tt2.html \ renater/web/errors.tt2.html \ renater/web/home.tt2.html \ renater/web/index.tt2.html \ diff --git a/templates/mail/send_authentication_token.tt2.txt b/templates/mail/send_authentication_token.tt2.txt index 179001c..a1bdf9f 100644 --- a/templates/mail/send_authentication_token.tt2.txt +++ b/templates/mail/send_authentication_token.tt2.txt @@ -2,11 +2,9 @@ [% lh.maketext("Somebody with IP address [_1] has requested to create test accounts for eduGAIN Service Provider with entityID [_2].", sourceip, entityid) %] [% lh.maketext("The address [_1] is mentioned in the eduGAIN metadata as a contact for this Service Provider.", to) %] -[% lh.maketext("To complete the creation of test accounts, paste the following validation token in the eduGAIN Access Check web form.") %] - -[% lh.maketext("Validation token:") %] [% token %] - -eduGAIN Access Check: [% app.url %] +[% lh.maketext("To complete the creation of test accounts, paste the following validation token in eduGAIN Access Check:") %] +- [% lh.maketext("Challenge URL: [_1]", challenge_url) %] +- [% lh.maketext("Validation token: [_1]", token) %] [% lh.maketext("If the creation of test accounts was not initiated by you or a fellow administrator for the above Service Provider, please forward this email and contact [_1] to inform them about a potential abuse of the eduGAIN Access Check service.", app.support_email) %] diff --git a/templates/renater/mail/send_authentication_token.tt2.txt b/templates/renater/mail/send_authentication_token.tt2.txt index 179001c..a1bdf9f 100644 --- a/templates/renater/mail/send_authentication_token.tt2.txt +++ b/templates/renater/mail/send_authentication_token.tt2.txt @@ -2,11 +2,9 @@ [% lh.maketext("Somebody with IP address [_1] has requested to create test accounts for eduGAIN Service Provider with entityID [_2].", sourceip, entityid) %] [% lh.maketext("The address [_1] is mentioned in the eduGAIN metadata as a contact for this Service Provider.", to) %] -[% lh.maketext("To complete the creation of test accounts, paste the following validation token in the eduGAIN Access Check web form.") %] - -[% lh.maketext("Validation token:") %] [% token %] - -eduGAIN Access Check: [% app.url %] +[% lh.maketext("To complete the creation of test accounts, paste the following validation token in eduGAIN Access Check:") %] +- [% lh.maketext("Challenge URL: [_1]", challenge_url) %] +- [% lh.maketext("Validation token: [_1]", token) %] [% lh.maketext("If the creation of test accounts was not initiated by you or a fellow administrator for the above Service Provider, please forward this email and contact [_1] to inform them about a potential abuse of the eduGAIN Access Check service.", app.support_email) %] -- GitLab