Auth exact-matching, review-race guards, centralized account-name validation #59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/auth-and-input-validation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fifth PR of the refactor series (stacked on #58 → #57 → #56 → #55; merge in order).
Problems (CODE-REVIEW-2026-06 #5, #6, #16, #17 + libra-#36, libra-#51, libra-#52):
can_access_user_datacompareduser_id[:8]prefixes — a 32-bit space; any prefix collision (or a crafted short target id) let one user read another's balances/entries.can_access_accountused a substring test (f"User-{short}" in account.name) that also matched accounts merely containing the segment.crud.create_accountleaked raw sqlalchemyIntegrityErroron duplicates (libra-#36), andget_or_create_user_accountstring-matched the SQLite error message (never matched on Postgres).Changes:
can_access_user_data; exact:-segment match incan_access_account.approve/reject_manual_payment_requestare status-guarded (WHERE status='pending'+ rowcount); the approve endpoint claims first, writes the ledger entry second, and reverts the claim if the write fails — at most one journal entry per request, losers get 409.validate_account_namecentralized inaccount_utils.py(libra-#51), called fromcrud.create_account(choke point for every creation path; virtual parents may be a bare root), the admin endpoint, andfava_client.add_accountat the writer boundary (libra-#52).AccountExistsErrordomain error;POST /accountsreturns 409 on duplicate / 400 on malformed names; the user-account recovery path catches the domain error (Postgres-compatible).Tests: new
tests/test_auth_validation.py— prefix-colliding users isolated; substring account bait denied while the genuinely-owned account passes; concurrent double-approve creates exactly one ledger entry; duplicate create → 409; malformed name → 400. Full suite: 182 passed, 3 skipped.🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.