This is an old revision of the document!


Drupal 8 MultiSite Shibboleth

Installation de drupal en mode multisite et authentification + authorisation via fédération d'identité shibboleth .

Références

site primaire

installation

recuperation de l'archive courante et preparation de l'arborescence

[root@bois drup]# pwd
/var/www/drup/drup
[root@bois drup]# wget https://ftp.drupal.org/files/projects/drupal-8.3.1.tar.gz
--2017-04-20 11:12:38--  https://ftp.drupal.org/files/projects/drupal-8.3.1.tar.gz
[root@bois drup]# tar xvfz drupal-8.3.1.tar.gz
[root@bois drup]# ln -s drupal-8.3.1 drupal

modules php

drupal 8 a besoin de php 5.5, alors que c'est 5.1 qui est livré par defaut en centos 7

on commence par retirer les packages php 5.4 livré en centos 7 de base :

# yum remove php-common

Supprimé :
  php-common.x86_64 0:5.4.16-42.el7                                                                                                                    

Dépendances supprimées :
  php.x86_64 0:5.4.16-42.el7          php-cli.x86_64 0:5.4.16-42.el7   php-fpm.x86_64 0:5.4.16-42.el7       php-gd.x86_64 0:5.4.16-42.el7             
  php-intl.x86_64 0:5.4.16-42.el7     php-ldap.x86_64 0:5.4.16-42.el7  php-mbstring.x86_64 0:5.4.16-42.el7  php-mcrypt.x86_64 0:5.4.16-7.el7          
  php-mysql.x86_64 0:5.4.16-42.el7    php-pdo.x86_64 0:5.4.16-42.el7   php-pear.noarch 1:1.9.4-21.el7       php-pecl-zendopcache.x86_64 0:7.0.5-2.el7 
  php-process.x86_64 0:5.4.16-42.el7  php-soap.x86_64 0:5.4.16-42.el7  php-xml.x86_64 0:5.4.16-42.el7       php-xmlrpc.x86_64 0:5.4.16-42.el7   

puis on ajoute les repositories delivrant du php 5.5

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

on peux alors installer les modules php en 5.5 necessaires

 # yum install httpd php55w php55w-opcache php55w-mbstring php55w-gd php55w-xml php55w-pear php55w-fpm php55w-mysql
Installé :
  php55w.x86_64 0:5.5.38-1.w7         php55w-fpm.x86_64 0:5.5.38-1.w7       php55w-gd.x86_64 0:5.5.38-1.w7     php55w-mbstring.x86_64 0:5.5.38-1.w7  
  php55w-mysql.x86_64 0:5.5.38-1.w7   php55w-opcache.x86_64 0:5.5.38-1.w7   php55w-pear.noarch 1:1.10.1-1.w7   php55w-xml.x86_64 0:5.5.38-1.w7       

Dépendances installées :
  php55w-cli.x86_64 0:5.5.38-1.w7    php55w-common.x86_64 0:5.5.38-1.w7    php55w-pdo.x86_64 0:5.5.38-1.w7    php55w-process.x86_64 0:5.5.38-1.w7   

multisite considerations

[root@bois drupal]# mkdir sites/din
[root@bois drupal]# mkdir sites/dex
[root@bois drupal]# mkdir sites/din/files
[root@bois drupal]# mkdir sites/dex/files

[root@bois drupal]# locate default.settings.php
/var/www/drup/drup/drupal-8.3.1/sites/default/default.settings.php
[root@bois drupal]# cp /var/www/drup/drup/drupal-8.3.1/sites/default/default.settings.php sites/din/settings.php
[root@bois drupal]# cp /var/www/drup/drup/drupal-8.3.1/sites/default/default.settings.php sites/dex/settings.php

[root@bois default]# cp default.services.yml ../din/services.yml
[root@bois default]# cp default.services.yml ../dex/services.yml

declarations des sites dans sites.php

[root@bois sites]# cp example.sites.php sites.php
[root@bois sites]# vim sites.php 

on crée des liens vers les sous-sites via des liens

[root@bois drupal]# pwd
/var/www/drup/drup/drupal
[root@bois drupal]# ln -s ../drupal din
[root@bois drupal]# ls -l
total 236
-rw-r--r--  1 root root    262 19 avril 18:07 autoload.php
-rw-r--r--  1 root root   2309 19 avril 18:07 composer.json
-rw-r--r--  1 root root 152480 19 avril 18:07 composer.lock
drwxr-xr-x 12 root root   4096 19 avril 18:07 core
lrwxrwxrwx  1 root root      9  3 mai   16:37 dex -> ../drupal
-rw-r--r--  1 root root   1346 19 avril 18:07 example.gitignore
lrwxrwxrwx  1 root root      9  3 mai   16:39 din -> ../drupal
...

ou depuis le repertoire cible créé le lien en dur depuis la racine

[root@bois ex]# ln -s . /var/www/drup/drup/drupal/dex
[root@bois drupal]# ls -l dex
lrwxrwxrwx 1 root root 1  4 mai   11:03 dex -> .

il faut alors aller sur http://drup.domain.fr/drup/drupal/din/ pour installer le sous-sites “din”

conf apache

htaccess

il faut s'assurer que le .htaccess à la racine est bien executé et suis les liens symboliques dans notre mode multi-site

activation .htaccess

     <Directory /var/www/drup/drup/drupal>
                AllowOverride All
        </Directory>

dans le .htaccess à la racine du deploiement /var/www/drup/drup/drupal

# Follow symbolic links in this directory.
Options +FollowSymLinks

version drupal 7 avec shibd

Preparation de la configuration apache + anticipation sur les <Location> pour la suite avec shibboleth

[root@cms ]# cat /etc/httpd/conf.d/dup.conf 

<VirtualHost 157.158.11.129:80>
        ServerName dup.tem-tsp.eu
        ServerAlias dup.*
        DocumentRoot /var/www/dup/drupal
        ErrorLog logs/dup-error_log
        CustomLog logs/dup-access_log common

<Location />
ShibRequestSetting applicationId dup
</Location>

#https://wiki.aai.niif.hu/index.php?title=DrupalShibbolethReadmeDev
<Location /site1>
  AuthType Shibboleth
  ShibRequireSession Off
  # the following single line is only valid for Shib2
  ShibUseHeaders On
  require shibboleth
</Location>

<Location /site2>
  AuthType Shibboleth
  ShibRequireSession Off
  # the following single line is only valid for Shib2
  ShibUseHeaders On
  require shibboleth
</Location>
</VirtualHost>

#idem pour https
<VirtualHost 157.158.11.129:443>
        ServerName dup.tem-tsp.eu
        ServerAlias dup.*
        DocumentRoot /var/www/dup/drupal
        ErrorLog logs/ssl_dup-error_log
        CustomLog logs/ssl_dup-access_log common
        LogLevel warn
        SSLEngine on
	SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
        SSLCertificateFile /etc/pki/tls/certs/cert-10607--.tem-tsp.eu.pem
        SSLCertificateKeyFile /etc/pki/tls/private/tem-tsp_star_nop.key
	SSLCertificateChainFile /etc/pki/tls/certs/chain-10607--.tem-tsp.eu.pem
	SSLCACertificateFile /etc/pki/tls/certs/add_trust_external_ca_root.pem
<Location />
ShibRequestSetting applicationId dup
</Location>
...
</VirtualHost>

database

https://www.drupal.org/docs/7/install/step-2-create-the-database

sur le serveur mysql, preparer la database et les droits d'acces

MariaDB [(none)]> CREATE DATABASE drupcore CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE USER drupcoreuser@localhost IDENTIFIED BY 'secret'; 
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON drupcore.* TO 'drupcoreuser'@'localhost' IDENTIFIED BY 'secret';
Query OK, 0 rows affected (0.00 sec)

une autre database pour le sous-site “din”

MariaDB [(none)]> CREATE DATABASE drupdin CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE USER drupdinuser@localhost IDENTIFIED BY 'secret'; 
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON drupdin.* TO 'drupdineuser'@'localhost' IDENTIFIED BY 'secret';
Query OK, 0 rows affected (0.00 sec)

informations a retenir quand on lancera l'installation des sites via l'interface web drupal (drupcore database alias Drupal UPS core avec WanpassDrupCoreUserPoint) . .

configuration drupal 8

sur le tableau de bord (admin/reports/status) , 2 alertes importantes apparaissent

  1. PARAMÈTRES DES HÔTES DE CONFIANCE

on corrige en positionnant dans setting.php du site:

$settings['trusted_host_patterns'] = array(
    '^.+domain\.fr$',
    '^localhost$',
  1. RÉPERTOIRES DE CONFIGURATION ⇒ sites/din/settings.php doit définir la variable $config_directories

site primaire

Creation du site primaire (ici dup.tem-tsp.eu) dans la sous arborescence de sites

preparation du fichier settings.php depuis une copie du default et création du repertoir files, le tout en acces provisoirement largement ouverts pour poursuivre l'installation via la navigateur

[root@cms /var/www/dup/drupal/sites]# mkdir dup.tem-tsp.eu ; cd dup.tem-tsp.eu
[root@cms dup.tem-tsp.eu]# cp -a ../default/default.settings.php .
[root@cms dup.tem-tsp.eu]# cp default.settings.php settings.php
[root@cms dup.tem-tsp.eu]# mkdir files
[root@cms dup.tem-tsp.eu]# chmod 666 settings.php
[root@cms dup.tem-tsp.eu]# chmod 777 files

aller sur http://dup.tem-tsp.eu/ (pointra au final sur http://dup.tem-tsp.eu/install.php?profile=standard&locale=en )

sites secondaires

ici nous faisons usage d'une plateforme multisites en mode sous repertoires, donc le site site1 sera en url de type http://dup.tem-tsp.eu/site1 . Pour cela il faut creer un sous repertoire de type : dup.tem-tsp.eu.site1

[root@cms sites]# mkdir dups.tem-tsp.eu.site1
[root@cms sites]# cd dups.tem-tsp.eu.site1
[root@cms dup.tem-tsp.eu.site1]# cp ../default/default.settings.php .
[root@cms dup.tem-tsp.eu.site1]# cp default.settings.php settings.php
[root@cms dup.tem-tsp.eu.site1]# chmod 666 settings.php
[root@cms dup.tem-tsp.eu.site1]# mkdir files
[root@cms dup.tem-tsp.eu.site1]# chmod 775 files/
[root@cms dup.tem-tsp.eu.site1]# chgrp apache files/

lien symbolique

lien indispensable pour l'acces a l'url /sites1 pointe bien sur l'arborescence dup.tem-tsp.eu.site1

[root@cms dup.tem-tsp.eu.site1]# ln -s . /var/www/dups/drupal/site1

Installation du site secondaire via l'URL http://dup.tem-tsp.eu/site1 qui pointera vers install.php la premiere fois .

ensuite il faut retablir des droits d'acces aux fichiers de settings plus fermés !

[root@cms dup.tem-tsp.eu.site1]# chgrp apache settings.php
[root@cms dup.tem-tsp.eu.site1]# chmod 640 settings.php
[root@cms dup.tem-tsp.eu.site1]# ls -l
total 52
-rw-r--r-- 1 root root   23770 Dec 15 22:35 default.settings.php
drwxrwxr-x 3 root apache  4096 Dec 15 22:38 files
-rw-r----- 1 root apache 24094 Dec 15 22:38 settings.php

shibboleth

ref

Session SQL

[root@bois config]# vim config.php

/* 'store.type'                    => 'phpsession', */
    'store.type'                    => 'sql',
/*'store.sql.dsn'                 => 'sqlite:/path/to/sqlitedatabase.sq3',*/
    'store.sql.dsn'                 => 'sqlite:/var/www/drup/sqlitedb-dupsaml.sq3',

ne pas créer le fichier, i lle sera automatiquement

# ls -al /var/www/dup/sqlitedb-dupsaml.sq3 
-rw-r----- 1 apache apache 8192 28 avril 17:10 /var/www/drups/sqlitedb-dupssaml.sq3

en v7.X nous faisions usage du module drupal shib_auth qui permet une authentification shibboleth, mais aussi une affectation de role basé sur attributs shibboleth .

[root@cms modules]# wget http://ftp.drupal.org/files/projects/shib_auth-7.x-4.0.tar.gz
[root@cms modules]# tar xvfz shib_auth-7.x-4.0.tar.gz

activation et parameterage du module via l'interface web , detaiuls, cf https://wiki.aai.niif.hu/index.php?title=DrupalShibbolethReadmeDev