Skip to content

Restrict carts and orders to their signed-in owners - #202

Open
nirmalhk7 wants to merge 3 commits into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/agrinet-cart-order-ownership
Open

nirmalhk7 wants to merge 3 commits into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/agrinet-cart-order-ownership

Conversation

@nirmalhk7

@nirmalhk7 nirmalhk7 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Cart and order routes require the signed-in account ID to match the path owner before reads, cart changes, or checkout. API keys and tokens without a member ID are denied, and an administrator role does not bypass ownership. Existing owner operations keep their response shapes and behavior.

The follow-up addresses the CodeQL finding in the ownership test app by mounting the existing API rate limiter before JWT verification. A new HTTP regression exhausts its request budget, checks HTTP 429, and confirms that a subsequent cart write leaves the owner's data unchanged. Production handlers, dependencies, rate-limit settings, pricing, settlement, escrow, and stock-reservation policies are unchanged. Cart and order stores remain in memory.

Verification on the updated branch:

  • The new regression failed before the harness repair with HTTP 200 instead of 429. All 43 focused HTTP cases now pass, including the original 42 ownership cases.
  • cd backend && npm test passes 103 Node tests and 65 Jest tests across 25 Jest suites.
  • JavaScript syntax, ./scripts/list-hardcoded-urls.sh, and patch whitespace checks pass.
  • Full-repository Qlty comparisons in isolated copies add no findings: the same 15 smells and 13 check findings remain before and after. Repository-wide checks still report those existing findings; this is not a clean-repository claim.

The contribution follows the fork/PR and per-commit DCO requirements in NTARI's Bug-Build-Test guide. No JFA conformance binding changes or deployment verification are claimed. Hosted CodeQL must confirm the alert is cleared on the published head, and independent human review remains required. The author must not merge this PR.

Require the signed-in account ID to match the cart or order owner before
reads, cart mutations, and checkout. Reject API-key requests without a
member identity and prevent cross-account access, including admin tokens.

Cover all six mounted routes with real stores and authenticated HTTP
requests. Verify denied calls preserve owner data and legitimate owner
operations retain their existing behavior.

Validation: 103 Node tests and 46 Jest tests pass. Full-repository Qlty
scans add no findings relative to the baseline.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Preserve ownership checks across all six cart and order operations alongside current account security hardening. Verified 42 ownership cases, 102 Node tests and 65 Jest tests. Test-only removal of the owner guard produces 24 expected failures; all 42 cases pass with the guard restored.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
@nirmalhk7
nirmalhk7 marked this pull request as ready for review November 11, 2026 23:45

const app = express();
app.use(express.json());
app.use(auth);
Mount the existing API limiter before JWT authentication in the HTTP test app. Verify exhausted requests return 429 without mutating the owner cart, while retaining all ownership regressions.

Validation: 43 focused HTTP cases, 103 Node tests, and 65 Jest tests pass. Syntax, hardcoded-URL, and whitespace checks pass; full Qlty comparison adds no findings.
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants