Skip to content

PICOCLAW_GATEWAY_TOKEN env var does not control pico channel authentication #2438

@bamnenim-permissionlabs

Description

@bamnenim-permissionlabs

Description

The PICOCLAW_GATEWAY_TOKEN environment variable is commonly assumed to control WebSocket authentication for the /pico/ws channel. However, this is misleading:

  • PICOCLAW_GATEWAY_TOKEN only controls health check and reload endpoints (/health, /reload)
  • The /pico/ws channel authentication is controlled by .security.yml, specifically the channels.pico.token field
  • At runtime, PicoClaw applies a token override mechanism that prepends "pico-" plus a PID-based random token to the configured value
  • This dual-token system is undocumented, making it extremely difficult to integrate PicoClaw with external orchestration systems

This caused significant debugging effort in our deployment because all documentation and typical usage patterns suggest PICOCLAW_GATEWAY_TOKEN should be the source of truth for gateway authentication.

Steps to Reproduce

  1. Deploy PicoClaw with PICOCLAW_GATEWAY_TOKEN=my-secret-token set
  2. Attempt to connect to /pico/ws using the token my-secret-token in the WebSocket handshake
  3. Connection fails with 401 Unauthorized
  4. Inspect .security.yml and .picoclaw.pid files
  5. Observe that the actual required token is pico-{random-pid-token}{configured-channel-token}

Expected vs Actual Behavior

Expected: PICOCLAW_GATEWAY_TOKEN is the authoritative token for all gateway authentication (including /pico/ws), or the documentation clearly states which env vars control which endpoints.

Actual: PICOCLAW_GATEWAY_TOKEN only affects health/reload endpoints. The /pico/ws token is constructed at runtime from .security.yml plus a PID-based override, making it impossible to predict without reading generated files.

Suggested Fix

  1. Update README and config examples to clearly document which env vars control which endpoints
  2. Document the token override mechanism (overridePicoToken) and how it constructs the final token
  3. Consider adding a config option to disable the PID-based token override for external orchestration use cases

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions