Skip to content

fix: CSRF protection, task supervision, orphan draft recovery, pinned deps#11

Merged
diese-tech merged 1 commit into
mainfrom
claude/godforge-version-bump-pybPR
May 14, 2026
Merged

fix: CSRF protection, task supervision, orphan draft recovery, pinned deps#11
diese-tech merged 1 commit into
mainfrom
claude/godforge-version-bump-pybPR

Conversation

@diese-tech
Copy link
Copy Markdown
Owner

Summary

  • CSRF protection: Dashboard POST endpoints now require an X-CSRF-Token header matching a godforge_csrf cookie set at login. Covers both password and Discord OAuth login paths. Cleared on logout.
  • Task supervision: cleanup_task now has an @error handler that logs the exception and restarts the task instead of silently dying.
  • Orphan draft recovery: Active local draft channel IDs are persisted to data/active_local_drafts.json. On restart, on_ready() notifies each orphaned channel that its draft was lost and needs to be restarted.
  • CORS/session documented: .env.example now documents GODFORGE_ALLOWED_ORIGIN and GODFORGE_SESSION_SECRET as required for production.
  • Dependency pinning: requirements.txt pinned to current installed versions (discord.py 2.7.1, python-dotenv 1.2.2, aiohttp 3.13.5).

Test plan

  • 126/126 pytest tests pass
  • Verify dashboard POST requests without X-CSRF-Token header return 403
  • Verify restart posts orphan message to a channel that had an active draft

https://claude.ai/code/session_01Nfjayt2FK3coWyeWETtYpY


Generated by Claude Code

CSRF protection:
- web_api/server.py: generate godforge_csrf cookie on login (non-HttpOnly
  so JS can read it); require X-CSRF-Token header to match cookie on all
  protected POST endpoints; clear CSRF cookie on logout; covers both
  password and Discord OAuth login paths
- tests: introduce _Session namedtuple so _login() bundles session cookie
  + CSRF token; _request() transparently sends both when given a _Session

Task supervision:
- bot.py: add @cleanup_task.error handler to log and restart on crash

Draft state recovery on restart:
- bot.py: persist active local draft channel IDs to data/active_local_drafts.json
  on start, remove on end; on_ready() reads the file, notifies each orphaned
  channel that the draft was lost, and clears the file

CORS env var documented:
- .env.example: add GODFORGE_ALLOWED_ORIGIN and GODFORGE_SESSION_SECRET
  with production guidance

Dependency pinning:
- requirements.txt: pin discord.py==2.7.1, python-dotenv==1.2.2, aiohttp==3.13.5

https://claude.ai/code/session_01Nfjayt2FK3coWyeWETtYpY
@diese-tech diese-tech merged commit 638b14d into main May 14, 2026
2 checks passed
@diese-tech diese-tech deleted the claude/godforge-version-bump-pybPR branch May 14, 2026 04:37
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