[PR #349] [MERGED] Harden subscription endpoint authorization and add production-readiness review #316

Closed
opened 2026-03-02 23:35:06 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AJaySi/ALwrity/pull/349
Author: @AJaySi
Created: 2/11/2026
Status: Merged
Merged: 2/11/2026
Merged by: @AJaySi

Base: mainHead: codex/review-subscription-codebase-for-readiness


📝 Commits (1)

  • b14ee71 Harden subscription endpoint auth and add production readiness review

📊 Changes

4 files changed (+106 additions, -2 deletions)

View changed files

📝 backend/api/subscription/routes/alerts.py (+10 -2)
📝 backend/api/subscription/routes/dashboard.py (+4 -0)
📝 backend/api/subscription/routes/usage.py (+2 -0)
backend/docs/subscription-production-readiness-review.md (+90 -0)

📄 Description

Motivation

  • Close an IDOR/user-isolation gap in subscription and usage endpoints that allowed user-scoped data to be read or mutated without verifying the authenticated user.
  • Provide a short production-readiness audit of the subscription system to capture remaining risks and rollout recommendations.

Description

  • Added authentication dependency current_user: Dict[str, Any] = Depends(get_current_user) and enforced verify_user_access(user_id, current_user) on user-scoped endpoints GET /usage/{user_id}/trends, GET /dashboard/{user_id}, and GET /alerts/{user_id} to prevent cross-user access.
  • Enforced ownership checks for alert mutation by calling verify_user_access(str(alert.user_id), current_user) in POST /alerts/{alert_id}/mark-read before mutating the alert.
  • Added a new production-readiness audit backend/docs/subscription-production-readiness-review.md documenting findings, high-priority follow-ups (caching, billing-period accuracy, decimal money types), and rollout recommendations.
  • Minor validation step performed by compiling updated route modules and committing the changes.

Testing

  • Ran a syntax/bytecode validation with python -m compileall backend/api/subscription/routes/alerts.py backend/api/subscription/routes/usage.py backend/api/subscription/routes/dashboard.py, which completed successfully.
  • No other automated unit/integration tests were added or run as part of this change.

Codex Task


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AJaySi/ALwrity/pull/349 **Author:** [@AJaySi](https://github.com/AJaySi) **Created:** 2/11/2026 **Status:** ✅ Merged **Merged:** 2/11/2026 **Merged by:** [@AJaySi](https://github.com/AJaySi) **Base:** `main` ← **Head:** `codex/review-subscription-codebase-for-readiness` --- ### 📝 Commits (1) - [`b14ee71`](https://github.com/AJaySi/ALwrity/commit/b14ee7197dcc00138e9b72cecb57ee92ffd82182) Harden subscription endpoint auth and add production readiness review ### 📊 Changes **4 files changed** (+106 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `backend/api/subscription/routes/alerts.py` (+10 -2) 📝 `backend/api/subscription/routes/dashboard.py` (+4 -0) 📝 `backend/api/subscription/routes/usage.py` (+2 -0) ➕ `backend/docs/subscription-production-readiness-review.md` (+90 -0) </details> ### 📄 Description ### Motivation - Close an IDOR/user-isolation gap in subscription and usage endpoints that allowed user-scoped data to be read or mutated without verifying the authenticated user. - Provide a short production-readiness audit of the subscription system to capture remaining risks and rollout recommendations. ### Description - Added authentication dependency `current_user: Dict[str, Any] = Depends(get_current_user)` and enforced `verify_user_access(user_id, current_user)` on user-scoped endpoints `GET /usage/{user_id}/trends`, `GET /dashboard/{user_id}`, and `GET /alerts/{user_id}` to prevent cross-user access. - Enforced ownership checks for alert mutation by calling `verify_user_access(str(alert.user_id), current_user)` in `POST /alerts/{alert_id}/mark-read` before mutating the alert. - Added a new production-readiness audit `backend/docs/subscription-production-readiness-review.md` documenting findings, high-priority follow-ups (caching, billing-period accuracy, decimal money types), and rollout recommendations. - Minor validation step performed by compiling updated route modules and committing the changes. ### Testing - Ran a syntax/bytecode validation with `python -m compileall backend/api/subscription/routes/alerts.py backend/api/subscription/routes/usage.py backend/api/subscription/routes/dashboard.py`, which completed successfully. - No other automated unit/integration tests were added or run as part of this change. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_698c5bbd42248328b952679b1ff08e61) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 23:35:06 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ALwrity#316
No description provided.