Two answers, and only two
Every request an agent makes uses somebody’s authority. There are two possibilities.
- A person’s. The token names that person. What the agent can do is capped by what the person can do, and by what they approved. This is what the previous lesson showed.
- Its own. The token names the agent. Nobody approves anything at the moment it runs. An administrator decided in advance what this agent is allowed to do.
This guide calls whoever’s authority is being used the principal. Which of the two it should be is not a matter of taste. It follows from the work.
Whose authority is one question. Which software is acting is another, and a token can answer both: one that names Alice also names the app it was issued to. The next lesson puts a second piece of software on the path.
Sort five agents
For each one, whose authority should it use? Choose, then read why.
The pattern in those five: the mail assistant, the support bot and the agent filing Alice’s receipts act for a person. The invoice job and the deploy digest act as themselves. A rule of thumb that covers most cases:
- If the right answer depends on who is asking, the agent acts for that person.
- If the work belongs to a team or a company, and runs on a schedule or a trigger, the agent acts as itself.
How an agent proves it is itself
Acting as itself, the agent still needs a token, and the routine is a shorter version of the previous lesson. It proves which software it is to the authorization server, gets a short-lived access token, and sends that to the API. There is no browser and no consent screen, because there is no user. OAuth calls this client credentials.
Which service plays the authorization server depends on where the agent runs. Inside a company it is usually the sign-in system its services already trust. In a cloud it is the cloud’s own token service. On Kubernetes the cluster can play the part itself. The pod asks for a token addressed to the API it is going to call, and that API asks the cluster whether the token is good and was meant for it. The token a pod gets by default is addressed to the cluster itself: never send that one anywhere else.
The interesting part is the first step. What does the agent prove itself with? There are three common answers, and they are not equally good.
| A key it stores | A secret it trades for tokens | An identity from its platform | |
|---|---|---|---|
| What the agent holds | One long-lived API key, sent on every request | A long-lived client secret or private key, and short-lived tokens | Short-lived credentials only |
| Who issues it | Whoever runs the API | The authorization server, for a secret. A key pair is your own, with the public half registered there | The platform the agent runs on: a cloud, Kubernetes, a CI system |
| If a copy leaks | It works until someone notices and replaces it | A token stops in minutes. The secret works until it is replaced | It stops when it expires: minutes to hours, depending on the platform |
| Who replaces it | You, by hand | You, by hand | The platform, on its own |
The third column is called workload identity. The platform that started the agent already knows exactly what it started, so it can vouch for it. It hands the job a short, signed note saying what the job is, and replaces the note before it expires. The job trades that note for access.
Nothing had to be stored, but there is still something to take. Anything running inside the job can pick that note up, including a command or a web request the model was talked into making. Keep it, and the local address the platform hands it out from, out of reach of the model’s tools.
An identity nobody had to store for the agent
The agent’s identity: Issued by the platform
What the access token says
about: invoice-job
issued to: invoice-job
for: billing.example
allows: read invoices
expires: in 10 minutes| Who is acting? | The invoice job. The platform that started it vouches for that, so no long-lived secret had to be stored for the job. |
|---|---|
| For whom? | Nobody. The token is about the agent itself: the same name appears twice. |
| Who said they could? | An administrator, in advance, by writing a rule: this job may read invoices. Nobody approved tonight’s run. |
Everything from the token lesson still holds: one audience, a narrow scope, a short life. What changes is who the token is about, and that the only limit on this agent is the rule an administrator wrote.
In the figure the platform and the authorization server are two different systems, and the second has agreed to accept identities that the first one issues. That agreement is called federation. A cloud accepting a note from your CI system is the usual example. Where a platform’s own services accept its own notes, nothing is federated: it is all one system.
The trap in the middle
The fifth agent in the exercise was neither one thing nor the other: Alice’s access, and no Alice. It has a person’s full authority and no person watching. Of every arrangement in this guide, it is the one most likely to end badly.
Sometimes it is what the job needs. If you find yourself there:
- Ask for the narrowest scope that does the work. Filing receipts does not need permission to send mail.
- Find a way to reach the person for anything that cannot be undone. The final lesson shows how.
- Know how the access is switched off, and who can do it, before the agent runs for the first time.
Check yourself
Answer before you read on. Nothing is recorded.
What to keep
- Every request uses somebody’s authority: a person’s, or the agent’s own. Decide which first.
- Acting for a person: the token names the person, and what they can do is the ceiling.
- Acting as itself: the token names the agent, and the rule an administrator wrote is the only limit.
- An agent’s own identity is best issued by the platform it runs on and short-lived, not stored as a secret.
- A person’s access with no person watching is the arrangement to be most careful with.
The names for these
The rest of this guide, and every specification, uses these terms. Each links to its entry in the glossary.
| In this lesson | Its name | Defined as |
|---|---|---|
| Whoever’s authority a request uses | Principal | The party whose authority is being exercised. A person, an organization, or the agent itself. |
| An account that belongs to software | Service account | An account that belongs to software, not to a person. In OAuth terms, a client acting under its own identity. |
| Getting a token as itself, with no user | Client credentials | The OAuth grant in which a client obtains a token as itself, with no user involved. |
| A running piece of software, such as the invoice job | Workload | A running piece of software, such as a pod, a function or a process. Distinct from the person or organization it works for. |
| An identity the platform issues to it | Workload identity | An identity assigned to a workload by the platform it runs on, proven with a short-lived credential the workload did not have to be given in advance. |
| One system accepting identities that another issued | Federation | One system accepting identities issued by another, by prior agreement and usually by trusting its signing keys. |
Go deeper
The same ground at full depth, when you want it. None of it is needed for the next lesson.
- Client credentialsThe agent authenticates as itself and gets a token with no user in it.
- Workload identity federationThe platform vouches for the agent, across clouds, CI and Kubernetes.
- DeploymentsWhere the first credential comes from on each kind of platform.