Skip to content

API Reference parrot.auth.eval_context

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.auth.eval_context

View source

Canonical PBAC EvalContext builder for AI-Parrot (FEAT-446).

Consolidates the three eval-context builders that previously lived independently in parrot/auth/agent_guard.py, parrot-server/handlers/bots.py (_PBACHandlerMixin), and parrot-server/handlers/agent.py into a single implementation so S1 (FEAT-442 program) has exactly one place to inject tenant_id.

Function build_eval_context

Build a navigator-auth EvalContext from an aiohttp request.

Reads the authenticated session (populated by Guardian middleware on request.session, falling back to navigator_session.get_session) and constructs the EvalContext navigator-auth's PolicyEvaluator expects: it is a required-positional-args constructor — EvalContext(request, user, userinfo, session, *, org_id=None, client_id=None) — and PolicyEvaluator._build_user_context reads ctx.userinfo / ctx.user (not flat username/groups/ roles kwargs) to resolve the evaluation subject.

build_eval_context(request: web.Request) -> object | None

Parameter Type Default Description
request web.Request The incoming aiohttp request with a Guardian-populated session (or one resolvable via navigator_session.get_session).

Returns: object | None — An EvalContext instance, or None if navigator-auth is not installed, the session is unavailable, or construction fails (fail-open — callers must handle None).

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally