Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / module

auth

shared.auth

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Calls (1)
SymbolFileResolved by
Principalauth.pysame file
Contains (8)
SymbolFileResolved by
_configuredauth.pysame file
allowed_forauth.pysame file
is_publicauth.pysame file
parse_bearerauth.pysame file
Principalauth.pysame file
principal_for_tokenauth.pysame file
require_adminauth.pysame file
token_problemsauth.pysame file
Imported by (1)
SymbolFileResolved by
routerrouter.pythrough an import
shared.authbackend/app/shared/auth.py, lines 1–40Open source
"""Machine-to-machine authentication.Pharos is single-tenant: its clients are the owner's own tools (Ronin, anMCP client such as Claude Code, the CLI, the edge worker). Authentication istherefore two static bearer tokens rather than user accounts:``PHAROS_ADMIN_TOKEN``  full access: ingestion, deletion, admin endpoints.``PHAROS_READ_TOKEN``   optional, read-only: GET requests plus the read-only                        POST endpoints listed in ``READ_ONLY_POST_PREFIXES``                        (search, context retrieval, MCP). Give assistants                        this token so a prompt-injected agent cannot trigger                        clones of arbitrary repositories or delete data.Threat model and rotation are documented in ``SECURITY.md``. Properties:* fail closed — if no token is configured, every protected request is 401;* constant-time comparison (``hmac.compare_digest``);* tokens are never logged; failures log only the path;* public paths are matched exactly (no prefix tricks like ``/healthz``)."""from __future__ import annotationsimport hmacimport loggingimport osimport uuidfrom dataclasses import dataclassfrom fastapi import HTTPException, Request, statuslogger = logging.getLogger(__name__)PUBLIC_PATHS = frozenset(    {        "/health",        "/docs",        "/docs/oauth2-redirect",        "/redoc",        "/openapi.json",

Shows the first 40 of 157 lines. The rest is on GitHub at this commit.

What the index recorded

Signature
module backend.app.shared.auth
File
backend/app/shared/auth.py
Lines
1–157
Parser
python-ast
Git blob
c77f24b3d7406a6b302764a8fc5e475c40480e60
Call sites
3 named, 1 resolved, 2 left unlinked
Outside this subset
4 more edges reach code outside the graph shown here

Read it on GitHub at this commit