Skip to content

Commit 0c861b7

Browse files
authored
Merge pull request #8625 from ovh/TG-OPCP-Howtouseapiandgetcred
feat(opcp): create guide how to use api and get credentials
2 parents 07588aa + ce16dc3 commit 0c861b7

File tree

10 files changed

+216
-1
lines changed

10 files changed

+216
-1
lines changed
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
---
2+
title: "OPCP - Comment utiliser les API et obtenir les informations d'identification"
3+
excerpt: "Découvrez les étapes nécessaires pour configurer Keycloak et le CLI OpenStack afin de permettre l’authentification via Keycloak"
4+
updated: 2025-11-07
5+
---
6+
7+
## Objectif
8+
9+
**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).
10+
11+
**Ce guide décrit les étapes nécessaires pour configurer **Keycloak** et la **CLI OpenStack** afin de permettre l’authentification via Keycloak.**
12+
13+
## Prérequis
14+
15+
- Être administrateur de l'infrastructure [OPCP](/links/hosted-private-cloud/onprem-cloud-platform) et avoir accès à l'interface d'administration (admin.dashboard).
16+
- Avoir accès à l'interface d'administration Keyloack admin.
17+
- Avoir un utilisateur avec les droits suffisants pour se connecter à [Horizon](https://horizon.cloud.ovh.net/auth/login/) sur l'offre OPCP.
18+
19+
## En pratique
20+
21+
### Création d’un client Keycloak pour la CLI OpenStack
22+
23+
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.
24+
25+
#### Étapes
26+
27+
1. **Connexion à l’interface d’administration Keycloak**
28+
Connectez-vous à votre instance Keycloak et sélectionnez le *realm* dans lequel les utilisateurs OpenStack sont définis.
29+
30+
2. **Création d’un nouveau client**
31+
- Allez dans la section `Clients` et cliquez sur `Créer un client`{.action}.
32+
- Renseignez un **Client ID**, par exemple :
33+
34+
```text
35+
openstack-cli
36+
```
37+
38+
- Cliquez sur `Suivant`{.action}.
39+
40+
3. **Activation de l’authentification du client**
41+
- Activez le **Client Authentication** (mettre sur **ON**).
42+
- Cliquez sur `Suivant`{.action}, puis sur `Enregistrer`{.action}.
43+
44+
4. **Configuration des portées (Client Scopes)**
45+
- Ouvrez l’onglet `Client Scopes`.
46+
- Sélectionnez la portée nommée :
47+
48+
```text
49+
[votre-client-id]-dedicated
50+
```
51+
52+
- Cliquez sur `Configurer un nouveau mapper`{.action}.
53+
54+
5. **Ajout d’un mapper d’attributs de groupe utilisateur**
55+
- Choisissez le type de mapper **aggregated-user-group-attribute-mapper**.
56+
- Configurez les champs suivants :
57+
58+
| Champ | Valeur |
59+
|--------|--------|
60+
| **Name** | `projects` |
61+
| **User Attribute** | `project` |
62+
| **Token Claim Name** | `projects` |
63+
64+
- Cliquez sur `Enregistrer`{.action}.
65+
66+
6. **Récupération des identifiants du client**
67+
- Allez dans l’onglet `Credentials` du client que vous venez de créer.
68+
- Copiez et conservez de manière sécurisée la **Client Secret** — il sera nécessaire lors de la configuration du CLI OpenStack.
69+
70+
---
71+
72+
### Configuration de la CLI OpenStack
73+
74+
Une fois le client Keycloak créé, la CLI OpenStack doit être configurée pour utiliser ce client comme fournisseur d'identité OIDC (OpenID Connect).
75+
76+
#### Étapes
77+
78+
1. **Installer les outils CLI OpenStack**
79+
Si ce n’est pas déjà fait :
80+
81+
```bash
82+
sudo pip install python-openstackclient
83+
```
84+
85+
2. **Définir les variables d’environnement pour l’authentification Keycloak**
86+
Exemple :
87+
88+
```bash
89+
export OS_INTERFACE=public
90+
export OS_IDENTITY_API_VERSION=3
91+
export OS_AUTH_URL="https://keystone.domain.ovh"
92+
export OS_AUTH_TYPE="v3oidcpassword"
93+
export OS_PROTOCOL="openid"
94+
export OS_IDENTITY_PROVIDER="keycloak-admin"
95+
export OS_CLIENT_ID="keycloak-client-id"
96+
export OS_CLIENT_SECRET="keycloak-client-credentials"
97+
export OS_DISCOVERY_ENDPOINT="https://admin.keycloak.domain.ovh/realms/master/.well-known/openid-configuration"
98+
export OS_USERNAME="keycloak-user-username"
99+
export OS_PASSWORD="keycloak-user-password"
100+
export OS_PROJECT_ID="project-id"
101+
```
102+
103+
> **Tips 1**
104+
> : Vous pouvez utiliser le script suivant afin de générer le fichier de configuration openrc.sh facilement :
105+
106+
```bash
107+
#!/usr/bin/env bash
108+
109+
read -p "Your environment's base FQDN (e.g. example.bmp.ovhgoldorack.ovh): " FQDN_ENV
110+
111+
read -p 'master or pod realm ? (master/pod): ' REALM
112+
if [ "$REALM" != "master" ] && [ "$REALM" != "pod" ]; then
113+
echo "Invalid input. Please enter either 'master' or 'pod'."
114+
exit 1
115+
fi
116+
117+
read -p 'Keycloak client ID: ' KC_CLIENT_ID
118+
read -srp 'Keycloak client secret: ' KC_CLIENT_SECRET && echo
119+
120+
read -p 'Keycloak username: ' KC_USERNAME_INPUT
121+
read -srp 'Keycloak password: ' KC_PASSWORD_INPUT && echo
122+
123+
read -p 'Openstack Project ID (not the name): ' PROJECT_ID
124+
125+
printf "\n\nHere is your configuration, paste it to your shell or use the generate openrc.sh file\n\n"
126+
cat << EOM
127+
export OS_INTERFACE=public
128+
export OS_IDENTITY_API_VERSION=3
129+
export OS_AUTH_URL="https://keystone.${FQDN_ENV}"
130+
export OS_AUTH_TYPE="v3oidcpassword"
131+
export OS_PROTOCOL="openid"
132+
export OS_IDENTITY_PROVIDER=$([ "$REALM" = "master" ] && echo "keycloak-admin" || echo "keycloak")
133+
export OS_CLIENT_ID="$KC_CLIENT_ID"
134+
export OS_CLIENT_SECRET="$KC_CLIENT_SECRET"
135+
export OS_DISCOVERY_ENDPOINT="https://$([ "$REALM" = "master" ] && echo "admin.keycloak" || echo "keycloak").${FQDN_ENV}/realms/$REALM/.well-known/openid-configuration"
136+
export OS_USERNAME="$KC_USERNAME_INPUT"
137+
export OS_PASSWORD="$KC_PASSWORD_INPUT"
138+
export OS_PROJECT_ID="$PROJECT_ID"
139+
EOM
140+
141+
echo "#!/usr/bin/env bash
142+
143+
export OS_INTERFACE=public
144+
export OS_IDENTITY_API_VERSION=3
145+
export OS_AUTH_URL="https://keystone.${FQDN_ENV}"
146+
export OS_AUTH_TYPE="v3oidcpassword"
147+
export OS_PROTOCOL="openid"
148+
export OS_IDENTITY_PROVIDER=$([ "$REALM" = "master" ] && echo "keycloak-admin" || echo "keycloak")
149+
export OS_CLIENT_ID="$KC_CLIENT_ID"
150+
export OS_CLIENT_SECRET="$KC_CLIENT_SECRET"
151+
export OS_DISCOVERY_ENDPOINT="https://$([ "$REALM" = "master" ] && echo "admin.keycloak" || echo "keycloak").${FQDN_ENV}/realms/$REALM/.well-known/openid-configuration"
152+
export OS_USERNAME="$KC_USERNAME_INPUT"
153+
export OS_PASSWORD="$KC_PASSWORD_INPUT"
154+
export OS_PROJECT_ID="$PROJECT_ID > $PROJECT_ID."-openrc.sh"
155+
```
156+
157+
> **Tips: Configuration d'un proxy**
158+
> Si vous utilisez un proxy pour accéder a votre service, vous devez configurer vos variables d'environnement pour prendre en compte ce proxy.
159+
Pour ce faire, ajoutez les lignes de commande suivantes :
160+
161+
```bash
162+
export https_proxy=http://your-adress-ip:port/
163+
export http_proxy=http://your-adress-ip:port/
164+
```
165+
166+
### Vérification de la configuration
167+
168+
Vous pouvez tester votre configuration à l’aide de quelques commandes simples :
169+
170+
```bash
171+
openstack token issue
172+
openstack project list
173+
openstack server list
174+
```
175+
176+
Si ces commandes retournent des résultats, l’intégration **Keycloak ↔ OpenStack** est correctement configurée.
177+
178+
---
179+
180+
### Dépannage (Troubleshooting)
181+
182+
| Problème | Cause possible | Solution |
183+
|-----------|----------------|-----------|
184+
| `Invalid client credentials` | Mauvais ou manquant `Client Secret` | Vérifiez le secret dans l’onglet **Credentials** du client Keycloak |
185+
| `Unauthorized` | L’utilisateur n’est pas associé au bon groupe ou projet | Vérifiez les attributs `project` de l’utilisateur dans Keycloak |
186+
| `OIDC discovery failed` | Mauvaise URL dans `DISCOVERY_ENDPOINT` | Assurez-vous qu’elle pointe bien vers le *realm* correct de Keycloak |
187+
188+
---
189+
190+
### Références
191+
192+
- [Documentation Keycloak – OpenID Connect](https://www.keycloak.org/docs/latest/server_admin/#_oidc)
193+
- [Documentation OpenStack Keystone](https://docs.openstack.org/keystone/latest/)
194+
- [Documentation OVHcloud OPCP](https://docs.opcp.ovh)
195+
196+
---
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id: 6eb6dd6a-46a3-4f8f-b263-3362729401db
2+
full_slug: opcp-use-api-get-credentials

pages/index-translations.de.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
7878
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
7979
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
8080
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migration
81+
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
82+
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Erste Schritte
8183
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
8284
hosted-private-cloud-sap-ovhcloud-concepts: Konzepte
8385
hosted-private-cloud-sap-ovhcloud-getting-started: Erste Schritte
@@ -393,4 +395,4 @@ observability-logs-data-platform-visualizing-querying-exploiting: Visualizing, q
393395
observability-logs-data-platform-opensearch-index: OpenSearch Index as a service
394396
observability-logs-data-platform-security-conformity: Security and conformity
395397
observability-logs-data-platform-usecases: Usecases
396-
observability-logs-data-platform-services-logs: OVHcloud Service Logs
398+
observability-logs-data-platform-services-logs: OVHcloud Service Logs

pages/index-translations.es.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
7878
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
7979
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
8080
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migración
81+
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
82+
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Primeros pasos
8183
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
8284
hosted-private-cloud-sap-ovhcloud-concepts: Conceptos
8385
hosted-private-cloud-sap-ovhcloud-getting-started: Primeros pasos

pages/index-translations.fq.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
7878
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
7979
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
8080
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migration
81+
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
82+
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Premiers pas
8183
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
8284
hosted-private-cloud-sap-ovhcloud-concepts: Concepts
8385
hosted-private-cloud-sap-ovhcloud-getting-started: Premiers pas

pages/index-translations.fr.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
7979
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
8080
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
8181
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migration
82+
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
83+
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Premiers pas
8284
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
8385
hosted-private-cloud-sap-ovhcloud-concepts: Concepts
8486
hosted-private-cloud-sap-ovhcloud-getting-started: Premiers pas

pages/index-translations.it.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
7878
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
7979
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
8080
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migrazione
81+
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
82+
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Per iniziare
8183
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
8284
hosted-private-cloud-sap-ovhcloud-concepts: Concetti
8385
hosted-private-cloud-sap-ovhcloud-getting-started: Per iniziare

pages/index-translations.pl.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
7878
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
7979
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
8080
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migracja
81+
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
82+
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Pierwsze kroki
8183
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
8284
hosted-private-cloud-sap-ovhcloud-concepts: Koncepcje
8385
hosted-private-cloud-sap-ovhcloud-getting-started: Pierwsze kroki

pages/index-translations.pt.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ hosted-private-cloud-hosted-private-cloud-powered-by-vmware-tanzu: VMware Tanzu
7878
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-secnumcloud: SecNumCloud
7979
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-vrops: VMware vROps
8080
hosted-private-cloud-hosted-private-cloud-powered-by-vmware-migration: Migração
81+
hosted-private-cloud-hosted-private-cloud-opcp: On-Prem Cloud Plateform
82+
hosted-private-cloud-hosted-private-cloud-opcp-getting-started: Primeiros passos
8183
hosted-private-cloud-sap-ovhcloud: SAP on OVHcloud
8284
hosted-private-cloud-sap-ovhcloud-concepts: Conceitos
8385
hosted-private-cloud-sap-ovhcloud-getting-started: Primeiros passos

pages/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,9 @@
550550
+ [Move2Cloud - Migrating VMware Workloads to OVHcloud Hosted Private Cloud with Veeam Replication](hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vmware_migration_veeam)
551551
+ [Move2Cloud - Migrating VMware Workloads to OVHcloud Hosted Private Cloud with Zerto](hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vmware_migration_zerto)
552552
+ [Migrating OmniOS datastores](hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vmware_migration_omnios)
553+
+ [OPCP](hosted-private-cloud-opcp)
554+
+ [Getting started](hosted-private-cloud-opcp-getting-started)
555+
+ [How to use API and get credentials](hosted_private_cloud/opcp/how-to-use-api-and-get-credentials)
553556
+ [Nutanix on OVHcloud](products/hosted-private-cloud-nutanix-on-ovhcloud)
554557
+ [Getting started](hosted-private-cloud-nutanix-on-ovhcloud-getting-started)
555558
+ [Nutanix global high-level documentation](hosted_private_cloud/nutanix_on_ovhcloud/01-global-high-level-doc)

0 commit comments

Comments
 (0)