Service accounts
Give a script or a pipeline its own token, and cut it off without touching anyone else.
Prerequisites
- A running
afe serve. AFE_API_TOKENset to the bootstrap token, or a single sign-on session of an administrator.
Steps
-
Create the account. The expiry is optional:
afe service-account create ci-bot --expires 2027-06-30The command prints the token once, then a warning. Copy it now. The engine stores only a hash.
-
Give the token to the script:
export AFE_API_TOKEN=afe_sa_...afe run review --input input.yaml --url wss://afe.my-company.test/rpcService account tokens start with
afe_sa_. Every action the script takes is recorded under the account's name. -
List the accounts:
afe service-account listThe list shows the creator, the dates, and whether the account is revoked. It never shows tokens.
-
Revoke the account when you no longer need it:
afe service-account revoke ci-botA new call with the token fails at once. An open connection is re-checked every 60 seconds and closes with code 4401, even when the client sends nothing.
A service account is never a global administrator. It has only the roles a project's access block
gives it. Only a global administrator creates, lists or revokes accounts.
Troubleshooting
error: set AFE_API_TOKEN to talk to a server. The variable is empty in this shell.
permission denied (-32008). The caller is not an administrator. Only a refused create or
revoke leaves an entry in the audit trail: the other administrator methods only read.
An account name is rejected. The name already exists, revoked accounts included.
See also
- Assign roles in a project: give the account a role.
- Single sign-on for people.
- Identity and audit for the audit entry and its export.