Skip to content

fix: resolve user auth for github_auto dispatch (#264)#265

Open
jessie-coco wants to merge 12 commits intodevelopfrom
fix/264-github-auto-token-fallback
Open

fix: resolve user auth for github_auto dispatch (#264)#265
jessie-coco wants to merge 12 commits intodevelopfrom
fix/264-github-auto-token-fallback

Conversation

@jessie-coco
Copy link
Contributor

Summary

  • After Add auth to adapters endpoint and encrypt endpoint configs (#251) #261 removed token inheritance for security, github_auto routing (auto-detect GitHub URL → create issue) lost access to GitHub tokens
  • This adds a fallback: when a github-issue target has no token, look up the user's own GitHub auth credential (github_pat or github_oauth) from user_auths
  • Fixes dispatch failures for auto-detected GitHub URLs

Test plan

  • Unit tests: 515/515 pass
  • Deployed to jessie.coco.site/clawmark — server healthy

Closes #264

🤖 Generated with Claude Code

boot-coco and others added 12 commits March 10, 2026 03:37
Replace LIKE pattern matching with SQLite json_each() for proper JSON
array searching. The previous approach interpolated the tag parameter
into a LIKE pattern, allowing SQL wildcards (%, _) and double-quotes
to alter query semantics and leak data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Restrict externally_connectable localhost to port 3462 only
- GET_AUTH_STATE: return { authenticated, user } instead of raw JWT token
- DASHBOARD_LOGIN: validate token with server before accepting
- Dashboard: remove extension token auto-sync (use own OAuth flow)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add single-quote escaping to escapeHtml() (&#39;)
- Escape err.message in error handlers (lines 119, 137)
- Escape item.type, item.status, item.priority, item.created_by in list and thread views
- Escape item.id in data-id attribute

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
V1 item handlers (handleGetItem, handleAddMessage, handleAssignItem,
handleResolveItem, handleVerifyItem, handleReopenItem, handleCloseItem,
handleRespondToItem) did not verify that the requested item belongs to
the authenticated user's app_id. This allowed any authenticated user to
read, modify, or close items belonging to other apps.

Add the same app_id scoping check used by V2 endpoints:
  if (req.v2Auth?.app_id && item.app_id !== req.v2Auth.app_id)
    → 403 Forbidden

For handlers that previously skipped the item fetch (assign, resolve,
verify, reopen, close), an explicit getItem() call is added before the
scope check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
V1 item handlers (handleGetItem, handleAddMessage, handleAssignItem,
handleResolveItem, handleVerifyItem, handleReopenItem, handleCloseItem,
handleRespondToItem) did not verify that the requested item belongs to
the authenticated user's app_id. This allowed any authenticated user to
read, modify, or close items belonging to other apps.

Add the same app_id scoping check used by V2 endpoints:
  if (req.v2Auth?.app_id && item.app_id !== req.v2Auth.app_id)
    → 403 Forbidden

For handlers that previously skipped the item fetch (assign, resolve,
verify, reopen, close), an explicit getItem() call is added before the
scope check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both GET /api/v2/distributions/:item_id and POST .../retry had a flawed
access check that only ran when `item` was truthy. When an item was
deleted (null), the check was skipped entirely, leaking dispatch logs
and allowing retry triggers for any authenticated user.

Add an explicit null check before the access control guard so deleted
items return 404 immediately.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
)

- Create .dockerignore to exclude .git, .env, config.json, data/, *.db,
  test/, node_modules/, extension/, docs/, and *.zip from Docker image
- Add non-root clawmark user in Dockerfile to reduce container blast radius

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…oss (#250)

Add an in-memory per-document mutex (promise chain) that serializes all
read-modify-write operations on discussion JSON files. All four mutating
endpoints (POST /discussions, POST /respond, POST /discussions/resolve,
POST /submit-reply) are now wrapped in withDiscussionLock(doc, fn) so
concurrent requests on the same document are queued instead of racing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add v2Auth middleware to GET /api/v2/adapters (was unauthenticated)
- Encrypt endpoint configs at rest using the same encrypt/decrypt pattern
  already used for user_auths credentials
- Decrypt on read in getEndpoint, getEndpoints, updateEndpoint, setEndpointDefault

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ing (#252)

- Validate URL scheme (https?://) before window.open to prevent javascript: XSS
- Mask credential values in auth settings table (show last 4 chars only)
- Fix double-fetch auth using wrong property names (authToken/authUser → token/user)
- Wrap new URL() in try/catch to prevent crash on malformed source_url

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After token inheritance was removed in #261 for security, github_auto
and system_default routing lost access to GitHub tokens. This adds a
fallback that looks up the user's own GitHub auth credential when no
token is present on the target config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants