Modifications entre les versions 19 et 20
Version 19 à la date du 2015-02-12 17:21:39
Taille: 14658
Éditeur: FredyPulido
Commentaire:
Version 20 à la date du 2015-02-12 17:24:57
Taille: 14478
Éditeur: FredyPulido
Commentaire:
Texte supprimé. Texte ajouté.
Ligne 206: Ligne 206:
}}}
Alternative : Copier le fichier depuis la VM de test en utilisant scp:
{{{
scp root@10.36.1.97:/srv/www/sondages.auf.org/application/views/admin/authentication/login.php .

Recette de migration pour Limesurvey de 1.87 vers 2.05+

Serveur en production (ancienne)

  • Arrêter Limesurvey en produtcion
  • Faire un tgz (sondages.auf.org.tgz) avec tous les fichiers pour la migration:
    • Dump de la basse de donnés (sondages_auf_org.mysql)
    • Dossier avec fichiers de l'application limesurvey (sondages_auf_org)
    • Certificats SSL
      • _.auf.org-cert.pem
      • _.auf.org-key.pem
      • GandiStandardSSLCA.pem)

Serveur nouveau : Installation Limesurvey2.05+

Installation des paquets :

aptitude install php5-gd php5-imap

Obtenir le backup (utiliesr addrese IP, pas utilise sondages.auf.org)

cd
# scp root@10.36.1.97:sondages.auf.tgz .   
tar -zxf sondages.auf.org.tgz && rm sondages.auf.org_2015-01-28.tar.gz

Préparer les Fichiers de l'application Limesurvey:

mkdir -p /srv/www/
mv sondages.auf.org /srv/www/sondages.auf.org.old
cd /srv/www/
wget https://www.limesurvey.org/en/stable-release/finish/25-latest-stable-release/1218-limesurvey205plus-build150211-tar-gz
tar -zxf 1218-limesurvey205plus-build150211-tar-gz && rm 1218-limesurvey205plus-build150211-tar-gz
## wget https://www.limesurvey.org/en/stable-release/finish/25-latest-stable-release/1213-limesurvey205plus-build141229-tar-gz
## tar -zxf 1213-limesurvey205plus-build141229-tar-gz && rm 1213-limesurvey205plus-build141229-tar-gz
mv limesurvey/ sondages.auf.org
cp -a sondages.auf.org.old/templates/auf* sondages.auf.org/upload/templates/
cp -a sondages.auf.org.old/upload/* sondages.auf.org/upload/
rm -fr sondages.auf.org.old
chown -hR root: sondages.auf.org
cd sondages.auf.org
chgrp -hR www-data tmp/ upload/ application/config/
chmod -R g+w  tmp/ upload/ application/config/

Modifier templates AUF pour éviter warning dans la migration DB :

for i in upload/templates/auf* ; do
sed -i '/<\/head>/i\{TEMPLATEJS}' $i/startpage.pstpl
done

Configuration Apache http (redirection vers https)

cat <<EOT>> /etc/apache2/sites-available/sondages.auf.org
<VirtualHost *:80>
             ServerName sondages.auf.org
        ServerAdmin technique@ca.auf.org
        Redirect permanent / https://sondages.auf.org/
</VirtualHost>
EOT

Configuration Apache https

cat <<EOT>> /etc/apache2/sites-available/sondages.auf.org-ssl
<VirtualHost *:443>
        ServerName sondages.auf.org
        ServerAdmin technique@ca.auf.org

        SSLEngine on
        SSLCertificateFile    /etc/ssl/certs/_.auf.org-cert.pem
        SSLCertificateKeyFile /etc/ssl/private/_.auf.org-key.pem
        SSLCACertificateFile  /etc/ssl/certs/GandiStandardSSLCA.pem
        SSLVerifyClient None

        DocumentRoot /srv/www/sondages.auf.org
        <Directory /srv/www/sondages.auf.org>
                Options FollowSymLinks MultiViews
                AllowOverride All
                Order Allow,Deny
                Allow From All

                AddDefaultCharset utf-8
                php_value default_charset utf-8

                RewriteEngine On
                ## DONT TOUCH ANYTHING ##
                # Only with survey code : http://server.fr/123456
                RewriteRule ^([0-9]+)/*$ index.php?sid=$1 [L,QSA]
                # Survey code + Lang + Token : http://server.fr/123456/lang-fr/tk-sdlfkjozeiru
                RewriteRule ^([0-9]+)/lang-([^/]*)/*$ index.php?sid=$1&lang=$2 [L,QSA]
                # Survey code + Token : http://server.fr/123456/tk-sdlfkjozeiru
                RewriteRule ^([0-9]+)/lang-([^/]*)/tk-([^/]*)/*$ index.php?sid=$1&lang=$2&token=$3 [L,QSA]
                # Survey code + Token : http://server.fr/123456/tk-sdlfkjozeiru
                RewriteRule ^([0-9]+)/tk-([^/]*)/*$ index.php?sid=$1&token=$2 [L,QSA]
        </Directory>

        ErrorLog /var/log/apache2/sondages.auf.org-error.log
        LogLevel warn
        CustomLog /var/log/apache2/sondages.auf.org-access.log combined
</VirtualHost>
EOT

Les certificats SSL

cd
mv _.auf.org-cert.pem GandiStandardSSLCA.pem /etc/ssl/certs/
mv _.auf.org-key.pem /etc/ssl/private/
##scp root@10.36.1.97:/etc/ssl/certs/_.auf.org-cert.pem /etc/ssl/certs/_.auf.org-cert.pem
##scp root@10.36.1.97:/etc/ssl/private/_.auf.org-key.pem /etc/ssl/private/_.auf.org-key.pem
##scp root@10.36.1.97:/etc/ssl/certs/GandiStandardSSLCA.pem /etc/ssl/certs/GandiStandardSSLCA.pem

Activation modules et sites Apache:

a2enmod rewrite ssl
a2ensite sondages.auf.org sondages.auf.org-ssl
service apache2 restart

Préparer la Base de données /!\ Changer aufauf pour le vrai mot de passe /!\ :

cd
mysql -e "create database limesurvey"
mysql limesurvey < sondages_auf_org.mysql && rm sondages_auf_org.mysql
mysql -e "grant all privileges on limesurvey.* to 'limesurvey'@'localhost' identified by 'aufauf'"

Conf limesurvey depuis le navigateur web (dans mon poste du travail):

  • Verifier /etc/hosts dans mon poste du travail, il faut l'adresse du nouveau serveur pour le domain sondages.auf.org
    • sudo vi /etc/hosts
    • sudo nscd -i hosts
  • http://sondages.auf.org/admin

    • Welcome:
      • Please select your preferred language: Français - French

      • Cliquer la bouton start installation

    • Paramètres de la base de données
      • Utilisateur de la base de données: limesurvey
      • Mot de passe de la base de données: aufauf /!\ Changer aufauf pour le vrai mot de passe /!\

      • Nom de la base de données: limesurvey
  • https://sondages.auf.org/index.php/admin/templates/sa/upload

    • Téléverser le modèle auf2014 (auf2014.zip dans mon poste du travail)
  • https://sondages.auf.org/index.php/admin/globalsettings

    • Modèle par défaut : auf2014
    • Sauvegarder

Permission fichier configuration Limesurvey:

chmod o-rwx /srv/www/sondages.auf.org/application/config/config.php

Serveur nouveau : ID AUF pour Limesurvey2.05+

Convertir le nom des utilisateurs anciennes dans la base de données vers prenom.nom@auf.org :

mysql limesurvey -e "UPDATE lime_users SET users_name=email WHERE email LIKE '%@auf.org' AND email !='webmestre@auf.org' AND users_name !='TNSAfrique'"

Hack Bouton login ID AUF

cd /srv/www/sondages.auf.org/styles
wget https://nuage.auf.org/themes/auf/core/img/idauf_bouton.png
wget https://nuage.auf.org/themes/auf/core/img/idauf_bouton_survol.png

cd
mv patchs/login.php.patch /srv/www/sondages.auf.org/application/views/admin/authentication/
cd /srv/www/sondages.auf.org/application/views/admin/authentication/
patch login.php < login.php.patch && rm login.php.patch

Reference: contenu du fichier login.php.patch

--- login.php.orig      2014-12-29 15:25:36.000000000 -0500
+++ login.php   2015-02-06 10:55:27.556158144 -0500
@@ -2,6 +2,28 @@
     <div class='messagebox ui-corner-all'>
         <div class='header ui-widget-header'><?php echo $summary; ?></div>
         <br />
+<form id="id_auf">
+
+<p style="display: inline-block;
+    margin-right: 20px;
+    vertical-align: middle;
+    text-align: right"> <strong>Usagers de l'AUF&nbsp;:</strong>
+</p>
+
+<p style="display: inline-block;
+    vertical-align: middle;
+    text-align: right">
+
+<a href="https://sondages.auf.org/mellon/login?ReturnTo=/admin/" onmouseover="document.idauf_bouton.src='/styles/idauf_bouton_survol.png';" onmouseout="document.idauf_bouton.src='/styles/idauf_bouton.png';"><img id="idauf_bouton" src="/styles/idauf_bouton.png" height="32" width="200"></a>
+
+</p>
+</form>
+
+
+<p align="left"><strong>Pour les usagers qui n'ont pas d'adresse @auf.org,</strong><br>utilisez le formulaire de connexion suivant&nbsp;:</p>
+
+
+
         <ul style='width: 500px; margin-left: auto; margin-right: auto'>
             <?php 
             $pluginNames = array_keys($pluginContent);

Hack du plugin pour le logout:

diff /srv/www/sondages.auf.org/application/core/plugins/Authwebserver/Authwebserver.php Authwebserver.php
23,27c23
<          ),
<          'logout_url' => array(
<                       'type' => 'string',
<                              'label' => 'Remote auth logout URL (LimeSurvey will redirect to this URL after local logout)',
<                              ),
---
>                 )
38d33
<       $this->subscribe('afterLogout');
135,143c130
<     public function afterLogout()
<     {
<     $logoutURL = $this->get('logout_url');
<         if (!empty($logoutURL))
<         {
<         header("Location: $logoutURL");
<         exit;
<         }
<     }
---
>

Alternative : Copier le fichier depuis la VM de test en utilisant scp:

# scp root@10.36.1.88:/srv/www/sondages.auf.org/application/core/plugins/Authwebserver/Authwebserver.php

Configuration du plugin auth web:

Pour la création automatique des utilisateurs il faut ajouter la ligne auth_webserver_autocreate_use dans le fichier /srv/www/sondages.auf.org/application/config/config.php :

                'debugsql'=>0, // Set this to 1 to enanble sql logging, only active when debug = 2
                'auth_webserver_autocreate_user'=>true,
        ),

Pour définir le profile des nouveaux utilisateurs auth_webserver_autocreate_user il faut modifier function hook_get_auth_webserver_profil dans le fichier: /srv/www/sondages.auf.org/application/config/config-defaults.php function hook_get_auth_webserver_profile($user_name)

{
      return Array(
                        'full_name' => getenv("MELLON_gn")." ".getenv("MELLON_sn"),
                        'email' => getenv("MELLON_mail"),
                        'lang' => 'fr',
                        'create_survey' => 1,
                        'create_user' => 0,
                        'delete_user' => 0,
                        'superadmin' => 0,
                        'configurator' =>0,
                        'manage_template' => 0,
                        'manage_label' => 0,
                        );
}

Configuration ID AUF en utilisant https://redmine.auf.org/projects/auth/wiki/MiseEnPlaceSP

cd
openssl req -new -x509 -keyout key.pem -out cert.pem -nodes -days 3650 -newkey rsa:2048 -subj "/CN=sondages.auf.org"
chmod 0600 key.pem
chmod 0644 cert.pem
chown root:root key.pem cert.pem
mv key.pem /etc/ssl/private/saml-sondages.auf.org-key.pem
mv cert.pem /etc/ssl/certs/saml-sondages.auf.org-cert.pem
wget --no-check-certificate https://id.auf.org/idp/saml2/metadata -O- | tee -a /etc/ssl/saml-id.auf.org-metadata.xml

# rm /etc/ssl/private/saml-sondages.auf.org-key.pem # rm /etc/ssl/certs/saml-sondages.auf.org-cert.pem # rm /etc/ssl/saml-id.auf.org-metadata.xml # scp root@10.36.1.97:/etc/ssl/private/saml-sondages.auf.org-key.pem /etc/ssl/private/saml-sondages.auf.org-key.pem # scp root@10.36.1.97:/etc/ssl/certs/saml-sondages.auf.org-cert.pem /etc/ssl/certs/saml-sondages.auf.org-cert.pem # scp root@10.36.1.97:/etc/ssl/saml-id.auf.org-metadata.xml /etc/ssl/saml-id.auf.org-metadata.xml

apt-get install libapache2-mod-auth-mellon

ConfApache (ajouter dessus </VirtualHost>) /etc/apache2/sites-available/sondages.auf.org-ssl

    <Location />
        AuthType "Mellon"
        # si on veut imposer l'authentification avant d'accéder au site (100% privé)
        #MellonEnable "auth"
        # si on veut laisser le site web déclencher l'authentification (public + privé)
        MellonEnable "info"

        # les méta-données
                MellonDefaultLoginPath "/"
        MellonOrganizationName "sondages.auf.org"
        MellonOrganizationDisplayName "fr" "Sondages AUF"
        MellonOrganizationURL "http://www.auf.org"
        MellonSPPrivateKeyFile /etc/ssl/private/saml-sondages.auf.org-key.pem
        MellonSPCertFile /etc/ssl/certs/saml-sondages.auf.org-cert.pem
        MellonIdPMetadataFile /etc/ssl/saml-id.auf.org-metadata.xml

        # les conditions d'accès
        MellonUser "mail"
        MellonCond "mail" "^[^@]*@auf\.org$" [REG]
        #MellonCond "mail" "jean-christophe.andre@auf.org" [OR]
        #MellonCond "mail" "moussa.nombre@auf.org"
        #MellonCond "eduPersonAffiliation" "employee"
    </Location>

    <Location /mellon/>
        AuthType "Mellon"
        MellonEnable "info"
    </Location>

a2enmod auth_mellon
service apache2 restart

# /srv/www/sondages.auf.org/application/views/admin/authentication/login.php

diff /srv/www/sondages.auf.org/application/views/admin/authentication/login.php*
5,26d4
< <form id="id_auf">
<
< <p style="display: inline-block;
<     margin-right: 20px;
<     vertical-align: middle;
<     text-align: right"> <strong>Usagers de l'AUF&nbsp;:</strong>
< </p>
<
< <p style="display: inline-block;
<     vertical-align: middle;
<     text-align: right">
<
< <a href="https://sondages.auf.org/mellon/login?ReturnTo=/admin/" onmouseover="document.idauf_bouton.src='/styles/idauf_bouton_survol.png';" onmouseout="document.idauf_bouton.src='/styles/idauf_bouton.png';"><img id="idauf_bouton" src="/s\
tyles/idauf_bouton.png" height="32" width="200"></a>
<
< </p>
< </form>
<
<
< <p align="left"><strong>Pour les usagers qui n'ont pas d'adresse @auf.org,</strong><br>utilisez le formulaire de connexion suivant&nbsp;:</p>
<
<
<

Tests:

  • Login standard user
  • login ID
  • Creation du sondage avec utilisateur ID
    • Verifier s'il est possible de choisir le template
    • Verifier le template2014

LimeSurvey/De187Vers205 (dernière édition le 2015-02-20 21:50:26 par FredyPulido)