# Identity and access for AI agents: permissions of their own

> How to give an AI agent its own identity: delegation or acting alone, short-lived scoped tokens, workload identity, approval, audit trails and revocation.

- Published: 2026-08-25; last updated 2026-11-14
- Author: the WeStack AI team
- Subject: AI agents
- Address: https://westack.ai/blog/identity-and-access-for-ai-agents

> An agent that acts needs an identity of its own: a registered principal with an owner, credentials that expire, and permissions scoped to each tool. Borrowing a person's API key hides who did what and hands the agent everything that person can do. Decide for each action whether the agent acts as itself or on behalf of a user, issue short-lived tokens for that case, require approval for the risky ones, and log every action against the agent, the user and the run.

## Why is the admin's API key the wrong answer?

A freight forwarder builds an agent to handle shipment exceptions. It reads delay notices, updates arrival times in the transport management system, emails customers and issues goodwill credits. The developer who built the prototype put her own administrator API key in an environment variable. It worked, so it went live.

This is the most common design we meet, and it fails in five ways.

- **Attribution.** Every action is logged under her name. When a credit is issued wrongly at three in the morning, the audit trail says she did it.
- **Scope.** The key can do everything she can, including deleting customers and changing rates. The agent needs four operations.
- **Lifetime.** The key does not expire. When she leaves, either it is disabled and the agent stops, or it outlives her.
- **Injection.** Anyone who can put text in front of the agent, such as a customer writing an email, is borrowing an administrator's rights.
- **Revocation.** You cannot switch the agent off without locking her out too.

OWASP's 2026 list for LLM applications gives this pattern as an example of excessive agency: a tool that reaches downstream systems with a generic, highly privileged identity when it should act in the context of a specific user. Its agentic list has a whole entry for identity and privilege abuse. We place both in context in our [LLM application security checklist](https://westack.ai/blog/llm-application-security-checklist).

## Does the agent act as itself or for a user?

This is the first design decision, and you make it for each action, not once for the agent.

**As itself.** No person is present. A job runs each night, scans new exceptions and drafts updates. The agent has its own identity and its own permissions, like any other service.

**On behalf of a user.** A dispatcher asks the agent to rebook a shipment. The agent should be able to do no more than that dispatcher can.

In the second case there are two ways to build it, and one is wrong. [RFC 8693](https://www.rfc-editor.org/rfc/rfc8693.html), the OAuth token exchange standard, draws the line. Under impersonation the agent becomes the user as far as any system receiving the token can tell. Under delegation the agent keeps an identity separate from the user's, and the token names both: the user as subject and the agent as actor. Choose delegation every time. It is the only version in which the log can say 'the exceptions agent did this for this dispatcher'.

The rule we apply on top: the effective permission is the overlap between what the user may do and what the agent may do. The dispatcher is allowed to delete a shipment. The agent is not. So the agent acting for the dispatcher cannot delete one, however the request is phrased.

| | Acting as itself | Acting for a user |
| --- | --- | --- |
| When | Scheduled and event-driven work | A person asked for something |
| Credential | Workload identity or client credentials | A delegated token naming the user and the agent |
| Permission | The agent's own role | The overlap of the user's rights and the agent's |
| The log shows | Agent and run | Agent, user and run |
| Main risk | A broad standing role | Impersonation, or consent given once and never reviewed |

## Tokens: OAuth, scopes and short lifetimes

The mechanics are OAuth, used properly.

The user signs in through your identity provider. The agent's client obtains a token through the authorisation code flow with PKCE, asking only for the scopes the task needs. Each token is valid at one service, so a token for the shipment API is useless at the billing API. Lifetimes are minutes. Refresh happens on the server, and no token ever enters the model's context.

When the agent has to call a second service, it does not forward the token it holds. It exchanges it for a new, narrower one aimed at that service. Forwarding is how one leaked token becomes access to everything.

The Model Context Protocol requires most of this for remote tool servers. Under its current [authorisation specification](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization), an MCP server is an OAuth resource server. Clients must say which server a token is for, servers must reject tokens that were not issued for them, and a server must not pass a client's token on to an upstream API. Short-lived access tokens are recommended. A server can also answer a request with an insufficient-scope challenge, which tells the client to go back and ask for more. That is the natural hook for approval, as we will see.

Two optional extensions cover the cases the core flow does not. A client-credentials extension serves agents with no user present and prefers a signed assertion to a static secret. The [enterprise-managed authorisation extension](https://modelcontextprotocol.io/extensions/auth/enterprise-managed-authorization) puts the company's identity provider in charge of which servers each employee's client may reach, with one place to revoke. The grant underneath it is still an IETF working-group draft, although several identity providers already ship it. The server side of all this is covered in [MCP security](https://westack.ai/blog/mcp-security).

## Service accounts, workload identity and the state of standards

When the agent acts as itself, three rules apply.

1. **One identity per agent.** Not one per team, and not one shared between staging and production. Each has a named human owner.
2. **No static keys where the platform can vouch for the workload.** Cloud roles, OIDC federation and SPIFFE all work the same way: the platform attests to what the workload is and issues a short-lived credential. Nothing sits in a file waiting to be copied.
3. **Wrap the keys you cannot avoid.** Some third-party APIs offer only a long-lived, all-powerful key. Keep it in a secrets manager, put a narrow tool in front of it, and rotate it on a schedule.

Identity providers have started to treat agents as their own kind of principal. Microsoft's [Entra Agent ID](https://learn.microsoft.com/en-us/entra/agent-id/what-are-agent-identities) defines agent identities as distinct from both application identities and human users, built for agents that are created and destroyed in large numbers. It supports both autonomous and delegated access, and in Microsoft's own example the user who creates an agent is recorded as its sponsor.

The standards bodies are further behind, and say so. In February 2026 NIST's National Cybersecurity Center of Excellence published a [concept paper](https://www.nist.gov/news-events/news/2026/02/new-concept-paper-identity-and-authority-software-agents) proposing a project to demonstrate how existing identity standards can be applied to software agents, and asked for comment on identification, authorisation, auditing and non-repudiation. The OpenID Foundation's [whitepaper on identity for agentic AI](https://openid.net/new-whitepaper-tackles-ai-agent-identity-challenges/), from October 2025, concludes that current frameworks are a sound base for agents working inside one organisation, and that they were not designed for chains in which agents start other agents, or for trust that crosses organisations.

Our reading: there is no finished standard called agent identity, and you do not need one for an agent that works inside your own company. OAuth, your identity provider and workload identity cover it. Be cautious with long delegation chains across several agents and companies. Keep chains short and check authorisation again at each hop until the standards settle.

## Least privilege per tool, and elevation with approval

Permissions attach to tools, not to the agent as a whole. For the freight agent:

| Tool | Acts | Permission | Approval |
| --- | --- | --- | --- |
| `get_shipment` | For the user, or as itself | Read shipments | None |
| `update_eta` | For the user | Change one field on shipments the user can edit | None, logged |
| `email_customer` | As itself | Send approved templates to the contact on the shipment record | Sampled afterwards |
| `issue_credit` | For the user | Create a credit up to a fixed limit | Above the limit, a manager |

Three details carry the weight. The recipient of an email comes from the shipment record, so the model cannot supply an address. The credit limit is enforced in the tool's code, since a limit written in a prompt is only a suggestion. And nothing in the table says 'administrator'.

Larger credits use just-in-time elevation. The agent holds no standing permission for them. When one is needed, it requests elevation for that single action. A manager sees the exact amount, customer and reason, and on approval a token is issued that is good for that action and a few minutes. If nobody answers, the answer is no. Because the token expires, there is nothing to remember to take away afterwards.

We prefer this to a permanently powerful agent with a rule against misusing its power. The [guardrails article](https://westack.ai/blog/ai-agent-guardrails-prompt-injection) explains why a fooled model ignores such rules.

## Secrets, audit trails and revocation

**Secrets.** The model never sees a credential. Tools, or a broker in front of them, attach credentials outside the context window, so nothing secret can be coaxed out of a prompt, a memory store or a trace.

**Audit.** Every record ties an action to an agent, a user and a run:

```json
{
  "time": "2026-08-25T09:12:44Z",
  "agent": "exceptions-agent@v14",
  "on_behalf_of": "dispatcher:u_2291",
  "run": "run_8f3a",
  "tool": "issue_credit",
  "args": { "shipment": "SH-48213", "amount": 120, "currency": "GBP" },
  "decision": "approved",
  "approved_by": "manager:u_0417",
  "token_id": "jti_c91e"
}
```

Keep these where the agent cannot write. With them you can answer in minutes what the agent did for a given user in a given run, and who allowed it. Without the run identifier you are left matching timestamps.

**Revocation.** There are three levels, and each needs a tested switch:

1. Stop one run.
2. Disable the agent's identity, which stops every run.
3. Withdraw one user's delegation. This should also happen automatically when the user's account is closed.

Short lifetimes are the backstop. A token that lasts ten minutes limits the damage even when nobody notices for an hour.

Agents need a lifecycle as well. Each has an owner. When the owner leaves, the agent is reassigned or retired. Review the list every quarter, because forgotten agents accumulate just as forgotten service accounts do.

## What it costs and where it breaks

If you already have an identity provider and a secrets manager, giving one agent a proper identity is days of work. The effort goes into the table of tools and scopes, not into code.

Three things break in practice. Long-running agents outlive their tokens, so design refresh and re-approval into the loop from the start, as we describe in [long-running AI agents](https://westack.ai/blog/long-running-ai-agents). Legacy systems offer one all-powerful key and no scopes, which leaves a wrapping tool as the only control. And approval requests multiply until people stop reading them, so raise the thresholds and keep the gated actions few.

## How to start

In the first week:

1. List every agent in use and the credential each one runs on.
2. Replace any personal key with an identity that belongs to the agent.
3. For each tool, write down whether it acts as itself or for a user.
4. Cut scopes down to that table.
5. Add agent, user and run to every log line.
6. Test the off switch.

The first decision is which system is the source of truth for agent identities. Use the identity provider that already manages your people, so that agents are onboarded, reviewed and removed by the process you already run. Setting up that foundation is part of our [AI agent](https://westack.ai/services/ai-agents) and [cloud platform](https://westack.ai/services/cloud) work at WeStack AI.

## Frequently asked questions

### Should an AI agent have its own identity?

Yes. An agent that acts on other systems should be a registered principal with a named owner, its own credentials and its own permissions. Running it on a person's API key hides who did what, gives the agent everything that person can do, and means you cannot switch the agent off without locking the person out.

### What is the difference between delegation and impersonation?

With impersonation the agent presents itself as the user, and the systems behind it cannot tell the two apart. With delegation the agent keeps its own identity and acts on the user's behalf, so tokens and logs name both. Delegation is the right default for agents because it preserves accountability and lets you limit the agent separately.

### Do AI agents need OAuth?

For anything beyond a prototype, yes. OAuth gives you short-lived tokens, scopes that limit what each token can do, and one place to revoke access. The Model Context Protocol's authorisation model is built on OAuth 2.1, and identity providers are adding agent-specific features on top of the same foundation, so the work carries over.

### How do you revoke an AI agent's access?

At three levels: stop a single run, disable the agent's identity, or withdraw one user's delegation to it. Short token lifetimes are the backstop, because a token that expires in minutes limits the damage even when revocation is slow. Test all three before launch and write down who is allowed to trigger each.
