Skip to content
Snippets Groups Projects
Verified Commit 34a53c8d authored by Quentin Duchemin's avatar Quentin Duchemin
Browse files

[Mail] Support for LDAPS

parent 07c68bec
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,8 @@ Deux dossiers supplémentaires doivent exister :
Copier `mail.secrets.example` dans `mail.secrets` et remplacer les valeurs. Le mot de passe LDAP du compte `mail` est sur le [pass](https://gitlab.utc.fr/picasoft/interne/pass).
S'assurer que [TLS Certs Monitor](../pica-tls-certs-monitor) est lancé.
Lancer :
```bash
docker-compose up -d
......
......@@ -27,8 +27,9 @@ services:
- mail-mda-maildir:/home
- /DATA/docker/certs/mail.picasoft.net/:/certs-ssl/:ro
environment:
LDAP_ADDRESS: ldap.picasoft.net
LDAP_NSS_CN: cn=mail,ou=Services,dc=picasoft,dc=net
# Should be an URI, with ldap:// or ldaps://
LDAP_ADDRESS: ldaps://ldap.picasoft.net:636
LDAP_NSS_CN: cn=nss,dc=picasoft,dc=net
LDAP_BASE: dc=picasoft,dc=net
USER_FILTER: (uid=%n)
PASSWORD_FILTER: (uid=%n)
......@@ -62,11 +63,11 @@ services:
#domaines mails qu'on s'autorise à relayer (qui ont le droit de passer à travers notre serveur si ils sont en expéditeur ou destinataire)
RELAY_DOMAINS: picasoft.net
#réglage de la connexion au serveur LDAP: protocole (ldap ou ldaps), hôte et port
LDAP_PROTOCOL: ldap
LDAP_PROTOCOL: ldaps
LDAP_SERVER_HOSTNAME: ldap.picasoft.net
LDAP_PORT: 389
LDAP_PORT: 636
#réglage du bind : login d'un compte qui a suffisamment de droits pour lire l'arborescence (à l'exception des mots de passe)
LDAP_BIND_DN: cn=mail,ou=Services,dc=picasoft,dc=net
LDAP_BIND_DN: cn=nss,dc=picasoft,dc=net
#réglage de la manière dont on répertorie les comptes et les adresses existantes
#la config actuelle fait que la possession d'une adresse mail se fait ainsi : login => login@picasoft.net
#cependant, nous avons quand même deux couches différentes: l'existence d'un compte (SASL) et l'existence d'une adresse
......
......@@ -7,17 +7,13 @@ ENV DEBIAN_FRONTEND noninteractive
#installation des paquets debian
RUN apt-get update -y \
&& apt-get install -y \
dovecot-common dovecot-imapd dovecot-lmtpd dovecot-ldap \
dovecot-common dovecot-imapd dovecot-lmtpd dovecot-ldap ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& addgroup --gid 1000 vmail \
&& adduser --system --disabled-login --no-create-home --ingroup vmail --uid 500 vmail
### Définition des variables d'environnement.
# LDAP
ENV LDAP_ADDRESS ldap.test.picasoft.net
ENV LDAP_BASE dc=picasoft,dc=net
ENV LDAP_NSS_CN cn=mail,ou=Services,dc=picasoft,dc=net
ENV LDAP_DNPASS readonly
ENV USER_FILTER (uid=%n)
ENV PASSWORD_FILTER (uid=%n)
# SSL
......
......@@ -14,7 +14,8 @@
### Modification de /etc/dovecot/dovecot-ldap.conf.ext
# Définition de l'adresse du LDAP
sed -i 's/^#hosts =.*/hosts = '"${LDAP_ADDRESS}"'/' /etc/dovecot/dovecot-ldap.conf.ext
# L'URI peut contenir un /, on utilise @ pour séparer les champs de sed
sed -i 's@^#uris =.*@uris = '"${LDAP_ADDRESS}"'@' /etc/dovecot/dovecot-ldap.conf.ext
# Définition du distinguished name pour accéder au LDAP
sed -i 's/^#dn =.*/dn = '"${LDAP_NSS_CN}"'/' /etc/dovecot/dovecot-ldap.conf.ext
# Définition du mot de passe pour accéder au LDAP
......
......@@ -8,7 +8,7 @@ ENV DEBIAN_FRONTEND noninteractive
#installation des paquets debian
RUN apt-get update -y \
&& apt-get install -y \
postfix postfix-ldap libsasl2-modules sasl2-bin opendkim opendkim-tools rsyslog opendmarc \
postfix postfix-ldap libsasl2-modules sasl2-bin opendkim opendkim-tools rsyslog opendmarc ca-certificates \
&& rm -rf /var/lib/apt/lists/*
......@@ -20,16 +20,6 @@ ENV MY_HOSTNAME pica01-test.picasoft.net
#noms de domaines de courriers qu'on s'autorise à transmettre, séparés par des virgules (example.com, example2.com, example3.com)
ENV RELAY_DOMAINS picasoft.net
#SASL et binds (LDAP)
#serveur LDAP utilisé pour l'authentification LDAP
#attention, des informations sensibles (hashs de mots de passe) seront envoyées, il faut que le canal soit sécurisé (utiliser LDAPS au lieu de LDAP, ou encore STARTTLS sur LDAP)
#protocole : on pourrait utiliser LDAPS au lieu de LDAP
ENV LDAP_PROTOCOL ldap
ENV LDAP_SERVER_HOSTNAME ldap.test.picasoft.net
ENV LDAP_PORT 389
#compte utilisé par les démons saslauthd et virtual_mailbox pour lire l'arborescence LDAP
ENV LDAP_BIND_DN cn=readonly,dc=picasoft,dc=net
ENV LDAP_BIND_PW readonly
#niveau de l'arborescence à partir de laquelle les entrées sont considérées
ENV LDAP_SEARCH_BASE dc=picasoft,dc=net
......
......@@ -24,6 +24,9 @@ bind = yes
bind_dn = ${LDAP_BIND_DN}
bind_pw = ${LDAP_BIND_PW}
result_attribute = uid
# Mandatory for SSL : http://www.postfix.org/ldap_table.5.html
# Section LDAP SSL AND STARTTLS PARAMETERS
version = 3
EOF
postconf -e "virtual_mailbox_maps = ldap:/etc/postfix/ldap-virtual-mailbox-maps"
postconf -e "smtpd_sender_login_maps = ldap:/etc/postfix/ldap-virtual-mailbox-maps"
......@@ -73,6 +76,8 @@ postconf -e 'smtpd_sasl_local_domain = '
postconf -e 'smtpd_sasl_auth_enable = yes'
#autorise l'auth sasl seulement sur un canal tls
postconf -e 'smtpd_tls_auth_only = yes'
# Active SMTPS sur le port 465
postconf -e 'smtpd_tls_wrappermode = yes'
#autorise l'auth depuis des clients connus comme obsolètes/non standard (outlook) mais ne présentant pas de faille de sécurité
postconf -e 'broken_sasl_auth_clients = yes'
......@@ -81,7 +86,7 @@ cat <<EOF >> /etc/default/saslauthd-postfix
MECHANISMS="ldap"
MECH_OPTIONS=""
EOF
#on enlève le démon saslauthd par défaut de debian (nous utilisons saslauthd-postfix)
#on enlève le démon saslauthd par défaut de debian (nous utilisons le fichier saslauthd-postfix)
#ça ne change rien à part qu'il n'y a pas de warning dans les logs concernant un service non utilisé
rm /etc/default/saslauthd
#configuration de ce serveur LDAP
......
#
# Settings for saslauthd daemon
# Please read /usr/share/doc/sasl2-bin/README.Debian for details.
#
# Should saslauthd run automatically on startup? (default: no)
START=yes
......@@ -15,19 +10,6 @@ DESC="SASL Auth. Daemon for Postfix"
NAME="saslauthd-postf"
# Which authentication mechanisms should saslauthd use? (default: pam)
#
# Available options in this Debian package:
# getpwent -- use the getpwent() library function
# kerberos5 -- use Kerberos 5
# pam -- use PAM
# rimap -- use a remote IMAP server
# shadow -- use the local shadow password file
# sasldb -- use the local sasldb database file
# ldap -- use LDAP (configuration is in /etc/saslauthd.conf)
#
# Only one option may be used at a time. See the saslauthd man page
# for more information.
#
# Exemple: MECHANISMS="pam"
#paramètre par défaut enlevé, il sera inséré lors de l'entrypoint
......@@ -35,31 +17,9 @@ NAME="saslauthd-postf"
# See the saslauthd man page for information about mech-specific options.
# Exemple: MECH_OPTIONS=""
# How many saslauthd processes should we run? (default: 5)
# A value of 0 will fork a new process for each connection.
THREADS=5
# Other options (default: -c -m /var/run/saslauthd)
# Note: You MUST specify the -m option or saslauthd won't run!
#
# WARNING: DO NOT SPECIFY THE -d OPTION.
# The -d option will cause saslauthd to run in the foreground instead of as
# a daemon. This will PREVENT YOUR SYSTEM FROM BOOTING PROPERLY. If you wish
# to run saslauthd in debug mode, please run it by hand to be safe.
#
# See /usr/share/doc/sasl2-bin/README.Debian for Debian-specific information.
# See the saslauthd man page and the output of 'saslauthd -h' for general
# information about these options.
#
# Example for chroot Postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"
# Example for non-chroot Postfix users: "-c -m /var/run/saslauthd"
#
# To know if your Postfix is running chroot, check /etc/postfix/master.cf.
# If it has the line "smtp inet n - y - - smtpd" or "smtp inet n - - - - smtpd"
# then your Postfix is running in a chroot.
# If it has the line "smtp inet n - n - - smtpd" then your Postfix is NOT
# running in a chroot.
# Option -m sets working dir for saslauthd (contains socket)
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd" # postfix/smtp in chroot()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment