# SAML + CENTREON

## 📘 Intégration Authentik (IdP) avec Centreon (SP) via SAML

Cette documentation décrit comment intégrer **Authentik** comme **fournisseur d'identité (IdP)** avec **Centreon** comme **Service Provider (SP)** via **SAML 2.0**, en environnement sécurisé **avec reverse proxy** et certificats TLS **Let's Encrypt**.

***

### 🧰 Prérequis

#### 1. Environnement sécurisé

* **Centreon** et **Authentik** sont accessibles en HTTPS via reverse proxy (NGINX, Traefik, Apache…).
* Certificats **Let’s Encrypt** valides sur les deux côtés (authentik et centreon).
* Authentik est déjà installé ([voir guide Docker ici](/tutoriels/singlesignon/authentik.md)).

#### 2. DNS / Reverse Proxy

* Le reverse proxy gère les certificats SSL et fait suivre le trafic vers les IP internes :
  * `https://auth.mondomaine.tld` → Authentik (port 80/443)
  * `https://centreon.mondomaine.tld` → Centreon (port 80/443)

***

### ⚙️ Étapes côté Authentik (IdP)

#### 1. Générer un certificat signé (pour les assertions)

Depuis l’interface admin :

* Aller dans **System → Certificates → Generate**
* Paramètres :
  * **Common Name (CN)** : `centreon.mondomaine.tld`
  * **Subject Alternative Name (SAN)** : `auth.mondomaine.tld`, `centreon.mondomaine.tld`
* Utiliser ce certificat pour :
  * **Signer l’assertion**
  * **Signer la réponse**

***

#### 2. Créer un Provider SAML

Aller dans **Providers → Create → SAML Provider**

* **ACS URL** :\
  `https://centreon.mondomaine.tld/centreon/api/latest/saml/acs`
* **Issuer** :\
  `https://centreon.mondomaine.tld` *(⚠️ Sans `/` final)*
* **SLO URL** : *(facultatif)*
* **Binding** : POST
* **Sign Responses** : ✅
* **Sign Assertions** : ✅
* **Certificate** : le certificat généré à l'étape 1

Enregistrer.

***

#### 3. Créer une Application SAML

* Aller dans **Applications → Create**
* **Name** : `Centreon`
* **Slug** : `centreon`
* **Provider** : celui créé juste avant
* **User attribute mapping ( fais par defaut, mais s'assurer d'avoir les suivants d'inclu)** :
  * `username`&#x20;
  * `email`&#x20;
  * `name`&#x20;

**💡 Identifiants SAML visibles dans :**\
[`https://auth.mondomaine.tld/application/saml/centreon/metadata/`](https://auth.skyfik.net/application/saml/supervision/metadata/)&#x20;

***

### ⚙️ Étapes côté Centreon (SP)

#### 1. Modifier le fichier PHP des options SAML

Dans `/usr/share/centreon/src/Core/Security/Authentication/Infrastructure/Provider/Settings/Formatter/OneLoginSettingsFormatter.php`

Ajoutez dans le bloc `'security'` :

```php
'security' => [
    'requestedAuthContext' => false,                
    'requestedAuthnContextComparison' => 'Minimum',
],
```

Redémarrer Apache / PHP-FPM ou l’unité Centreon :

```bash
systemctl restart centreon
```

***

#### 2. Configuration Web de SAML dans Centreon

Depuis l’interface web Centreon :

* **Administration → Authentication → SAML**

| Champ                      | Valeur                                                                        |
| -------------------------- | ----------------------------------------------------------------------------- |
| Authentication Method      | Mixed                                                                         |
| Remote login URL           | `https://auth.mondomaine.tld/application/saml/centreon/sso/binding/redirect/` |
| Issuer (Entity ID)         | `https://centreon.mondomaine.tld`                                             |
| x.509 Certificate          | 🔐 Certificat signé généré dans Authentik (voir étape 1)                      |
| Login Attribute (username) | `http://schemas.goauthentik.io/2021/02/saml/username`                         |
| Email Attribute            | `http://schemas.goauthentik.io/2021/02/saml/email`                            |
| Name Attribute             | `http://schemas.goauthentik.io/2021/02/saml/name`                             |

***

### 🔁 Reverse Proxy (bonus)

#### Exemple de config NGINX pour passer centreon en https

```nginx
server {
    listen 443 ssl;
    server_name centreon.mondomaine.tld;

    ssl_certificate /etc/letsencrypt/live/centreon.mondomaine.tld/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/centreon.mondomaine.tld/privkey.pem;

    location / {
        proxy_pass http://<centreon_ip>/;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
```

💡 **Important** : Le certificat présenté doit être valide et reconnu par Authentik.

{% hint style="danger" %}
Si vous utilisez un **certificat autosigné**, ajoutez-le manuellement dans le keystore Java d'Authentik ou désactivez la validation stricte (non recommandé en prod).
{% endhint %}

### ✅ Vérifications finales

* ✔️ L’ACS URL correspond à celle définie dans Authentik
* ✔️ Le certificat est bien signé
* ✔️ Les attributs SAML sont bien mappés
* ✔️ Authentik utilise une URL en HTTPS avec certificat reconnu

***

### DEBUG

Si vous rencontrez des bug, j'ai ecrit un comment sur une issue github qui peut etre très utiles.&#x20;

[Lien vers commentaires issues](https://github.com/bbalet/jorani/issues/394#issuecomment-2886970601)

### 📚 Références utiles

* [Authentik SAML Docs](https://goauthentik.io/docs/providers/saml)
* [Centreon SAML Integration (via OneLogin)](https://docs.centreon.com/docs/administration/authentication/saml/)
* [Schemas Authentik SAML](https://github.com/goauthentik/authentik/blame/main/blueprints/system/providers-saml.yaml)

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki-tech.fikara.io/tutoriels/singlesignon/saml-+-centreon.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
