Skip to main content

Mattermost

Ce guide vous explique comment configurer l'authentification unique (SSO) entre SmartLink et Mattermost. Mattermost supporte à la fois SAML2 et OpenID Connect dans les éditions Professional et Enterprise.

Prérequis

  • Mattermost version 5.0+ (SAML2) ou 5.35+ (OpenID Connect)
  • Mattermost Professional ou Enterprise Edition
  • Accès administrateur système à Mattermost
  • Application configurée dans SmartLink

Configuration avec OpenID Connect (Recommandé)

1. Créer l'application

  1. Connectez-vous à SmartLink en tant qu'administrateur
  2. Allez dans ApplicationsAjouter
  3. Créez une nouvelle application :
    • Nom : Mattermost
    • URL : https://mattermost.example.com
    • Description : Plateforme de messagerie d'équipe
    • Icône : Choisissez l'icône Mattermost

2. Configurer OpenID Connect

  1. Dans l'onglet Authentification
  2. Sélectionnez OpenID Connect
  3. Notez les informations :
    • Client ID : mattermost-xxxxxx
    • Client Secret : secret-xxxxxx
    • Issuer URL : https://votre-smartlink.link.vaultys.org
    • App ID : [appid] (identifiant unique de l'application dans SmartLink)

3. URLs de redirection

Ajoutez dans URLs de redirection autorisées :

https://mattermost.example.com/signup/openid/complete
https://mattermost.example.com/login/openid/complete

4. Scopes requis

  • openid
  • profile
  • email
  • groups (optionnel, pour la synchronisation des équipes)

Configuration dans Mattermost

1. Via l'interface System Console

  1. Connectez-vous en tant qu'administrateur système
  2. Allez dans System ConsoleAuthenticationOpenID Connect
  3. Activez Enable OpenID Connect Authentication

2. Configuration des paramètres

Configurez les champs suivants :

  • Select OpenID Connect Service Provider : Custom
  • Button Name : SmartLink SSO
  • Button Color : #0066CC
  • Discovery Endpoint : https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/.well-known/openid-configuration
  • Client ID : mattermost-xxxxxx
  • Client Secret : secret-xxxxxx

3. Configuration avancée (optionnel)

Si la découverte automatique ne fonctionne pas, configurez manuellement :

  • Authorization Endpoint : https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/authorize
  • Token Endpoint : https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/token
  • User API Endpoint : https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/userinfo

4. Mapping des attributs

  • ID Attribute : sub
  • Username Attribute : email
  • Email Attribute : email
  • First Name Attribute : given_name
  • Last Name Attribute : family_name
  • Nickname Attribute : nickname
  • Position Attribute : title
  • Language Attribute : locale
  • Picture Attribute : picture

Configuration via config.json

Pour une configuration par fichier :

{
"GitLabSettings": {
"Enable": true,
"Secret": "",
"Id": "",
"Scope": "",
"AuthEndpoint": "",
"TokenEndpoint": "",
"UserApiEndpoint": "",
"DiscoveryEndpoint": "https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/.well-known/openid-configuration",
"ButtonText": "SmartLink SSO",
"ButtonColor": "#0066CC"
},
"OpenIdSettings": {
"Enable": true,
"Secret": "secret-xxxxxx",
"Id": "mattermost-xxxxxx",
"Scope": "openid profile email groups",
"AuthEndpoint": "https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/authorize",
"TokenEndpoint": "https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/token",
"UserApiEndpoint": "https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/userinfo",
"DiscoveryEndpoint": "https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/.well-known/openid-configuration",
"ButtonText": "SmartLink SSO",
"ButtonColor": "#0066CC"
}
}

Configuration avec SAML2

1. Configurer SAML2

  1. Dans l'application Mattermost
  2. Onglet AuthentificationSAML2
  3. Configurez :
    • Entity ID : https://mattermost.example.com
    • ACS URL : https://mattermost.example.com/login/sso/saml
    • Format NameID : emailAddress ou persistent

2. Télécharger les métadonnées

  • Métadonnées IdP : https://votre-smartlink.link.vaultys.org/api/saml2/[appid]/metadata
  • URL SSO : https://votre-smartlink.link.vaultys.org/api/saml2/[appid]/sso
  • URL SLO : https://votre-smartlink.link.vaultys.org/api/saml2/[appid]/slo
  • Certificat X.509 : Téléchargez depuis SmartLink

Configuration dans Mattermost

1. Via System Console

  1. System ConsoleAuthenticationSAML 2.0
  2. Activez Enable Login With SAML 2.0

2. Configuration des paramètres SAML

  • Identity Provider Metadata URL : https://votre-smartlink.link.vaultys.org/api/saml2/[appid]/metadata

Ou configuration manuelle :

  • SAML SSO URL : https://votre-smartlink.link.vaultys.org/api/saml2/[appid]/sso
  • Identity Provider Issuer URL : https://votre-smartlink.link.vaultys.org
  • Identity Provider Public Certificate : Collez le certificat X.509

3. Configuration Service Provider

  • Service Provider Identifier : https://mattermost.example.com
  • Verify Signature : true
  • Enable Encryption : false

4. Mapping des attributs SAML

  • Email Attribute : email
  • Username Attribute : username
  • Id Attribute : uid
  • First Name Attribute : firstName
  • Last Name Attribute : lastName
  • Nickname Attribute : nickname
  • Position Attribute : title
  • Language Attribute : preferredLanguage
  • Login Button Text : Se connecter avec SmartLink

Synchronisation des équipes et canaux

Configuration des groupes SCIM

Pour synchroniser automatiquement les équipes :

  1. System ConsoleGroups
  2. Activez Enable AD/LDAP Group Sync
  3. Configurez le mapping des groupes :
{
"GroupSettings": {
"EnableCustomUserGroups": true,
"EnableSyncWithLdap": true,
"EnableSyncWithSaml": true
}
}

Mapping automatique des équipes

{
"TeamSettings": {
"EnableOpenIDConnectGroupSync": true,
"GroupsField": "groups",
"TeamMapping": {
"smartlink-dev": "development-team",
"smartlink-marketing": "marketing-team",
"smartlink-support": "support-team"
}
}
}

Création automatique de canaux

Script pour créer automatiquement des canaux basés sur les groupes :

#!/bin/bash
# Créer des canaux pour chaque groupe

mmctl auth login https://mattermost.example.com \
--name production \
--username admin \
--password-file password.txt

# Créer les équipes
mmctl team create --name development --display-name "Development"
mmctl team create --name marketing --display-name "Marketing"

# Créer les canaux
mmctl channel create --team development --name backend --display-name "Backend"
mmctl channel create --team development --name frontend --display-name "Frontend"
mmctl channel create --team marketing --name campaigns --display-name "Campaigns"

Configuration Docker

Docker Compose avec OpenID Connect

version: '3.8'

services:
mattermost:
image: mattermost/mattermost-enterprise-edition:latest
container_name: mattermost
restart: unless-stopped
environment:
# Database
- MM_SQLSETTINGS_DRIVERNAME=postgres
- MM_SQLSETTINGS_DATASOURCE=postgres://mattermost:mattermost@db:5432/mattermost?sslmode=disable

# OpenID Connect
- MM_OPENIDSETTINGS_ENABLE=true
- MM_OPENIDSETTINGS_ID=mattermost-xxxxxx
- MM_OPENIDSETTINGS_SECRET=secret-xxxxxx
- MM_OPENIDSETTINGS_DISCOVERYENDPOINT=https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/.well-known/openid-configuration
- MM_OPENIDSETTINGS_BUTTONTEXT=SmartLink SSO
- MM_OPENIDSETTINGS_BUTTONCOLOR=#0066CC

# Site URL
- MM_SERVICESETTINGS_SITEURL=https://mattermost.example.com

# File storage
- MM_FILESETTINGS_DIRECTORY=/mattermost/data/

volumes:
- ./data:/mattermost/data
- ./config:/mattermost/config
- ./logs:/mattermost/logs
- ./plugins:/mattermost/plugins
ports:
- "8065:8065"
depends_on:
- db

db:
image: postgres:13-alpine
restart: unless-stopped
environment:
- POSTGRES_USER=mattermost
- POSTGRES_PASSWORD=mattermost
- POSTGRES_DB=mattermost
volumes:
- postgres_data:/var/lib/postgresql/data

volumes:
postgres_data:

Gestion des permissions

Rôles système

Configuration du mapping des rôles :

{
"OpenIdSettings": {
"AdminAttribute": "is_admin",
"AdminAttributeValue": "true",
"SystemAdminRoles": ["smartlink-admins"],
"TeamAdminRoles": ["smartlink-team-leads"]
}
}

Schémas de permissions personnalisés

{
"Roles": {
"channel_user": {
"permissions": [
"create_post",
"add_reaction",
"remove_reaction",
"upload_file"
]
},
"team_admin": {
"permissions": [
"manage_team",
"add_user_to_team",
"remove_user_from_team",
"manage_channel_roles"
]
}
}
}

Test de la configuration

1. Test de connexion

# Test via API
curl -X POST https://mattermost.example.com/api/v4/users/login \
-H "Content-Type: application/json" \
-d '{"login_id":"user@example.com","password":"password"}'

2. Test avec mmctl

# Installation de mmctl
brew install mmctl # macOS
# ou
wget https://releases.mattermost.com/mmctl/v7.8.0/linux_amd64.tar

# Connexion
mmctl auth login https://mattermost.example.com

# Vérification
mmctl user list
mmctl team list
mmctl channel list development

3. Test des webhooks

# Créer un webhook entrant
WEBHOOK_URL=$(mmctl webhook create-incoming \
--team development \
--channel general \
--display-name "SmartLink Integration")

# Tester l'envoi
curl -X POST $WEBHOOK_URL \
-H "Content-Type: application/json" \
-d '{"text": "Test SSO integration"}'

Dépannage

Erreur "Invalid login credentials"

Solution :

  1. Vérifiez les logs Mattermost :
    docker logs mattermost 2>&1 | grep -i auth
  2. Testez la découverte OpenID :
    curl https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/.well-known/openid-configuration

Erreur "SAML login was unsuccessful"

Solution :

  1. Vérifiez le certificat X.509
  2. Testez avec saml-tracer (extension navigateur)
  3. Vérifiez les logs :
    tail -f /opt/mattermost/logs/mattermost.log | grep SAML

Les équipes ne sont pas synchronisées

Solution :

{
"OpenIdSettings": {
"GroupsClaim": "groups",
"EnableGroupSync": true,
"GroupsField": "groups"
}
}

Erreur "User is not authorized"

Solution :

  1. Vérifiez que l'utilisateur est assigné à l'application dans SmartLink
  2. Vérifiez les permissions dans Mattermost :
    mmctl user search user@example.com
    mmctl permissions show-role system_user

Sécurité

Configuration recommandée

{
"ServiceSettings": {
"EnableInsecureOutgoingConnections": false,
"EnableLocalMode": false,
"SessionLengthWebInDays": 7,
"SessionLengthMobileInDays": 30,
"SessionCacheInMinutes": 10,
"WebsocketSecurePort": 443,
"TLSMinVer": "1.2"
},
"PasswordSettings": {
"MinimumLength": 10,
"Lowercase": true,
"Number": true,
"Uppercase": true,
"Symbol": true
}
}

Audit et compliance

{
"ComplianceSettings": {
"Enable": true,
"Directory": "/mattermost/compliance/",
"EnableDaily": true
},
"LogSettings": {
"EnableConsole": true,
"ConsoleLevel": "INFO",
"EnableFile": true,
"FileLevel": "INFO",
"FileLocation": "/mattermost/logs/"
}
}

Intégrations avancées

Bots et applications

# Bot Python pour Mattermost
from mattermostdriver import Driver

driver = Driver({
'url': 'https://mattermost.example.com',
'token': 'bot-token-xxxxxx',
'scheme': 'https',
'port': 443
})

driver.login()

# Poster un message
driver.posts.create_post({
'channel_id': 'channel-id',
'message': 'Bonjour depuis SmartLink SSO!'
})

Intégration avec GitLab

{
"PluginSettings": {
"Plugins": {
"com.github.manland.mattermost-plugin-gitlab": {
"gitlaburl": "https://gitlab.example.com",
"gitlaboauthclientid": "gitlab-oauth-id",
"gitlaboauthclientsecret": "gitlab-oauth-secret"
}
}
}
}

Ressources