Rotate a service account secret
You can rotate a service account credential's secret to replace it with a new one.
Before you begin
- A service account exists with at least one credential.
- You have the
service_account:rotate_secretpermission, or you are a project administrator. - You know the service account ID and the credential ID. To find these values, list the credentials for the service account:
$ curl -H "Authorization: Bearer access_token" \ https://orchestrator_host/api/v1/service_accounts/service_account_id/credentials
About this task
Rotation is useful for periodic credential hygiene, responding to a suspected compromise, or meeting compliance requirements. The client ID stays the same during rotation, so you only need to update the secret in your external systems. During the grace period, both the old and new secrets are accepted, so you can update external systems without downtime.
When you rotate a secret, the following sequence occurs:
- Automation orchestrator generates a new secret and hashes it.
- The current secret hash is moved to a temporary storage field.
- The old secret remains valid until the grace period expires.
- During the grace period, authentication attempts are verified against the new secret first, then the old secret.
- After the grace period expires, only the new secret is accepted.
Setting the grace period to 0 means the old secret is rejected immediately after rotation.
Procedure
Results
Authenticate with the new secret to confirm it works:
$ curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=client_id&client_secret=new_secret" \
https://orchestrator_host/api/v1/auth/tokenDuring the grace period, authenticate with the old secret to confirm it is still accepted.
After the grace period expires, authenticate with the old secret to confirm it is rejected.
Example: rotating a ServiceNow integration credential
The following example rotates the secret for a service account that a ServiceNow instance uses to call automation orchestrator, using a 2-hour grace period to avoid downtime.
-
Rotate the credential:
$ curl -X POST \ -H "Authorization: Bearer access_token" \ -H "Content-Type: application/json" \ -d '{"grace_period_seconds": 7200}' \ https://orchestrator_host/api/v1/service_accounts/service_account_id/credentials/credential_id/rotate -
Record the new
client_secretfrom the response. -
In ServiceNow, update the connection credential for the automation orchestrator integration with the new secret.
-
Test the ServiceNow integration to confirm it authenticates with the new secret.
The old secret continues to work for any ServiceNow jobs that started before the update and cached the old credential. After 2 hours, only the new secret is accepted.