Authorization
How Anvio decides what an authenticated identity can do — trust zones, approvers, blocked users, and the human approval gate.
5 min read
Authentication (see Authentication) answers "who is this?" Authorization answers "what can they do?" Anvio's authorization model is built from two complementary mechanisms: RBAC (roles, Level 3+) and the Soul Gate policy engine (trust zones, approvers, blocked users — available from Level 1).
RBAC (Level 3+)
Per docs/12-security.md, role-based access control activates once a multi-user PostgreSQL deployment is enabled. At Level 1–2, every request resolves to a single local user with the user role via NoAuthProvider (see Authentication); there's nothing to authorize against beyond the soul-gate policy below.
AuthContext carries a roles: string[] array populated from the JWT payload's roles claim when auth.provider: jwt is active:
// packages/auth/src/index.ts
const payload = jwt.verify(token, this.secret) as { sub: string; email?: string; roles?: string[] };
return { userId: payload.sub, email: payload.email, roles: payload.roles ?? ['user'], provider: 'jwt' };TODO: The specific role names, permission matrix, and enforcement points for RBAC beyond "roles exist on the auth context" were not found in the source at this depth.
docs/12-security.mdonly states RBAC activates at Level 3+ without further detail — treat fine-grained RBAC as a Level 3+ capability still being fleshed out, not a fully documented system today.
Soul Gate policy (all levels)
The mechanism that actually gates tool execution and channel behavior today — independent of RBAC — is the Soul Gate: a policy engine that parses a SOUL.md file (Hermes/slaude-style) into a SoulPolicy object enforced by the channel harness. See Soul Gate Policy for the full policy-file format; this page covers the authorization mechanics it drives.
Trust tiers
packages/harness/src/policy-enforcer.ts resolves every inbound message to one of three trust tiers before any tool call is considered:
export function resolveTrustTier(
policy: SoulPolicy,
channel: ChannelType | string,
zoneId?: string,
): HarnessTrustTier {
if (!zoneId) return 'restricted';
if (inTrustedZones) return 'trusted';
if (inAllowedZones) return 'allowed';
return 'restricted';
}| Tier | Meaning |
|---|---|
trusted | Zone (channel + ID, e.g. a specific Slack workspace or Telegram chat) is explicitly listed in policy.trustedZones. |
allowed | Zone is listed in policy.allowedZones but not trusted. |
restricted | Default — zone not recognized, or no zone ID supplied at all. |
Restricted-zone and DM access
export function canAccessRestrictedZone(
policy, channel, userId, trustTier, dmPolicy, isDm,
): boolean {
if (trustTier === 'trusted' || trustTier === 'allowed') return true;
if (isDm && dmPolicy === 'manager_only') return isManagerUser(policy, channel, userId);
if (!isDm && trustTier === 'restricted') return isManagerUser(policy, channel, userId);
return true;
}In practice: trusted/allowed zones always pass. A DM in a manager_only-policy channel (see workspace/harness/channel-profiles.yaml, where slack-like profiles default to dmPolicy: manager_only) only passes for the manager or backup manager. A restricted, non-DM message also falls back to manager-only.
Blocked users
export function isUserBlocked(policy, channel, userId): boolean {
return policy.blockedUsers.some(
(u) => matchesChannelRef(u.channel, channel) && u.userId === userId,
);
}Blocked users are checked against channel:userId pairs from the SOUL.md policy — a block on slack:U12345 doesn't block that same ID on Telegram unless the channel ref is a wildcard.
Manager / backup manager
export function isManagerUser(policy, channel, userId): boolean {
const managerIds = [policy.manager?.userId, policy.backupManager?.userId].filter(Boolean);
return managerIds.some(/* id matches AND channel matches */);
}Manager identity comes straight from the SOUL.md ## Reporting section (e.g. Manager: cli:local-user in workspace/souls/architect-soul/SOUL.md).
Human approval gate
Beyond zone-based authorization, Anvio enforces a per-action human approval workflow for sensitive tool calls, implemented in packages/harness/src/approval-gate.ts.
Key behaviors from ApprovalGate:
- Every request gets a
randomUUID()request ID and is tracked in an in-memorypendingmap alongside aHarnessApprovalContext. resolve(requestId, userId, approved)only succeeds ifisAuthorizedApprover()confirms the resolvinguserIdis actually listed as an approver for that channel/summary in the soul policy — an arbitrary channel member cannot approve someone else's pending action.scheduleTimeout()auto-rejects (resolvedBy: 'system:timeout',approved: false) afterapprovalTimeoutSeconds()— configured per-soul, e.g.workspace/souls/architect-soul/SOUL.md's## Approval timeout→seconds: 3600.- The legacy
authorize(requestId, userId)method is@deprecatedin favor ofresolve(requestId, userId, true).
Approvers in SOUL.md
## Approvers
- cli:local-user: anything ; catchallApprovers are parsed by packages/soul-gate/src/verifier.ts's parseApproversSection(), which extracts channel-qualified IDs (slack:U123, cli:local-user, etc.) and a scope string, plus a catchall flag when the line contains "catchall" or "anything". A catchall approver can approve any pending action regardless of scope; scoped approvers are matched against the action summary.
verifyPolicyIds() (packages/soul-gate/src/verifier.ts) is a safety net: it strips any blocked user, approver, manager, or zone ID from the parsed policy that doesn't appear verbatim in the source SOUL.md text. This guards against an LLM-assisted policy extraction hallucinating IDs that were never actually written in the file.
Summary: what gates a tool call
- Trust tier — is this channel/zone trusted, allowed, or restricted?
- Blocked list — is this specific user blocked on this channel?
- DM policy — for direct messages, is
manager_onlyin effect, and if so, is the sender the manager? - Approval gate — for actions the soul mandate marks as requiring approval (e.g. "Request human approval before mutating production or shared infrastructure" from the architect-soul mandate), does an authorized approver respond before timeout?
Last updated on