Agent Wranglers

ACC-39Required

Limit tokens and agents to what their owner may do

Give an API key, connected app or AI agent at most its creator's permissions. Check the creator's current role on every call.

How to do it

Store the creator and the scopes on each key. Allow an action only when the key's scopes and the creator's current role both allow it. A key from a demoted admin then loses admin actions at once. When the creator leaves the organisation, suspend their keys and tell the owners. Name scopes as give each token only the scopes its job needs says. An exchanged token keeps the same limits, as Never widen an agent's rights when you exchange its token says.

Examples

JavaScript example

export const canWithKey = (key, creatorMembership, permission) =>
  key.scopes.includes(permission) && can(creatorMembership, permission);

Python example

def can_with_key(key, creator_membership, permission: str) -> bool:
    return permission in key.scopes and can(creator_membership, permission)

How to check

As a test admin, make a key with an admin scope, then demote the admin to member. The key's next admin call answers 403.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/accounts/roles-and-permissions/delegated-permissions">Agent Wranglers accounts and identity playbook</a>. In code you write, add a comment next to it with the same link.