19.6. Configuring short-lived access
Red Hat Advanced Cluster Security for Kubernetes (RHACS) provides the ability to configure short-lived access to the user interface and API calls.
You can configure this by exchanging OpenID Connect (OIDC) identity tokens for a RHACS-issued token.
We recommend this especially for Continuous Integration (CI) usage, where short-lived access is preferable over long-lived API tokens.
The following steps outline the high-level workflow on how to configure short-lived access to the user interface and API calls:
- Configuring RHACS to trust OIDC identity token issuers for exchanging short-lived RHACS-issued tokens.
- Exchanging an OIDC identity token for a short-lived RHACS-issued token by calling the API.
-
To prevent privilege escalation, when you create a new token, your role’s permissions limit the permission you can assign to that token. For example, if you only have
readpermission for the Integration resource, you cannot create a token withwritepermission. - If you want a custom role to create tokens for other users to use, you must assign the required permissions to that custom role.
-
Use short-lived tokens for machine-to-machine communication, such as CI/CD pipelines, scripts, and other automation. Also, use the
roxctl central logincommand for human-to-machine communication, such asroxctlCLI or API access. - The majority of cloud service providers support OIDC identity tokens, for example, Microsoft Entra ID, Google Cloud Identity Platform, and AWS Cognito. OIDC identity tokens issued by these services can be used for RHACS short-lived access.
- Third-party OIDC identity tokens can also be used directly to access the API endpoint, without an exchange, if a machine-to-machine configuration exists for the token issuer.
Start configuring short-lived access for an OpenID Connect (OIDC) identity token issuer.
Procedure
-
In the RHACS portal, go to Platform Configuration
Integrations. - Scroll to the Authentication Tokens category, and then click Machine access configuration.
- Click Create configuration.
Select the configuration type, choosing one of the following:
- Generic if you use an arbitrary OIDC identity token issuer.
- GitHub Actions if you plan to access RHACS from GitHub Actions.
- Enter the OIDC identity token issuer.
Enter the token lifetime for tokens issued by the configuration.
注意The format for the token lifetime is XhYmZs and you cannot set it for longer than 24 hours.
Add rules to the configuration:
- The Key is the OIDC token’s claim to use.
- The Value is the expected OIDC token claim value.
The Role is the role to assign to the token if the OIDC token claim and value exist.
注意Rules are similar to Authentication Provider rules to assign roles based on claim values.
As a general rule, Red Hat recommends to use unique, immutable claims within Rules. The general recommendation is to use the sub claim within the OIDC identity token. For more information about OIDC token claims, see the list of standard OIDC claims.
- Click Save.
19.6.2. Exchanging an identity token 复制链接链接已复制到粘贴板!
Prerequisites
- You have a valid OpenID Connect (OIDC) token.
- You added a Machine access configuration for the RHACS instance you want to access.
Procedure
Prepare the POST request’s JSON data:
{ "idToken": "<id_token>" }- Send a POST request to the API /v1/auth/m2m/exchange.
Wait for the API response:
{ "accessToken": "<access_token>" }- Use the returned access token to access the RHACS instance.
If you are using GitHub Actions, you can use the stackrox/central-login GitHub Action.