feat: 🐛 implement deletes, purges, apikey for security and update…#590
Merged
Conversation
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.
Walkthrough — Bug #588: PII Retention & Access Control
What Was Done
1. Fixed broken test imports
tests/test_v1_system.py: Fixed allapp.api.v1.routes.system→app.api.routes.systemimports and monkeypatch paths.tests/test_api.py,tests/test_jobs.py: Updated all bare/templates,/forms,/jobspaths to/api/v1/…to match the actual prefix.2. Database — new repository helpers
app/db/repositories.pyget_form_submission(session, id)— lookup by PKdelete_form_submission(session, submission)— remove row and commitdelete_template(session, template)— remove row and commit3. Config — new environment variables
app/core/config.pyFIREFORM_API_KEY""(disabled)RETENTION_PERIOD_DAYS304. Access-control dependency
app/api/deps.py:verify_api_key— whenFIREFORM_API_KEYis set, callers must supply it viaX-API-Keyheader orAuthorization: Bearer <key>. No-ops when the key is unconfigured.5. DELETE endpoints
DELETE /api/v1/templates/{id}— deletes the template DB record, its source PDF, all linkedFormSubmissionrows, their output PDFs, and all linkedJobrows.DELETE /api/v1/forms/{id}— deletes the submission DB row and its output PDF.POST /api/v1/forms/purge?days=N— bulk-purges all submissions older than N days (defaults toRETENTION_PERIOD_DAYS), including their output PDFs.All three endpoints require the API key when one is configured.
6. Celery purge task
app/tasks/purge.py:purge_old_submissionsCelery task — same logic as the HTTP purge endpoint, scheduled via Celery Beat at 03:00 UTC daily.app/core/celery.py: registered the new task and added thebeat_scheduleentry.7. Tests
tests/test_deletion.py— 21 new tests covering:8. README
README.mdcurlexamples.Test Results