# Enforce AuthZ policy checks and KMS secret isolation

URL: https://docs.hanzo.ai/docs/guides/cyber/authz-and-kms-hardening

> Enforce explicit least-privilege checks via POST /v1/authz/check, store credentials strictly in /v1/kms/secrets, and verify mutations on GET /v1/audit.

**Zero hardcoded credentials and zero implicit permissions.** Every service and agent verifies access with `POST /v1/authz/check` and reads secrets on demand from Hanzo KMS.

## Architecture & contract

Hanzo IAM authenticates who the principal is; AuthZ decides what `(subject, action, resource)` tuple is permitted; KMS injects scoped secret paths without persisting plaintext on disk; `/v1/audit` records every access.

**Primary endpoint:** `POST /v1/authz/check` · \*_Status:_\* `shipped` · \*_Level:_\* `architect`

## Run it across all four surfaces

**CLI**

```bash
hanzo kms health
hanzo kms secrets list
hanzo audit list
```

**SDK**

**TypeScript**

```ts
import { Configuration, AuthzApi, KmsApi } from 'hanzoai';

const cfg = new Configuration({ accessToken: process.env.HANZO_API_KEY });
const [check, kms] = await Promise.all([
  new AuthzApi(cfg).postAuthzCheck({ subject: 'agent:deploy', action: 'deploy', resource: 'app:billing' }),
  new KmsApi(cfg).getKmsHealth(),
]);
console.log({ allowed: check.data, kms: kms.data });
```

**Python**

```python
import os
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AuthzApi, KmsApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
print(AuthzApi(client).post_authz_check({"subject": "agent:deploy", "action": "deploy", "resource": "app:billing"}))
print(KmsApi(client).get_kms_health())
```

**HTTP**

```bash
curl -s -X POST https://api.hanzo.ai/v1/authz/check \
  -H "Authorization: Bearer $HANZO_API_KEY" -H "Content-Type: application/json" \
  -d '{"subject":"agent:deploy","action":"deploy","resource":"app:billing"}' | jq '.'

curl -s https://api.hanzo.ai/v1/kms/health \
  -H "Authorization: Bearer $HANZO_API_KEY" | jq '.'

curl -s https://api.hanzo.ai/v1/audit \
  -H "Authorization: Bearer $HANZO_API_KEY" | jq '.'
```

**MCP**

```bash
curl -s -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "kms",
      "arguments": {"op": "get_kms_health", "input": {}}
    }
  }'
```

## Verify the outcome

- Verify an unauthorized subject returns `allowed: false` on `POST /v1/authz/check` and the check is logged in `/v1/audit`.

## Production guardrails

- Record KMS secret paths in documentation and runbooks — never log, commit, or echo secret values.

## Next steps & Hanzo University

- [Sovereign Zero-Trust AI](https://docs.hanzo.ai/docs/cybersecurity/sovereign-zero-trust)

- **[CYB 401 — Sovereign Zero-Trust AI](https://hanzo.university/sovereign-zero-trust-ai)** ([Launch interactive lab on hanzo.app/learn](https://hanzo.app/learn/sovereign-zero-trust-ai))
