• Stefy Lanza (nextime / spora )'s avatar
    api: enforce API tokens under a bare uvicorn start · f4482fd5
    Stefy Lanza (nextime / spora ) authored
    Found while checking the production proxy path. BearerAuthMiddleware falls
    OPEN when admin.routes.session_manager is None and no CODERAI_API_TOKEN is
    set: with no user database to check a token against it lets the request
    through rather than locking out an install with no auth configured. That is
    defensible on a loopback workstation.
    
    main.py and build_system_app() both initialise that database. A bare
    `uvicorn codai.api.app:app` start — exactly how the GPU-less orchestrator
    runs — did not, so once published through a reverse proxy every /v1/* call
    was served WITHOUT credentials. Verified before and after: session_manager
    None on import, /v1/models 200 with no header; now initialised at import
    and 401 for no header, a wrong Bearer, and nginx's Basic.
    
    The readiness probes stay open on purpose (/healthz, /health, /v1/health):
    a probe behind auth is read as "backend down" by every health checker,
    surya-ocr's vLLM client included.
    
    The guide gains the three traps of that deployment: auth_basic and Bearer
    share one header so the API path must not be basic-authed, proxy_buffering
    must be off for streaming, and how to check in one curl whether tokens are
    actually enforced.
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    f4482fd5
Name
Last commit
Last update
codai Loading commit data...
docs Loading commit data...
packaging Loading commit data...
samples Loading commit data...
tests Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.dockerignore Loading commit data...
.gitignore Loading commit data...
AI.PROMPT Loading commit data...
CODERAI_API_DOCUMENTATION.md Loading commit data...
CoderAI.gif Loading commit data...
DISTRIBUTION.md Loading commit data...
LICENSE.md Loading commit data...
MULTIMODAL_CAPABILITIES.md Loading commit data...
MULTIMODAL_UI_EXAMPLES.md Loading commit data...
README.md Loading commit data...
REQUEST-geoclip-embeddings.md Loading commit data...
REQUEST-vpr-embeddings.md Loading commit data...
amdgpu-coredump-05000.bin Loading commit data...
build-oci.sh Loading commit data...
build.ps1 Loading commit data...
build.sh Loading commit data...
coderai Loading commit data...
coderai-broker-implementation-reference.md Loading commit data...
coderai-integration.md Loading commit data...
commands Loading commit data...
osxbuild.sh Loading commit data...
package-oci.sh Loading commit data...
package-tarball.sh Loading commit data...
requirements-crisperwhisper.txt Loading commit data...
requirements-h3.txt Loading commit data...
requirements-longcat-train.txt Loading commit data...
requirements-longcat.txt Loading commit data...
requirements-melotts.txt Loading commit data...
requirements-nemo.txt Loading commit data...
requirements-nvidia.txt Loading commit data...
requirements-ocr-paddle.txt Loading commit data...
requirements-ocr.txt Loading commit data...
requirements-pyannote.txt Loading commit data...
requirements-surya.txt Loading commit data...
requirements-vllm.txt Loading commit data...
requirements-vulkan.txt Loading commit data...
requirements.txt Loading commit data...
run-oci.sh Loading commit data...
smoke-test-oci.sh Loading commit data...
todo.md Loading commit data...