Context
All agentd services (notify, ask, wrap, orchestrator) expose HTTP APIs on localhost with no authentication or authorization. While the services currently bind to 127.0.0.1 which limits exposure, there is no mechanism to:
- Verify that requests come from legitimate agentd components
- Prevent unauthorized local processes from creating/modifying notifications or spawning agents
- Support future networked deployments where services may not be co-located
Proposed Solution
Implement a shared-secret token-based authentication scheme:
- Token generation:
xtask generates a random token during install and stores it in a shared config location (e.g., ~/.config/agentd/auth_token)
- Middleware: Each service adds an Axum middleware layer that validates
Authorization: Bearer <token> headers
- Clients:
NotifyClient, AskClient, WrapClient are updated to include the token in requests
- Health endpoints:
GET /health remains unauthenticated for monitoring
This is a stepping stone — more sophisticated auth (mTLS, JWT) can follow for networked deployments.
Acceptance Criteria
Relevant Files
crates/notify/src/api.rs, crates/ask/src/api.rs, crates/wrap/src/api.rs, crates/orchestrator/src/api.rs — add middleware
crates/notify/src/client.rs, crates/ask/src/client.rs, crates/wrap/src/client.rs — update clients
crates/cli/src/main.rs — token loading
crates/xtask/src/main.rs — token generation during install
Dependencies
No blocking dependencies. Can be worked on independently.
Related: #57 (graceful degradation), #7 (integration tests)
Context
All agentd services (notify, ask, wrap, orchestrator) expose HTTP APIs on localhost with no authentication or authorization. While the services currently bind to
127.0.0.1which limits exposure, there is no mechanism to:Proposed Solution
Implement a shared-secret token-based authentication scheme:
xtaskgenerates a random token duringinstalland stores it in a shared config location (e.g.,~/.config/agentd/auth_token)Authorization: Bearer <token>headersNotifyClient,AskClient,WrapClientare updated to include the token in requestsGET /healthremains unauthenticated for monitoringThis is a stepping stone — more sophisticated auth (mTLS, JWT) can follow for networked deployments.
Acceptance Criteria
/healthNotifyClient,AskClient,WrapClient) send auth header401 UnauthorizedRelevant Files
crates/notify/src/api.rs,crates/ask/src/api.rs,crates/wrap/src/api.rs,crates/orchestrator/src/api.rs— add middlewarecrates/notify/src/client.rs,crates/ask/src/client.rs,crates/wrap/src/client.rs— update clientscrates/cli/src/main.rs— token loadingcrates/xtask/src/main.rs— token generation during installDependencies
No blocking dependencies. Can be worked on independently.
Related: #57 (graceful degradation), #7 (integration tests)