Authentification de l'API OIDC
Les API Equinix utilisent le protocole OAuth 2.0 pour authentifier les requêtes de votre utilisateur OIDC auprès des points de terminaison de l'API. Pour interagir avec les API Equinix, vous avez besoin d'un jeton d'accès porteur.
Préalable
-
Un fournisseur OIDC.
-
Un jeton d'identification OIDC fourni par votre fournisseur OIDC enregistré.
-
Autorisations spécifiques au produit ou au service permettant de définir la portée du jeton d'accès à l'API. Vous avez besoin soit:
ern:<access-policy-ern>where<access-policy-ern>is a single access policy that has been granted to the principal.roleassignments:<org-id>where<org-id>is the organization ID where the OIDC principal has assigned roles.projectpolicies:<project-id>where<project-id>is a project ID where the OIDC principal has been granted an access policy or access policies.orgpolicies:<org-id>where<org-id>is an organization ID where the principal has been granted an access policy or access policies.orgpolicies:<org-id> roleassignments:<org-id>where<org-id>is an organization ID where the principal has been granted both roles and access policies.
Pour plus d'informations, voir Étendues du contrôle d'accès.
Demande d'un jeton d'accès
Pour demander un jeton d'accès porteur, envoyez une requête POST au point de terminaison /v1/token.
Dans le corps de la requête, veuillez préciser:
grant_type- Useurn:ietf:params:oauth:grant-type:token-exchangeto receive an access token.scope(required) - Provide the scope. The permissions granted by the token are checked against whether the principal has been granted the appropriate roles or access policies. For more information, see Access Control Scopes.subject_token- The OIDC ID token.subject_token_type- Useurn:ietf:params:oauth:token-type:id_tokenwhich identifies yoursubject_tokenas an OIDC ID token.
Exemple de requête cURL:
curl -X POST 'https://sts.eqix.equinix.com/v1/token' \
--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:token-exchange' \
--data-urlencode 'subject_token_type=urn:ietf:params:oauth:token-type:id_token' \
--data-urlencode 'scope=<role_or_access_policy>' \
--data-urlencode 'subject_token=<oidc_id_token>'
Utilisation des jetons d'accès
Pour interagir avec l'API Equinix, envoyez votre jeton d'accès dans l'en-tête Authorization de la requête HTTP avec Authorization: Bearer <token>.