Commit Graph

17 Commits

Author SHA1 Message Date
Hugh Brown
ce18fe4f0c fix: apply rate limiting to optional agent auth path
get_agent_auth_context_optional was not rate-limited, allowing
brute-force token guessing via routes that use require_user_or_agent.
Now applies agent_auth_limiter when a token is actually presented.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
54279bf413 revert: restore truncated token_prefix in agent auth log messages
A 6-character prefix of the token is standard practice for debugging
failed auth attempts and is not a security risk. Restored in both
required and optional auth paths, and removed the now-incorrect test
that asserted its absence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
94988deef2 security: add rate limiting to agent auth and webhook ingest
Agent token auth performed O(n) PBKDF2 operations per request with no
rate limiting, enabling CPU exhaustion attacks. Webhook ingest had no
rate limits either. Add an in-memory token-bucket rate limiter:
- Agent auth: 20 requests/minute per IP
- Webhook ingest: 60 requests/minute per IP

Includes unit tests for the rate limiter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
4257c08ba9 security: stop logging token prefix on failed agent auth
The first 6 characters of invalid agent tokens were logged, leaking
partial credential information. Remove token_prefix from log messages
while preserving the request path for debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hanush H Nair
4c35cb03ad fix(backend): Return None instead of 401 when agent not found in get_agent_auth_context_optional 2026-02-27 23:19:40 +05:30
Adam Grenier
3b20e799e2 fix: accept Authorization: Bearer in agent_auth_context_optional
The optional variant of get_agent_auth_context had accept_authorization=False,
which prevented agents using Authorization: Bearer from passing through the
ACTOR_DEP / BOARD_READ_DEP / TASK_DEP dependency chain.

This caused 401 on any agent route that resolves a board or task via the shared
ACTOR_DEP (e.g. PATCH /agent/boards/{id}/tasks/{id} and
POST /agent/boards/{id}/tasks/{id}/comments), even though the same token worked
fine on routes that use AGENT_CTX_DEP directly (accept_authorization=True).

Fix: set accept_authorization=True in get_agent_auth_context_optional so both
X-Agent-Token and Authorization: Bearer are accepted consistently.

Verified: PATCH and POST /comments now resolve board/task correctly when
Authorization: Bearer is used. No security regression — agent_token_hash
comparison rejects any non-agent bearer tokens.
2026-02-26 11:51:45 -08:00
Abhimanyu Saharan
e9e0d6960a docs(backend): clarify auth/error-handling via docstrings 2026-02-12 08:27:31 +00:00
Abhimanyu Saharan
8d0b2939a6 feat: enhance logging configuration and add request logging context 2026-02-11 16:49:43 +05:30
Abhimanyu Saharan
8f6347dc8d refactor: simplify code formatting and improve readability across multiple files 2026-02-09 20:44:05 +05:30
Abhimanyu Saharan
7ca1899d9f refactor: update module docstrings for clarity and consistency 2026-02-09 15:49:50 +05:30
Abhimanyu Saharan
844b521d00 Touch agent presence on authenticated requests 2026-02-07 04:34:16 +05:30
Abhimanyu Saharan
4bab455912 feat: implement task dependencies with validation and update handling 2026-02-07 00:21:44 +05:30
Abhimanyu Saharan
d86fe0a7a6 feat: add validation for minimum length on various fields and update type definitions 2026-02-06 16:12:04 +05:30
Abhimanyu Saharan
f258b756e8 feat: refactor imports and clean up code formatting across multiple files 2026-02-06 02:43:08 +05:30
Abhimanyu Saharan
4cc6c42440 feat: add is_board_lead property to agent and board types 2026-02-05 19:06:32 +05:30
Abhimanyu Saharan
51313a9272 feat(activity): Simplify query statements and improve code readability 2026-02-05 00:21:33 +05:30
Abhimanyu Saharan
b0e3208fa3 feat: enhance agent management with session handling and UI improvements 2026-02-04 14:58:20 +05:30