fix: CSRF protection, task supervision, orphan draft recovery, pinned deps#11
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
X-CSRF-Tokenheader matching agodforge_csrfcookie set at login. Covers both password and Discord OAuth login paths. Cleared on logout.cleanup_tasknow has an@errorhandler that logs the exception and restarts the task instead of silently dying.data/active_local_drafts.json. On restart,on_ready()notifies each orphaned channel that its draft was lost and needs to be restarted..env.examplenow documentsGODFORGE_ALLOWED_ORIGINandGODFORGE_SESSION_SECRETas required for production.requirements.txtpinned to current installed versions (discord.py 2.7.1, python-dotenv 1.2.2, aiohttp 3.13.5).Test plan
X-CSRF-Tokenheader return 403https://claude.ai/code/session_01Nfjayt2FK3coWyeWETtYpY
Generated by Claude Code