Add global privacy compliance controls#32
Conversation
|
Closing because the compliance work needs to be rebased onto feat/golang+sql instead of master. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea128a6132
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| {"username": username, "type": request_type, "status": {"$in": ["received", "in_progress"]}}, | ||
| {"$set": record, "$setOnInsert": {"created_at": now}}, |
There was a problem hiding this comment.
Preserve in-progress privacy requests on retries
When a user resubmits a deletion request after an operator has moved the existing record to in_progress, the filter matches that record but $set applies record, whose status is always received and whose received_at is the current time. This can downgrade an active case back to the received queue and reset the timestamp used for the compliance deadline; preserve the existing status/timestamp when matching an open request or only create a new received record on insert.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Adds privacy compliance controls to the ClashKing API by introducing authenticated endpoints for data export and deletion-request intake, along with a retention-policy disclosure endpoint and supporting persistence for privacy requests.
Changes:
- Add
privacy_requestsMongo collection wiring toDBClient. - Introduce new
routers/v2/privacy.pyrouter with authenticated export and deletion-request endpoints plus a public retention endpoint. - Add
docs/privacy_compliance.mdto document privacy controls and operational expectations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| utils/utils.py | Adds privacy_requests collection handle to the shared DB client. |
| routers/v2/privacy.py | Implements privacy export, deletion-request recording, and retention disclosure endpoints. |
| docs/privacy_compliance.md | Documents the new privacy endpoints and operational/compliance guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await db_client.privacy_requests.update_one( | ||
| {"username": username, "type": request_type, "status": {"$in": ["received", "in_progress"]}}, | ||
| {"$set": record, "$setOnInsert": {"created_at": now}}, | ||
| upsert=True, | ||
| ) |
| @router.delete("/auth/me") | ||
| @router.post("/privacy/delete-request") | ||
| async def request_current_user_deletion(current_user: User = Depends(get_current_user)) -> dict[str, Any]: | ||
| """Register an erasure request for the authenticated API account. |
Summary
Validation