Typed request principal exposing headers and cookies for auth.
# Source: https://github.com/zylon-ai/private-gpt | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
from __future__ import annotations
from private_gpt.context import current_bag, reset_bag
_HEADERS_KEY = "headers"
_COOKIES_KEY = "cookies"
class Principal:
"""Request-scoped principal carrying HTTP headers and cookies.
The principal is a typed view over the shared context bag (see
``private_gpt.context``). ``Principal.current()`` reads the bag and exposes
the request's headers/cookies as typed claims — no parameter threading
needed. Because the bag travels with ARQ / Celery jobs, the principal is
automatically available on workers.
A ``Principal`` con
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key