Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
---
title: "OPCP - Comment utiliser les API et obtenir les informations d'identification"
excerpt: "Découvrez les étapes nécessaires pour configurer Keycloak et le CLI OpenStack afin de permettre l’authentification via Keycloak"
updated: 2025-11-07
---

## Objectif

**OPCP** intègre une authentification centralisée avec **Keycloak**. Il est donc nécessaire de configurer la **CLI OpenStack** afin qu’il utilise Keycloak comme fournisseur d’identité (Identity Provider).

**Ce guide décrit les étapes nécessaires pour configurer **Keycloak** et la **CLI OpenStack** afin de permettre l’authentification via Keycloak.**

## Prérequis

- Être administrateur de l'infrastructure [OPCP](/links/hosted-private-cloud/onprem-cloud-platform) et avoir accès à l'interface d'administration (admin.dashboard).
- Avoir accès à l'interface d'administration Keyloack admin.
- Avoir un utilisateur avec les droits suffisants pour se connecter à [Horizon](https://horizon.cloud.ovh.net/auth/login/) sur l'offre OPCP.

## En pratique

### Création d’un client Keycloak pour la CLI OpenStack

Un client **Keycloak dédié** est nécessaire pour permettre à la CLI OpenStack de communiquer de manière sécurisée avec le serveur Keycloak.

#### Étapes

1. **Connexion à l’interface d’administration Keycloak**
Connectez-vous à votre instance Keycloak et sélectionnez le *realm* dans lequel les utilisateurs OpenStack sont définis.

2. **Création d’un nouveau client**
- Allez dans la section `Clients` et cliquez sur `Créer un client`{.action}.
- Renseignez un **Client ID**, par exemple :

```text
openstack-cli
```

- Cliquez sur `Suivant`{.action}.

3. **Activation de l’authentification du client**
- Activez le **Client Authentication** (mettre sur **ON**).
- Cliquez sur `Suivant`{.action}, puis sur `Enregistrer`{.action}.

4. **Configuration des portées (Client Scopes)**
- Ouvrez l’onglet `Client Scopes`.
- Sélectionnez la portée nommée :

```text
[votre-client-id]-dedicated
```

- Cliquez sur `Configurer un nouveau mapper`{.action}.

5. **Ajout d’un mapper d’attributs de groupe utilisateur**
- Choisissez le type de mapper **aggregated-user-group-attribute-mapper**.
- Configurez les champs suivants :

| Champ | Valeur |
|--------|--------|
| **Name** | `projects` |
| **User Attribute** | `project` |
| **Token Claim Name** | `projects` |

- Cliquez sur `Enregistrer`{.action}.

6. **Récupération des identifiants du client**
- Allez dans l’onglet `Credentials` du client que vous venez de créer.
- Copiez et conservez de manière sécurisée la **Client Secret** — il sera nécessaire lors de la configuration du CLI OpenStack.

---

### Configuration de la CLI OpenStack

Une fois le client Keycloak créé, la CLI OpenStack doit être configurée pour utiliser ce client comme fournisseur d'identité OIDC (OpenID Connect).

#### Étapes

1. **Installer les outils CLI OpenStack**
Si ce n’est pas déjà fait :

```bash
sudo pip install python-openstackclient
```

2. **Définir les variables d’environnement pour l’authentification Keycloak**
Exemple :

```bash
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL="https://keystone.domain.ovh"
export OS_AUTH_TYPE="v3oidcpassword"
export OS_PROTOCOL="openid"
export OS_IDENTITY_PROVIDER="keycloak-admin"
export OS_CLIENT_ID="keycloak-client-id"
export OS_CLIENT_SECRET="keycloak-client-credentials"
export OS_DISCOVERY_ENDPOINT="https://admin.keycloak.domain.ovh/realms/master/.well-known/openid-configuration"
export OS_USERNAME="keycloak-user-username"
export OS_PASSWORD="keycloak-user-password"
export OS_PROJECT_ID="project-id"
```

> **Tips 1**
> : Vous pouvez utiliser le script suivant afin de générer le fichier de configuration openrc.sh facilement :

```bash
#!/usr/bin/env bash

read -p "Your environment's base FQDN (e.g. example.bmp.ovhgoldorack.ovh): " FQDN_ENV

read -p 'master or pod realm ? (master/pod): ' REALM
if [ "$REALM" != "master" ] && [ "$REALM" != "pod" ]; then
echo "Invalid input. Please enter either 'master' or 'pod'."
exit 1
fi

read -p 'Keycloak client ID: ' KC_CLIENT_ID
read -srp 'Keycloak client secret: ' KC_CLIENT_SECRET && echo

read -p 'Keycloak username: ' KC_USERNAME_INPUT
read -srp 'Keycloak password: ' KC_PASSWORD_INPUT && echo

read -p 'Openstack Project ID (not the name): ' PROJECT_ID

printf "\n\nHere is your configuration, paste it to your shell or use the generate openrc.sh file\n\n"
cat << EOM
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL="https://keystone.${FQDN_ENV}"
export OS_AUTH_TYPE="v3oidcpassword"
export OS_PROTOCOL="openid"
export OS_IDENTITY_PROVIDER=$([ "$REALM" = "master" ] && echo "keycloak-admin" || echo "keycloak")
export OS_CLIENT_ID="$KC_CLIENT_ID"
export OS_CLIENT_SECRET="$KC_CLIENT_SECRET"
export OS_DISCOVERY_ENDPOINT="https://$([ "$REALM" = "master" ] && echo "admin.keycloak" || echo "keycloak").${FQDN_ENV}/realms/$REALM/.well-known/openid-configuration"
export OS_USERNAME="$KC_USERNAME_INPUT"
export OS_PASSWORD="$KC_PASSWORD_INPUT"
export OS_PROJECT_ID="$PROJECT_ID"
EOM

echo "#!/usr/bin/env bash

export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL="https://keystone.${FQDN_ENV}"
export OS_AUTH_TYPE="v3oidcpassword"
export OS_PROTOCOL="openid"
export OS_IDENTITY_PROVIDER=$([ "$REALM" = "master" ] && echo "keycloak-admin" || echo "keycloak")
export OS_CLIENT_ID="$KC_CLIENT_ID"
export OS_CLIENT_SECRET="$KC_CLIENT_SECRET"
export OS_DISCOVERY_ENDPOINT="https://$([ "$REALM" = "master" ] && echo "admin.keycloak" || echo "keycloak").${FQDN_ENV}/realms/$REALM/.well-known/openid-configuration"
export OS_USERNAME="$KC_USERNAME_INPUT"
export OS_PASSWORD="$KC_PASSWORD_INPUT"
export OS_PROJECT_ID="$PROJECT_ID > $PROJECT_ID."-openrc.sh"
```

> **Tips: Configuration d'un proxy**
> Si vous utilisez un proxy pour accéder a votre service, vous devez configurer vos variables d'environnement pour prendre en compte ce proxy.
Pour ce faire, ajoutez les lignes de commande suivantes :

```bash
export https_proxy=http://your-adress-ip:port/
export http_proxy=http://your-adress-ip:port/
```

### Vérification de la configuration

Vous pouvez tester votre configuration à l’aide de quelques commandes simples :

```bash
openstack token issue
openstack project list
openstack server list
```

Si ces commandes retournent des résultats, l’intégration **Keycloak ↔ OpenStack** est correctement configurée.

---

### Dépannage (Troubleshooting)

| Problème | Cause possible | Solution |
|-----------|----------------|-----------|
| `Invalid client credentials` | Mauvais ou manquant `Client Secret` | Vérifiez le secret dans l’onglet **Credentials** du client Keycloak |
| `Unauthorized` | L’utilisateur n’est pas associé au bon groupe ou projet | Vérifiez les attributs `project` de l’utilisateur dans Keycloak |
| `OIDC discovery failed` | Mauvaise URL dans `DISCOVERY_ENDPOINT` | Assurez-vous qu’elle pointe bien vers le *realm* correct de Keycloak |

---

### Références

- [Documentation Keycloak – OpenID Connect](https://www.keycloak.org/docs/latest/server_admin/#_oidc)
- [Documentation OpenStack Keystone](https://docs.openstack.org/keystone/latest/)
- [Documentation OVHcloud OPCP](https://docs.opcp.ovh)

---
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 6eb6dd6a-46a3-4f8f-b263-3362729401db
full_slug: opcp-use-api-get-credentials
4 changes: 3 additions & 1 deletion pages/index-translations.de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migration
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Erste Schritte
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
hosted-private-cloud-sap-ovhcloud-concepts: Konzepte
hosted-private-cloud-sap-ovhcloud-getting-started: Erste Schritte
Expand Down Expand Up @@ -391,4 +393,4 @@ observability-logs-data-platform-visualizing-querying-exploiting: Visualizing, q
observability-logs-data-platform-opensearch-index: OpenSearch Index as a service
observability-logs-data-platform-security-conformity: Security and conformity
observability-logs-data-platform-usecases: Usecases
observability-logs-data-platform-services-logs: OVHcloud Service Logs
observability-logs-data-platform-services-logs: OVHcloud Service Logs
2 changes: 2 additions & 0 deletions pages/index-translations.es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migración
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Primeros pasos
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
hosted-private-cloud-sap-ovhcloud-concepts: Conceptos
hosted-private-cloud-sap-ovhcloud-getting-started: Primeros pasos
Expand Down
2 changes: 2 additions & 0 deletions pages/index-translations.fq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migration
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Premiers pas
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
hosted-private-cloud-sap-ovhcloud-concepts: Concepts
hosted-private-cloud-sap-ovhcloud-getting-started: Premiers pas
Expand Down
2 changes: 2 additions & 0 deletions pages/index-translations.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migration
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Premiers pas
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
hosted-private-cloud-sap-ovhcloud-concepts: Concepts
hosted-private-cloud-sap-ovhcloud-getting-started: Premiers pas
Expand Down
2 changes: 2 additions & 0 deletions pages/index-translations.it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migrazione
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Per iniziare
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
hosted-private-cloud-sap-ovhcloud-concepts: Concetti
hosted-private-cloud-sap-ovhcloud-getting-started: Per iniziare
Expand Down
2 changes: 2 additions & 0 deletions pages/index-translations.pl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migracja
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Pierwsze kroki
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
hosted-private-cloud-sap-ovhcloud-concepts: Koncepcje
hosted-private-cloud-sap-ovhcloud-getting-started: Pierwsze kroki
Expand Down
2 changes: 2 additions & 0 deletions pages/index-translations.pt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migração
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Primeiros passos
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
hosted-private-cloud-sap-ovhcloud-concepts: Conceitos
hosted-private-cloud-sap-ovhcloud-getting-started: Primeiros passos
Expand Down
3 changes: 3 additions & 0 deletions pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@
+ [Move2Cloud - Migrating VMware Workloads to OVHcloud Hosted Private Cloud with Veeam Replication](hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vmware_migration_veeam)
+ [Move2Cloud - Migrating VMware Workloads to OVHcloud Hosted Private Cloud with Zerto](hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vmware_migration_zerto)
+ [Migrating OmniOS datastores](hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vmware_migration_omnios)
+ [OPCP](hosted-private-cloud-opcp)
+ [Getting started](hosted-private-cloud-opcp-getting-started)
+ [How to use API and get credentials](hosted_private_cloud/opcp/how-to-use-api-and-get-credentials)
+ [Nutanix on OVHcloud](products/hosted-private-cloud-nutanix-on-ovhcloud)
+ [Getting started](hosted-private-cloud-nutanix-on-ovhcloud-getting-started)
+ [Nutanix global high-level documentation](hosted_private_cloud/nutanix_on_ovhcloud/01-global-high-level-doc)
Expand Down