Version 1.1 Picture guide
How ProcurAuth works
A picture guide for the author of a backend or of a service. Alice and her AI agent are the example. Read it before the specification.
1. Who manages what
ProcurAuth lets a backend manage the rights of its users and the rights of the AI agents that act for them. Alice is a user. She gives her agent a key.
- Alice's agent holds only the text of a key. It never holds a right.
- The edge checks the key and gives the service an identity token.
- The service holds a PEP. It speaks AuthZEN: it asks the PDP for each call and applies the answer.
- Your backend holds the rights. When Alice changes a right or revokes the key, the services change nothing.
2. The roles
Four parts take part in a call of Alice's agent. Your service is one of them.
The edge stands in front of the service. The service accepts requests only through the edge. The PDP decides. The service never decides alone.
3. The flow of one call
One call has five steps. Follow the numbers in the figure.
- The agent of Alice shows its key to the edge, in the
Authorizationheader. - The edge checks the key. It gives the service a signed identity token. The key text does not go on.
- The service asks the PDP: can this subject do this action on this resource?
- The PDP answers yes or no. A yes can carry limits.
- The service acts, or it refuses.
The service sends only the subject id to the PDP. It never sends the text of the key.
A route that runs no action of the action document, for example a static file, asks the action access on the service. A health-probe route needs no token and asks no question.
The PDP can also ask for the approval of the owner before an action runs. The service then runs nothing until the owner approves. The MCP binding tells how a tool waits for the approval.
4. A key never has more than its owner
A key is a subject. It acts for a person, its owner. Alice makes a key for her agent. The key has its own grants.
The PDP answers yes for a key only when two things are true. A grant of the key gives the action and covers the resource. The owner has that right now.
When Alice loses a right, her agent loses it too. The PDP copies no right. It checks the owner at each decision. A kept answer in the service can delay this by cache_ttl at most.
5. Coverage
The resources of a service form a tree. In the example, the types are host, database and table. Each resource has a chain of ancestors, from the service down.
A grant on a node covers the node and each node below it. This includes a node that the service adds later. A grant never covers a node above it.
- G: the grant
- covered
- not covered
- added later
To give her agent two databases only, Alice gives one grant on each of them. The service builds the chain from its own data. It never takes the chain from a client.
6. Limits: ceilings and budgets
A grant can carry limit values, so Alice can bound her agent. A limit has a kind: a ceiling or a budget. The two kinds work in different places.
| Property | Ceiling | Budget |
|---|---|---|
| Example | max_duration = 30 s | 10 per second and 300 per minute |
| What it bounds | One use | Many uses, over time |
| Who applies it | The service | The PDP, which counts |
| In the answer | The value, in context.limits | No value. The answer shows the units that the PDP took. |
| When it stops a call | The service stops the use at the value. | The PDP answers no, with budget_exceeded and retry_after, the seconds to wait. |
A budget has one to four windows: second, minute, hour or day. Each window has its own counter. A use takes one unit from each counter, or from none. The service maps the refusal to HTTP 429, with Retry-After.
7. The identity token
The edge gives the service a short signed token for one subject, here the key of Alice's agent. The token is a JWT. The service checks the signature, the issuer, the audience and the times.
owner, and its sub is the id of the person.- The token has no grant, no limit and no decision.
- The service sends only
subto the PDP. - The service never uses
ownerin a decision. It is for logs and approvals. - The service refuses a token that has a bad signature, a bad issuer, a bad audience or a bad time.
- The times
iat,expand the optionalnbfare JSON integers with digits only. The service refuses a fraction, an exponent or a sign. - When the edge has more than one signing key, each token has
kid. The service then refuses a token withoutkid.
8. The action document and the options route
A service publishes two documents. Both are below the same well-known path. A system that shows Alice a form for grants reads them.
The action document
The service publishes it at /.well-known/procurauth/actions, with no login. It is a JSON object. These members are mandatory: server, resource_types and actions. The members resources and limits are optional.
serveris the id of the service. It equals theaudof the tokens.resource_typesis the tree of types. Each item hasname,parentanddescription.actionslists each action withname,resource_types,descriptionandlimits.limitsdeclares each limit withname,label,description,unitandkind. A ceiling also hasminandmax.
{ "server": "datastore", "resource_types": [ { "name": "host", "parent": "service", "description": "One database server." }, { "name": "database", "parent": "host", "description": "One database." }, { "name": "table", "parent": "database", "description": "One table." } ], "actions": [ { "name": "data.read", "resource_types": [ "service", "host", "database", "table" ], "description": "Read data.", "limits": ["requests", "max_rows", "max_duration"] }, { "name": "data.write", "resource_types": [ "service", "host", "database", "table" ], "description": "Change data.", "limits": ["requests", "max_duration"] } ], "resources": [ { "path": "host:prod", "label": "Production" } ], "limits": [ { "name": "requests", "label": "Requests", "description": "Requests that run.", "unit": "request", "kind": "budget" }, { "name": "max_rows", "label": "Most rows", "description": "The most rows that one read gives.", "unit": "rows", "kind": "ceiling", "min": 1, "max": 1000000 }, { "name": "max_duration", "label": "Longest run", "description": "The longest run of one use, in seconds.", "unit": "seconds", "kind": "ceiling", "min": 1, "max": 600 } ]}Check a document like this one with access-lint. Rules: 5.1, 5.2, 5.3, 6.1.
The options route
A form where Alice gives grants to her agent needs a list of choices. The route /.well-known/procurauth/resources lists the children of a node. The request has these query parameters:
parent: optional. The path of the node, for examplehost:prod.type: mandatory. The type of the children.q: optional. A search text.limit: optional. The most items to give.after: optional. The value ofnextfrom the last answer.
The caller encodes each value in percent form. Thus host:prod is host%3Aprod.
GET /.well-known/procurauth/resources ?parent=host%3Aprod &type=database &q=test &limit=2 { "items": [ { "id": "test1", "label": "test1", "has_children": true }, { "id": "test2", "label": "test2", "has_children": true } ], "next": null}The databases of the host prod whose names hold test, two at a time. The value next is null on the last page. Rules: 5.6, 5.7, 5.8, 5.9.
9. Glossary
- Action
- What a subject does, for example
data.read. - Action document
- The document in which a service declares its types, actions and limits.
- Agent
- An AI program that uses a key. It is not a subject.
- Backend
- The system of the operator. It holds the users, their rights, the keys of their agents and the limit values, and the PDP decides from this data.
- Budget
- A limit that gives units for one or more windows. The PDP counts it.
- Ceiling
- A limit on one use, for example
max_duration. The service applies it. - Chain
- The ancestors of a node, from the service down.
- Counter
- The units that one subject spent on one window of a budget.
- Coverage
- The rule that a grant on a node covers the node and each node below it.
- Edge
- The part in front of a service. It checks the key and gives the identity token.
- Grant
- A right to do an action on a resource. It can carry limit values.
- Identity token
- A short signed token that the edge gives a service for one subject.
- Key
- A subject that acts for a person. It never has more rights than its owner.
- Options
- The children of a node that a service lists for a form.
- Owner
- The person for whom a key acts.
- PDP
- The decision point. It answers yes or no, and it counts budgets.
- PEP
- The part of a service that asks the PDP and applies the answer.
- Resource
- A node in the tree of a service: the service, a host, a database or a table.
- Service
- The application that holds a PEP. It is the root of its tree.
- Subject
- A person or a key. A key id has a colon, for example
key:9b1c04e2aa71f0c3. - Window
- The fixed period of a counter: second, minute, hour or day.