Taille: 10075
Commentaire: 1er jet
|
Taille: 6111
Commentaire: Aucunement besoin des dossiers 64bits
|
Texte supprimé. | Texte ajouté. |
Ligne 3: | Ligne 3: |
<<TableOfContents>> | |
Ligne 5: | Ligne 6: |
== Échanges avec Inverse == {{{ Le mainteneur de CrudeSAML a publié une nouvelle version avec mes correctifs: http://ftp.espci.fr/pub/crudesaml/crudesaml-1.4.tar.gz ******** J'ai terminé l'implémentation du support SAML dans SOGo en vue de se connecter à Dovecot via le module PAM/SASL crudesaml. À l'aide de l'auteur de crudesaml, j'ai dû adapter le code de trois composants (en plus de SOGo): - Dovecot pour accepter des "mots de passe" de plus de 1000 caractères - liblasso pour qu'il exporte la fonction utilisée par crudesaml - crudesaml pour réduire le nombre de warnings et de prototypes mal configurés lors de la compilation. Je joins ces patches à ce message, même si j'ai déja envoyé l'un d'eux à Jean-Christophe. Au niveau de SOGo, la fonctionnalité sera présente dans la version 2.0.3 de SOGo. Et le guide d'installation a été mis à jour concernant les nouvelles directives de configuration. Notez que j'ai utilisé simplesamlphp comme idp. Je vous suggèrerais de tester les nightly builds de demain pour corriger tout éventuel problème le plus vite possible. ********* >> Peux-tu me dire quelle patch ne s'applique pas correctement? > Celui pour Dovecot, qui est super simple (1 seule ligne) avec Dovecot 2.x (Debian testing) mais pour lequel nous n'avons pas trouvé d'équivalent dans le code source de Dovecot 1.x (Debian stable). Avec v1.2, ca devrait fonctionner, car on a dans le code: ./src/login-common/client-common.h:#define LOGIN_MAX_INBUF_SIZE 8192 }}} |
|
Ligne 49: | Ligne 10: |
* sogo (nightly) : 2.0.0.20130218-1 | * sogo : 2.2.16-1 |
Ligne 51: | Ligne 12: |
== installation "manuelle" des paquets requis == * lasso (https://dev.entrouvert.org/lasso/lasso-2.3.6.tar.gz) |
== Configuration de SOGo == * modification de la config SOGo : {{{ /* SAML */ SOGoAuthenticationType = saml2; SOGoSAML2CertificateLocation = "/etc/ssl/certs/saml-sogo-test-saml.ca.auf.org-cert.pem"; SOGoSAML2PrivateKeyLocation = "/etc/ssl/private/saml-sogo-test-saml.ca.auf.org-key.pem"; SOGoSAML2IdpCertificateLocation = "/etc/ssl/certs/GandiStandardSSLCA.pem"; SOGoSAML2IdpMetadataLocation = "/etc/ssl/saml-id.auf.org-metadata.xml"; SOGoSAML2IdpPublicKeyLocation = /etc/ssl/certs/_.auf.org-cert.pem; SOGoSAML2LogoutEnabled = YES; SOGoSAML2LogoutURL = "http://sogo.auf.org"; }}} * Adapter les droits {{{ chgrp sogo /etc/ssl/private/saml-sogo-test-saml.ca.auf.org-key.pem chmod g+r /etc/ssl/private/saml-sogo-test-saml.ca.auf.org-key.pem adduser sogo ssl-cert }}} * restart de SOGo == Compilation de Lasso et CrudeSAML == * [[https://dev.entrouvert.org/lasso/lasso-2.3.6.tar.gz|lasso]] (on appliquera le patch de Wolfgang) |
Ligne 59: | Ligne 44: |
* lire le `INSTALL` pour l'installation (./configure ; make ; make install) * ./configure |
* appliquer le [[attachment:lasso-export.diff|patch de Inverse]] : `patch -p0 < lasso-export.diff` * ./configure ; make ; make install (lire le `INSTALL`) |
Ligne 64: | Ligne 49: |
* Cyrus SASL (ftp://ftp.cyrusimap.org/cyrus-sasl/cyrus-sasl-2.1.26.tar.gz) * ./configure --prefix=/opt/cyrus-sasl |
* aptitude install libsasl2-dev |
Ligne 67: | Ligne 51: |
* modifier : fichier configure | * modif du fichier plugin_common.h {{{ #include <saslplug.h> : +typedef int (*sasl_callback_ft)(void); }}} * patch apporté par JC {{{ 2ème problème : il y avait un souci dans l'interprétation des dates SAML par le module PAM. Nous avons « hacké » ça en quelques lignes de code C pour supprimer automatiquement les microsecondes quand elles sont présentes : elles ne sont pas vraiment utiles et elles ne sont pas comprises par la fonction C "strptime". }}} . L'erreur rencontrée est la suivante {{{ Aug 19 15:45:32 sogo-test-saml auth: SAML assertion AuthnStatement AuthnInstant = -1 Aug 19 15:45:32 sogo-test-saml auth: invalid authn AuthnInstant 2015-08-19T19:40:40.652611Z }}} {{{ root@sogo-test-saml:/# git diff usr/local/src/crudesaml-1.4/saml.c diff --git a/usr/local/src/crudesaml-1.4/saml.c b/usr/local/src/crudesaml-1.4/saml.c index 415479a..f3121bb 100644 --- a/usr/local/src/crudesaml-1.4/saml.c +++ b/usr/local/src/crudesaml-1.4/saml.c @@ -153,9 +153,15 @@ saml_get_date(date) struct tm tm; const char *format = "%Y-%m-%dT%TZ"; - if (strptime(date, format, &tm) == NULL) - return (time_t)-1; + char *date2 = strdup(date); + if (strchr(date2,'.') != NULL && strchr(date2,'Z') != NULL) + strcpy(strchr(date2,'.'), strchr(date2,'Z')); + if (strptime(date2, format, &tm) == NULL){ + free(date2); + return (time_t)-1; + } + free(date2); return (timegm(&tm)); } root@sogo-test-saml:/# }}} * {{{ ./configure && make && make install }}} * les librairies aux bons endroits : |
Ligne 69: | Ligne 100: |
10900 -LIBS="-lsasl $LIBS" +LIBS="-lsasl2 $LIBS" 10935 - LIBS="-lsasl $LIBS" + LIBS="-lsasl2 $LIBS" }}} *./configure --prefix=/opt/crudesaml --with-sasls=/opt/cyrus-sasl * modifier : fichier Makefile {{{ -libsaml_la_CFLAGS = -I/usr/include/sasl +libsaml_la_CFLAGS = -I/opt/cyrus-sasl/include/sasl }}} * make * make install {{{ root@sogo-test-saml:/usr/local/src/crudesaml-1.4# make install make[1]: Entering directory `/usr/local/src/crudesaml-1.4' make[1]: Nothing to be done for `install-exec-am'. /bin/mkdir -p '/usr/local/share/man/man5' /usr/bin/install -c -m 644 pam_saml.5 cy2_saml.5 '/usr/local/share/man/man5' /bin/mkdir -p '/opt/cyrus-sasl/lib/sasl2' /bin/bash ./libtool --mode=install /usr/bin/install -c libsaml.la '/opt/cyrus-sasl/lib/sasl2' libtool: install: /usr/bin/install -c .libs/libsaml.so.0.2.0 /opt/cyrus-sasl/lib/sasl2/libsaml.so.0.2.0 libtool: install: (cd /opt/cyrus-sasl/lib/sasl2 && { ln -s -f libsaml.so.0.2.0 libsaml.so.0 || { rm -f libsaml.so.0 && ln -s libsaml.so.0.2.0 libsaml.so.0; }; }) libtool: install: (cd /opt/cyrus-sasl/lib/sasl2 && { ln -s -f libsaml.so.0.2.0 libsaml.so || { rm -f libsaml.so && ln -s libsaml.so.0.2.0 libsaml.so; }; }) libtool: install: /usr/bin/install -c .libs/libsaml.lai /opt/cyrus-sasl/lib/sasl2/libsaml.la libtool: install: /usr/bin/install -c .libs/libsaml.a /opt/cyrus-sasl/lib/sasl2/libsaml.a libtool: install: chmod 644 /opt/cyrus-sasl/lib/sasl2/libsaml.a libtool: install: ranlib /opt/cyrus-sasl/lib/sasl2/libsaml.a libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /opt/cyrus-sasl/lib/sasl2 ---------------------------------------------------------------------- Libraries have been installed in: /opt/cyrus-sasl/lib/sasl2 If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- /bin/mkdir -p '/usr/local/lib/security' /bin/bash ./libtool --mode=install /usr/bin/install -c pam_saml.la '/usr/local/lib/security' libtool: install: /usr/bin/install -c .libs/pam_saml.so.0.2.0 /usr/local/lib/security/pam_saml.so.0.2.0 libtool: install: (cd /usr/local/lib/security && { ln -s -f pam_saml.so.0.2.0 pam_saml.so.0 || { rm -f pam_saml.so.0 && ln -s pam_saml.so.0.2.0 pam_saml.so.0; }; }) libtool: install: (cd /usr/local/lib/security && { ln -s -f pam_saml.so.0.2.0 pam_saml.so || { rm -f pam_saml.so && ln -s pam_saml.so.0.2.0 pam_saml.so; }; }) libtool: install: /usr/bin/install -c .libs/pam_saml.lai /usr/local/lib/security/pam_saml.la libtool: install: /usr/bin/install -c .libs/pam_saml.a /usr/local/lib/security/pam_saml.a libtool: install: chmod 644 /usr/local/lib/security/pam_saml.a libtool: install: ranlib /usr/local/lib/security/pam_saml.a libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /usr/local/lib/security ---------------------------------------------------------------------- Libraries have been installed in: /usr/local/lib/security If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- make[1]: Leaving directory `/usr/local/src/crudesaml-1.4' root@sogo-test-saml:/usr/local/src/crudesaml-1.4# |
root@sogo-test-saml:/usr/lib/sasl2# chmod -x /lib/sasl2/*.so* root@sogo-test-saml:/usr/lib/sasl2# cp -aiv /lib/sasl2/*.so* /usr/lib/i386-linux-gnu/sasl2/ root@sogo-test-saml:/usr/lib/sasl2# chown root:root /usr/local/lib/security/*.so* root@sogo-test-saml:/usr/lib/sasl2# chmod -x /usr/local/lib/security/*.so* root@sogo-test-saml:/usr/lib/sasl2# cp -aiv /usr/local/lib/security/pam_saml.so.0.2.0 /lib/i386-linux-gnu/security/pam_saml.so |
Ligne 150: | Ligne 107: |
== Configuration de SOGo == * modification de la config SOGo : |
* vérification {{{ root@sogo-test-saml:/usr/lib/sasl2# aptitude install sasl2-bin root@sogo-test-saml:/usr/lib/sasl2# saslpluginviewer Plugin "saml" [loaded], API version: 4 SASL mechanism: SAML, best SSF: 0 security flags: NO_ANONYMOUS features: WANT_CLIENT_FIRST|PROXY_AUTHENTICATION }}} == Dovecot pour authentification SAML == * `/etc/pam.d/dovecot` |
Ligne 153: | Ligne 120: |
defaults -u sogo write sogod SOGoAuthenticationType "saml2" defaults -u sogo write sogod SOGoSAML2PrivateKeyLocation "/etc/ssl/certs/saml-sogo-test-saml.ca.auf.org-cert.pem" defaults -u sogo write sogod SOGoSAML2CertiticateLocation "/etc/ssl/private/saml-sogo-test-saml.ca.auf.org-key.pem" defaults -u sogo write sogod SOGoSAML2IdpMetadataLocation "/etc/ssl/saml-id.auf.org-metadata.xml" defaults -u sogo write sogod SOGoSAML2IdpPublicKeyLocation "/etc/ssl/certs/_.auf.org-cert.pem" defaults -u sogo write sogod SOGoSAML2IdpCertificateLocation "etc/ssl/certs/GandiStandardSSLCA.pem" defaults -u sogo write sogod SOGoSAML2LogoutEnabled yes |
#%PAM-1.0 # SAML : cf man pam_saml # http://www.ossir.org/paris/supports/2010/2010-02-09/saml.pdf #auth required pam_saml.so grace=86400 userid=uid idp=/etc/ssl/saml-id.auf.org-metadata.xml trusted_sp=https://sogo-test-saml.ca.auf.org/SOGo/saml2-metadata saml_check_session_timeframe=0 saml_check_assertion_timeframe=0 auth required pam_saml.so grace=600 userid=uid idp=/etc/ssl/saml-id.auf.org-metadata.xml trusted_sp=https://sogo-test-saml.ca.auf.org/SOGo/saml2-metadata account required pam_permit.so session required pam_permit.so |
Ligne 162: | Ligne 131: |
A VOIR : SOGoSAML2IdpPublicKeyLocation et SOGoSAML2IdpCertificateLocation ont été positionnés sur les certificats utilisés par id.auf.org. . est-ce bien ça qu'il faut mettre ici ? |
* Patcher Dovecot (version 2.1.7) pour agrandir la taille du buffer de connexion * récupérer le paquet source {{{ root@sogo-test-saml:~# echo "deb-src http://ftp2.ca.debian.org/debian wheezy main contrib" >> /etc/apt/sources.list root@sogo-test-saml:~# apt-get update root@sogo-test-saml:~# apt-get source dovecot-core root@sogo-test-saml:~# cd dovecot-2.1.7 }}} * appliquer le [[attachment:auf-saml.patch|patch]] `root@sogo-test-saml:~# patch -p1 < /root/auf-saml.patch` * mettre à jour le changelog `root@sogo-test-saml:~# dch -l ~auf7` * commiter les changements `dpkg-source --commit` * reconstruire les paquets Debian : `debuild -us -uc` * réinstaller les paquets : `debi` |
Ligne 165: | Ligne 144: |
* restart de SOGo * test N°1 : récupération des métadata : https://sogo-test-saml.ca.auf.org/SOGo/saml2-metadata {{{ Feb 19 16:41:35 sogod [31252]: |SOGo| starting method 'GET' on uri '/SOGo/saml2-metadata' Feb 19 16:41:35 sogod [31252]: [ERROR] [so-action 0x0xb8623808 SOGoSAML2Actions] did not find action class: SOGoSAML2Actions Feb 19 16:41:35 sogod [31252]: [ERROR] [so-action 0x0xb8354ef8 SOGoSAML2Actions] did not find method 'SOGoSAML2Actions' 2013-02-19 16:41:35.370 sogod[31252] <MySQL4Channel[0x0xb83876f0] connection=0x0xb82430b8> SQL: SELECT * FROM auf_users WHERE (c_uid = 'saml2-metadata') OR (mail_pays = 'saml2-metadata') OR (mail = 'saml2-metadata'); 2013-02-19 16:41:35.370 sogod[31252] <MySQL4Channel[0x0xb83876f0] connection=0x0xb82430b8> query has results, entering fetch-mode. 2013-02-19 16:41:35.370 sogod[31252] <MySQL4Channel[0x0xb83876f0] connection=0x0xb82430b8> SQL: SELECT c_uid FROM auf_users WHERE (c_uid = 'saml2-metadata') AND (source = 'LOCAL'); 2013-02-19 16:41:35.371 sogod[31252] <MySQL4Channel[0x0xb83876f0] connection=0x0xb82430b8> query has results, entering fetch-mode. Feb 19 16:41:35 sogod [31252]: [ERROR] [so-action 0x0xb85eb460 SOGoSAML2Actions] did not find action class: SOGoSAML2Actions Feb 19 16:41:35 sogod [31252]: [ERROR] [so-action 0x0xb8354ef8 SOGoSAML2Actions] did not find method 'SOGoSAML2Actions' Feb 19 16:41:35 sogod [31252]: [ERROR] [so-action 0x0xb85a2670 SOGoSAML2Actions] did not find action class: SOGoSAML2Actions Feb 19 16:41:35 sogod [31252]: [ERROR] [so-action 0x0xb8354ef8 SOGoSAML2Actions] did not find method 'SOGoSAML2Actions' Feb 19 16:41:35 sogod [31252]: |SOGo| request took 0.002779 seconds to execute 10.36.1.4 - - [19/Feb/2013:16:41:35 GMT] "GET /SOGo/saml2-metadata HTTP/1.1" 404 43/0 0.004 - - 0 }}} |
== Côté IdP == Les attributs à fournir : * pour SOGo : nom, prénom, adél * pour Dovecot : nom, prénom, adél, uid (pour nous (id.auf) '''Attribute policy :''' '''''Default+''''') ---- |
Sommaire
Tests d'intégration SOGo et SAML
Serveur de test
copie du CT sogo-test.ca.auf.org ==> sogo-test-saml.ca.auf.org
- installation en local de : dovecot-imapd (1:1.2.15-7) + postfix
- sogo : 2.2.16-1
Configuration de SOGo
- modification de la config SOGo :
/* SAML */ SOGoAuthenticationType = saml2; SOGoSAML2CertificateLocation = "/etc/ssl/certs/saml-sogo-test-saml.ca.auf.org-cert.pem"; SOGoSAML2PrivateKeyLocation = "/etc/ssl/private/saml-sogo-test-saml.ca.auf.org-key.pem"; SOGoSAML2IdpCertificateLocation = "/etc/ssl/certs/GandiStandardSSLCA.pem"; SOGoSAML2IdpMetadataLocation = "/etc/ssl/saml-id.auf.org-metadata.xml"; SOGoSAML2IdpPublicKeyLocation = /etc/ssl/certs/_.auf.org-cert.pem; SOGoSAML2LogoutEnabled = YES; SOGoSAML2LogoutURL = "http://sogo.auf.org";
Adapter les droits
chgrp sogo /etc/ssl/private/saml-sogo-test-saml.ca.auf.org-key.pem chmod g+r /etc/ssl/private/saml-sogo-test-saml.ca.auf.org-key.pem adduser sogo ssl-cert
- restart de SOGo
Compilation de Lasso et CrudeSAML
lasso (on appliquera le patch de Wolfgang)
- pré-requis :
- aptitude install zlib1g-dev
- aptitude install pkg-config
configure: error: Package requirements (glib-2.0 >= 2.4.0 gobject-2.0 >= 2.4.0 libxml-2.0 xmlsec1 >= 1.2.6 xmlsec1-openssl >= 1.2.6 openssl) were not met :
aptitude install libglib2.0-dev (==> glib-2.0 >= 2.4.0 gobject-2.0)
aptitude install libxmlsec1-dev ==> libxml-2.0 xmlsec1 >= 1.2.6 xmlsec1-openssl >= 1.2.6 openssl
appliquer le patch de Inverse : patch -p0 < lasso-export.diff
./configure ; make ; make install (lire le INSTALL)
- pré-requis :
crudesaml (http://ftp.espci.fr/pub/crudesaml/crudesaml-1.4.tar.gz)
- pré-requis :
- aptitude install libsasl2-dev
- aptitude install libpam0g-dev
- modif du fichier plugin_common.h
#include <saslplug.h> : +typedef int (*sasl_callback_ft)(void);
- patch apporté par JC
2ème problème : il y avait un souci dans l'interprétation des dates SAML par le module PAM. Nous avons « hacké » ça en quelques lignes de code C pour supprimer automatiquement les microsecondes quand elles sont présentes : elles ne sont pas vraiment utiles et elles ne sont pas comprises par la fonction C "strptime".
L'erreur rencontrée est la suivante
Aug 19 15:45:32 sogo-test-saml auth: SAML assertion AuthnStatement AuthnInstant = -1 Aug 19 15:45:32 sogo-test-saml auth: invalid authn AuthnInstant 2015-08-19T19:40:40.652611Z
root@sogo-test-saml:/# git diff usr/local/src/crudesaml-1.4/saml.c diff --git a/usr/local/src/crudesaml-1.4/saml.c b/usr/local/src/crudesaml-1.4/saml.c index 415479a..f3121bb 100644 --- a/usr/local/src/crudesaml-1.4/saml.c +++ b/usr/local/src/crudesaml-1.4/saml.c @@ -153,9 +153,15 @@ saml_get_date(date) struct tm tm; const char *format = "%Y-%m-%dT%TZ"; - if (strptime(date, format, &tm) == NULL) - return (time_t)-1; + char *date2 = strdup(date); + if (strchr(date2,'.') != NULL && strchr(date2,'Z') != NULL) + strcpy(strchr(date2,'.'), strchr(date2,'Z')); + if (strptime(date2, format, &tm) == NULL){ + free(date2); + return (time_t)-1; + } + free(date2); return (timegm(&tm)); } root@sogo-test-saml:/#
./configure && make && make install
- les librairies aux bons endroits :
root@sogo-test-saml:/usr/lib/sasl2# chmod -x /lib/sasl2/*.so* root@sogo-test-saml:/usr/lib/sasl2# cp -aiv /lib/sasl2/*.so* /usr/lib/i386-linux-gnu/sasl2/ root@sogo-test-saml:/usr/lib/sasl2# chown root:root /usr/local/lib/security/*.so* root@sogo-test-saml:/usr/lib/sasl2# chmod -x /usr/local/lib/security/*.so* root@sogo-test-saml:/usr/lib/sasl2# cp -aiv /usr/local/lib/security/pam_saml.so.0.2.0 /lib/i386-linux-gnu/security/pam_saml.so
- vérification
root@sogo-test-saml:/usr/lib/sasl2# aptitude install sasl2-bin root@sogo-test-saml:/usr/lib/sasl2# saslpluginviewer Plugin "saml" [loaded], API version: 4 SASL mechanism: SAML, best SSF: 0 security flags: NO_ANONYMOUS features: WANT_CLIENT_FIRST|PROXY_AUTHENTICATION
- pré-requis :
Dovecot pour authentification SAML
/etc/pam.d/dovecot
#%PAM-1.0 # SAML : cf man pam_saml # http://www.ossir.org/paris/supports/2010/2010-02-09/saml.pdf #auth required pam_saml.so grace=86400 userid=uid idp=/etc/ssl/saml-id.auf.org-metadata.xml trusted_sp=https://sogo-test-saml.ca.auf.org/SOGo/saml2-metadata saml_check_session_timeframe=0 saml_check_assertion_timeframe=0 auth required pam_saml.so grace=600 userid=uid idp=/etc/ssl/saml-id.auf.org-metadata.xml trusted_sp=https://sogo-test-saml.ca.auf.org/SOGo/saml2-metadata account required pam_permit.so session required pam_permit.so
- Patcher Dovecot (version 2.1.7) pour agrandir la taille du buffer de connexion
récupérer le paquet source
root@sogo-test-saml:~# echo "deb-src http://ftp2.ca.debian.org/debian wheezy main contrib" >> /etc/apt/sources.list root@sogo-test-saml:~# apt-get update root@sogo-test-saml:~# apt-get source dovecot-core root@sogo-test-saml:~# cd dovecot-2.1.7
appliquer le patch root@sogo-test-saml:~# patch -p1 < /root/auf-saml.patch
mettre à jour le changelog root@sogo-test-saml:~# dch -l ~auf7
commiter les changements dpkg-source --commit
reconstruire les paquets Debian : debuild -us -uc
réinstaller les paquets : debi
Côté IdP
Les attributs à fournir :
- pour SOGo : nom, prénom, adél
pour Dovecot : nom, prénom, adél, uid (pour nous (id.auf) Attribute policy : Default+)