📍 Article principal du cluster : Mattermost 2026 : guide complet.
Une PME de 30 personnes utilise déjà Authentik pour SSO Vaultwarden, Forgejo, Outline, Plausible. Brancher Mattermost complète l’écosystème : un seul login pour tout. Bonus : audit logs structurés pour conformité ARTCI/CDP/NESA. Ce tutoriel détaille la configuration complète.
Prérequis
- Mattermost Team Edition en production (voir tutoriel installation).
- Authentik en production (voir tutoriel Authentik).
- Niveau attendu : avancé.
- Temps estimé : 45-60 minutes.
Limitations Mattermost Team Edition
Important : Mattermost Team Edition (open source) supporte GitLab OAuth et Google OAuth. SAML SSO et OpenID Connect requièrent Mattermost Enterprise (10 USD/user/mois). Workaround pour Team Edition : utiliser le mode GitLab OAuth pointé sur Authentik (Authentik émule GitLab OAuth via OIDC).
Étape 1 — Provider OIDC Authentik (mode GitLab compat)
Authentik admin → Providers → Create → OAuth2/OpenID Provider :
Name: mattermost-provider
Authentication flow: default-authentication-flow
Authorization flow: default-provider-authorization-explicit-consent
Client type: confidential
Redirect URIs: https://chat.votre-entreprise.com/signup/gitlab/complete
Scopes: openid email profile
Subject mode: based on user's email
Note client_id et client_secret.
Étape 2 — Application Authentik
Applications → Create :
Name: Mattermost
Slug: mattermost
Provider: mattermost-provider
Launch URL: https://chat.votre-entreprise.com
Étape 3 — Configurer Mattermost (mode GitLab OAuth)
System Console → Authentication → GitLab :
Enable GitLab OAuth: True
Application ID: client_id Authentik
Application Secret: client_secret Authentik
GitLab Site URL: https://auth.votre-entreprise.com
User API URL: https://auth.votre-entreprise.com/application/o/userinfo/
Authorize Endpoint: https://auth.votre-entreprise.com/application/o/authorize/
Token Endpoint: https://auth.votre-entreprise.com/application/o/token/
Étape 4 — Adapter Authentik pour répondre comme GitLab
Mattermost s’attend au format GitLab user JSON. Authentik nécessite un Property Mapping custom.
Authentik admin → Customisation → Property Mappings → Create OAuth2/OpenID Property Mapping :
Name: gitlab-compat
Scope name: openid
Expression:
return {
"id": user.pk,
"email": user.email,
"username": user.username,
"name": user.name,
}
Lier ce mapping au Provider Mattermost.
Étape 5 — Tester
Mode incognito → https://chat.votre-entreprise.com → bouton « Sign in with GitLab » apparaît. Cliquer.
Redirection auth.votre-entreprise.com → login + MFA → consent → retour Mattermost connecté.
Étape 6 — Restreindre par groupe Authentik
Authentik → Application Mattermost → Policy bindings → Group : chat-users (employés). Seuls membres peuvent ouvrir Mattermost.
Étape 7 — Désactiver email/password login
Une fois SSO testé : System Console → Authentication → Email → Enable Sign Up With Email : OFF. Tous forcés au SSO.
Conformité ARTCI / CDP / NESA
Étape 8 — Activer audit logs
System Console → Logging → Enable File Logging : ON. Format : JSON. Path : /var/log/mattermost/audit.log.
Logs incluent : login, logout, message_post, message_edit, message_delete, channel_create, channel_join, file_upload.
Étape 9 — Ingestion Loki
Promtail collecte /var/log/mattermost/audit.log et envoie vers Loki. Dashboard Grafana custom pour visualisation.
# Promtail config
scrape_configs:
- job_name: mattermost
static_configs:
- targets: [localhost]
labels:
job: mattermost-audit
__path__: /var/log/mattermost/audit.log
Étape 10 — Rétention 1 an minimum
Loki retention : 1 an pour audit logs. Coût : ~ 5 GB stockage / 30 personnes / an, négligeable.
Étape 11 — Export pour audit annuel
Préparer requête LogQL pour audit annuel :
{job="mattermost-audit"} | json | event_type="login" | __error__=""
Export CSV via Grafana Explore. À fournir à l’auditeur ARTCI/CDP sur demande.
Erreurs fréquentes
| Erreur | Cause | Solution |
|---|---|---|
| « GitLab user not found » | Property Mapping manquant | Configurer mapping gitlab-compat |
| Boucle redirection | Cookie domain | Vérifier base domain partagé |
| Email pas pré-rempli | Scope email manquant | Ajouter scope email Provider Authentik |
| Logs pas générés | Logging désactivé | System Console enable logging |
| Loki ne reçoit pas | Promtail mal configuré | Vérifier path access |
| Disk plein logs | Pas de logrotate | Configurer logrotate hebdo |
Adaptation au contexte ouest-africain
Trois précisions. Mattermost Enterprise vs Team Edition : pour < 50 users, Team Edition + GitLab OAuth Authentik suffit. Pour > 50 users + SAML obligatoire, Enterprise. Audit ARTCI : ARTCI demande typiquement 1 an de logs incluant qui s’est connecté quand. Loki retention 1 an + export CSV répond. Confidentialité dossiers clients : channels privés Mattermost + 2FA Authentik = sécurité équivalente avocat/médecin.
Tutoriels frères
FAQ
SAML possible Team Edition ? Non. Workaround GitLab OAuth via Authentik fonctionne pour 95% des cas.
Migration vers Enterprise ? Possible plus tard. Données conservées.
Multi-IdP ? Mattermost supporte un IdP à la fois.
Audit retention 5 ans ? Loki ou Postgres archive cold storage. ~ 25 GB pour 5 ans.
Compliance HIPAA ? Mattermost Enterprise inclut HIPAA-compliant features.
Pour aller plus loin
- 🔝 Retour au pilier : Guide complet Mattermost 2026
- Documentation SSO : docs.mattermost.com/onboard/sso-gitlab