Skip to content

Keep bot keys out of Thruster access logs - #320

Open
thomasklemm wants to merge 4 commits into
basecamp:mainfrom
thomasklemm:cursor/bot-key-header-not-path-8545
Open

thomasklemm wants to merge 4 commits into
basecamp:mainfrom
thomasklemm:cursor/bot-key-header-not-path-8545

Conversation

@thomasklemm

@thomasklemm thomasklemm commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Thruster's access log records the raw path (and query), so bot keys in /rooms/:id/:bot_key/messages survive Rails' log scrubber.

Approach

  • Bots can call /rooms/:id/bot/messages with X-Campfire-Bot-Key or Authorization: Bearer
  • Nested messages/boosts routes are declared once for both URL forms
  • Pagination Link headers follow the current request
  • Webhooks keep legacy room.path and add room.api_path + room.bot_key for header auth
  • Query-string bot_key is ignored (Thruster logs query too)
  • Bots page curl snippets use the header form; the old path still works

Fixes #272.

Copilot AI balanced review requested due to automatic review settings October 5, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Webhook payloads still distribute credential-bearing paths, and Bearer scheme parsing is incorrectly case-sensitive.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Adds header-based bot authentication to prevent credentials appearing in Thruster access logs while preserving legacy URLs.

Changes:

  • Adds credential-free bot API routes with header/Bearer authentication.
  • Preserves pagination paths and updates generated curl commands.
  • Adds tests and operator security guidance.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
app/​controllers/​concerns/​authentication.rb Reads bot credentials from headers.
app/​controllers/​messages/​by_bots_controller.rb Preserves the current route in pagination links.
app/​views/​accounts/​bots/​_bot.html.erb Generates header-authenticated curl commands.
config/​routes.rb Adds credential-free bot API routes.
docs/​self-hosting.md Documents safe bot authentication and logging risks.
SECURITY.md Documents bot-key handling guidance.
test/​controllers/​messages/​by_bots_controller_test.rb Tests header authentication and pagination.
test/​controllers/​messages/​boosts/​by_bots_controller_test.rb Tests header-authenticated boosts.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread config/routes.rb
Comment thread app/controllers/concerns/authentication.rb
thomasklemm added a commit to roundhouse-rb/once-campfire that referenced this pull request Oct 5, 2026
From thomasklemm:cursor/bot-key-header-not-path-8545 (upstream PR state at merge: OPEN).
thomasklemm added a commit to roundhouse-rb/once-campfire that referenced this pull request Oct 5, 2026
From thomasklemm:cursor/bot-key-header-not-path-8545 (upstream PR state at merge: OPEN).
thomasklemm added a commit to roundhouse-rb/once-campfire that referenced this pull request Oct 5, 2026
…aths

preview already merged basecamp#306. Stacking basecamp#320 must not drop the
response.code == "200" check on attachment replies.
cursoragent and others added 4 commits October 7, 2026 19:47
Accept X-Campfire-Bot-Key or Authorization: Bearer on /rooms/:id/bot/...
so the credential is not in the path Thruster logs. The old path still
works; curl snippets on the bots page use the header form.

Fixes basecamp#272.

Co-authored-by: Thomas Klemm <github@tklemm.eu>
Share the nested messages/boosts tree between the header path and the
legacy bot-key path. Build pagination Link headers from the current
request so they follow whichever form the client used.

Co-authored-by: Thomas Klemm <github@tklemm.eu>
Keep room.path as the legacy URL. Add api_path plus bot_key so new
clients can POST with a header. HTTP auth schemes are case-insensitive.

Co-authored-by: Thomas Klemm <github@tklemm.eu>
Thruster logs query as well as path, so accepting ?bot_key= on
/rooms/:id/bot/... would reopen the credential leak. Read the key only
from the path segment, X-Campfire-Bot-Key, or Authorization. Trim docs
to self-hosting and cover the rejection in tests.

Co-authored-by: Thomas Klemm <github@tklemm.eu>
@thomasklemm

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and tightened the auth surface after review:

  • Bot keys are read only from the path segment, X-Campfire-Bot-Key, or Authorization — not from ?bot_key=, which Thruster would still log in query
  • Docs live in docs/self-hosting.md (removed the duplicate from SECURITY.md)
  • Copilot’s earlier webhook api_path / bot_key and case-insensitive Bearer notes remain in place

@cursor
cursor Bot force-pushed the cursor/bot-key-header-not-path-8545 branch from d2cfd56 to 903cb23 Compare October 7, 2026 19:54
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.

Bot key is still written to the log in the clear — Thruster's access log isn't covered by #269

3 participants