-
Notifications
You must be signed in to change notification settings - Fork 383
EN version - OPCP - Comment utiliser les API et obtenir les informations d'identification #8671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jessica41
wants to merge
1
commit into
develop
Choose a base branch
from
jf-en-opcp
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
199 changes: 199 additions & 0 deletions
199
pages/hosted_private_cloud/opcp/how-to-use-api-and-get-credentials/guide.en-gb.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,199 @@ | ||
| --- | ||
| title: "OPCP - How to use the APIs and obtain the credentials" | ||
| excerpt: "Discover the steps required to configure Keycloak and the OpenStack CLI to allow authentication via Keycloak" | ||
| updated: 2025-11-07 | ||
| --- | ||
|
|
||
| ## Objective | ||
|
|
||
| **OPCP** integrates a centralized authentication with **Keycloak**. It is therefore necessary to configure the **OpenStack CLI** so that it uses Keycloak as the identity provider (Identity Provider). | ||
|
|
||
| **This guide describes the steps required to configure Keycloak and the OpenStack CLI to allow authentication via Keycloak.** | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Be an administrator of the [OPCP](/links/hosted-private-cloud/onprem-cloud-platform) infrastructure and have access to the administration interface (admin.dashboard). | ||
| - Have access to the Keyloack admin interface. | ||
| - Have a user with sufficient rights to log in to [Horizon](https://horizon.cloud.ovh.net/auth/login/) on the OPCP offer. | ||
|
|
||
| ## Instructions | ||
|
|
||
| ### Creating a Keycloak client for the OpenStack CLI | ||
|
|
||
| A **dedicated Keycloak client** is required to allow the OpenStack CLI to securely communicate with the Keycloak server. | ||
|
|
||
| #### Steps | ||
|
|
||
| 1\. **Log in to the Keycloak administration interface** | ||
|
|
||
| - Log in to your Keycloak instance and select the *realm* in which the OpenStack users are defined. | ||
|
|
||
| 2\. **Create a new client** | ||
|
|
||
| - Go to the `Clients` section and click on `Create a client`{.action}. | ||
| - Enter a **Client ID**, for example: | ||
|
|
||
| ```console | ||
| openstack-cli | ||
| ``` | ||
|
|
||
| - Click on `Next`{.action}. | ||
|
|
||
| 3\. **Enable client authentication** | ||
|
|
||
| - Enable **Client Authentication** (set to **ON**). | ||
| - Click on `Next`{.action}, then on `Save`{.action}. | ||
|
|
||
| 4\. **Configure scopes (Client Scopes)** | ||
|
|
||
| - Open the `Client Scopes` tab. | ||
| - Select the scope named: | ||
|
|
||
| ```console | ||
| [your-client-id]-dedicated | ||
| ``` | ||
|
|
||
| - Click on `Configure a new mapper`{.action}. | ||
|
|
||
| 5\. **Add a user group attribute mapper** | ||
|
|
||
| - Choose the mapper type **aggregated-user-group-attribute-mapper**. | ||
| - Configure the following fields: | ||
|
|
||
| | Field | Value | | ||
| |--------|--------| | ||
| | **Name** | `projects` | | ||
| | **User Attribute** | `project` | | ||
| | **Token Claim Name** | `projects` | | ||
|
|
||
| - Click on `Save`{.action}. | ||
|
|
||
| 6\. **Retrieve the client credentials** | ||
|
|
||
| - Go to the `Credentials` tab of the client you just created. | ||
| - Copy and securely store the **Client Secret** — it will be needed when configuring the OpenStack CLI. | ||
|
|
||
| ### Configuration of the OpenStack CLI | ||
|
|
||
| Once the Keycloak client is created, the OpenStack CLI must be configured to use this client as the OIDC (OpenID Connect) identity provider. | ||
|
|
||
| #### Steps | ||
|
|
||
| 1\. **Install the OpenStack CLI tools** | ||
|
|
||
| If not already done: | ||
|
|
||
| ```bash | ||
| sudo pip install python-openstackclient | ||
| ``` | ||
|
|
||
| 2\. **Set environment variables for Keycloak authentication** | ||
|
|
||
| Example: | ||
|
|
||
| ```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" | ||
| ``` | ||
|
|
||
| > **Tip** | ||
| > You can use the following script to easily generate the openrc.sh configuration file: | ||
|
|
||
| ```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" | ||
| ``` | ||
|
|
||
| > **Tip: Proxy configuration** | ||
| > If you are using a proxy to access your service, you must configure your environment variables to take this proxy into account. | ||
|
|
||
| To do this, add the following commands lines: | ||
|
|
||
| ```bash | ||
| export https_proxy=http://your-adress-ip:port/ | ||
| export http_proxy=http://your-adress-ip:port/ | ||
| ``` | ||
|
|
||
| ### Configuration verification | ||
|
|
||
| You can test your configuration using a few simple commands: | ||
|
|
||
| ```bash | ||
| openstack token issue | ||
| openstack project list | ||
| openstack server list | ||
| ``` | ||
|
|
||
| If these commands return results, the **Keycloak ↔ OpenStack** integration is correctly configured. | ||
|
|
||
|
|
||
| ### Troubleshooting | ||
|
|
||
| | Problem | Possible cause | Solution | | ||
| |-----------|----------------|-----------| | ||
| | `Invalid client credentials` | Wrong or missing `Client Secret` | Check the secret in the **Credentials** tab of the Keycloak client | | ||
| | `Unauthorized` | The user is not associated with the correct group or project | Check the `project` attributes of the user in Keycloak | | ||
| | `OIDC discovery failed` | Wrong URL in `DISCOVERY_ENDPOINT` | Make sure it points to the correct Keycloak *realm* | | ||
|
|
||
|
|
||
| ### References | ||
|
|
||
| - [Keycloak Documentation – OpenID Connect](https://www.keycloak.org/docs/latest/server_admin/#_oidc) | ||
| - [OpenStack Keystone Documentation](https://docs.openstack.org/keystone/latest/) | ||
| - [OVHcloud OPCP Documentation](https://docs.opcp.ovh) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Jessica41
Can you remove the horizon link please (in FR version also) ?
In the case of OPCP, this is not this link, and it will change for each customer, so we cannot add it to the guide.