---
title: "Permission Policy"
---

Inbound auth answers "who are you"; permission policy answers "what may you do." VeADK's permission policy builds on [AgentKit Runtime](https://console.volcengine.com/agentkit/region:agentkit+cn-beijing/runtime) and the [Cedar](https://www.cedarpolicy.com/) declarative authorization language to provide end-to-end User → Agent → Tool authorization. This page shows how to define policies in the console and enable checks in code.

## Prerequisites

Following the [usage docs](https://www.volcengine.com/docs/86848/2123355?lang=zh), sign in to the Volcengine agent identity and permission platform and create a policy namespace and policies:

1. Go to **Authorization > Permission Policy** and create a policy namespace (name, description, project, and tags).
2. Add a policy in the namespace using **Visual Editor** or **Cedar Editor** (for example: allow a specific user to invoke a given agent).
3. Verify the policy with **Simulate Authorization**.

## Implementation

In the [AgentKit Runtime](https://console.volcengine.com/agentkit/region:agentkit+cn-beijing/runtime) console, set the `RUNTIME_IDENTITY_NAMESPACE` environment variable to your policy namespace (defaults to `default`), so checks match the right policy rules:

```bash
# set this to the policy namespace you actually created
export RUNTIME_IDENTITY_NAMESPACE="my-namespace"
```

Set `enable_authz=True` when initializing the agent to trigger checks. Pass the user ID to authorize at call time:

```python title="agent.py"
import asyncio

from veadk import Agent, Runner

# the user ID to authorize
user_id = "9d154b10-285f-404c-ba67-0bf648ff9ce0"

agent = Agent(enable_authz=True)
runner = Runner(agent=agent)

# user_id is the basis for the authorization check
response = asyncio.run(runner.run(messages="Hello", user_id=user_id))
print(response)
```

Outcomes:

- **Authorized**: the user has permission to invoke the agent in the namespace; the response returns normally.
- **Denied**: the user is not authorized and a permission exception is raised, e.g. `Agent <agent role> is not authorized to run by user 9d154b10-285f-404c-ba67-0bf648ff9ce0.`
