feat(api): enforce communication token auth with public status subset - #175
Merged
Zoupers merged 14 commits intoAug 16, 2026
Merged
Conversation
Merged
via the queue into
VirtualBeingsResearch:main
with commit Aug 16, 2026
eb2b37b
8 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR hardens Coworker API communication authentication while preserving the
previous local behavior until an administrator explicitly configures a
communication token.
Behavior:
API__COMMUNICATION_TOKEN:POST /messages,GET /status, andGET /logs/streambehave exactly as before. Desktop communication keeps theadministrator-token fallback.
API__COMMUNICATION_TOKENconfigured:POST /messagesrequiresAuthorization: Bearer <token>(401 otherwise).GET /statuswithout a valid Bearer returns only basic lifecycle fields;a valid Bearer returns the full snapshot.
GET /logs/streamrequires a valid Bearer.API__DEVELOPMENT_MODEsetting has been removed;Desktop HTTPS enforcement remains controlled by Desktop's
security.development_mode.Implementation
src/coworker/api/routes.py: explicit-token flag separate from the effectivetoken used for Desktop fallback; public/full
/statusbranching; removed the_development_modeearly return; token helper for other routes.src/coworker/api/app.py:/logs/streamBearer gate when a token isexplicitly configured.
src/coworker/application.py: passes the explicit-token flag from config.reports an explicitly configured token; the back-face runtime log stream now
uses an authenticated fetch stream and reconnects automatically.
api.communication_tokenhas Generate and Copytoken buttons. Generate creates a Relay-compatible
cwct_v1_<32-byte-base64url>token; Copy fetches the effective token from thenew
GET /api/admin/communication-tokenendpoint and writes it to theclipboard. Saving hot-applies to the running API without a restart;
.envchanges still require a restart.
GET /profileis also gated once a token is explicitly configured, so anunauthenticated status page can no longer trigger profile-reminder inbox
events as a side effect.
src/coworker/web/assets vianpm --prefix web run build.examples/chat.html,examples/api_test.html, andexamples/api.pyfor Bearer support and partial-status guidance.observability, upgrading, Desktop development, and configuration pages.
Validation
pytest(offline image): 1771 passed, 1 skippedruff check src tests examples/api.py: passedmypy src: passednpm --prefix web run build: passedpython scripts/check_version.py: passedgit diff --check: passedNot run: Rust/Desktop checks (
cargo, desktop npm tests) and Explore Labbackend tests — no code in those areas changed.
Risks / compatibility
API__COMMUNICATION_TOKEN: REST integrations and the Web identity page mustthen provide the Bearer. The identity page and Web chat provide token inputs.
unauthenticated local behavior; production deployments should configure
API__COMMUNICATION_TOKEN.API__DEVELOPMENT_MODEsetting has been removed.