Skip to content

feat(backend): add HMAC-SHA256 keyset pagination codec and hierarchical RBAC policy evaluator - #30

Merged
ATLURI0001 merged 1 commit into
mainfrom
feat/hmac-keyset-pagination-and-rbac-policy
Nov 18, 2026
Merged

ATLURI0001 merged 1 commit into
mainfrom
feat/hmac-keyset-pagination-and-rbac-policy

Conversation

@ATLURI0001

Copy link
Copy Markdown
Owner

Architectural Overview

Paginating large course catalogs, enrollment ledgers, and submission queues via SQL OFFSET degrades linearly ($O(N)$) and suffers duplicate/skipped row drift under concurrent writes. Simultaneously, multi-role academic workflows (students, TAs, instructors, admins, suspended accounts) require composable authorization policies with strict deny precedence.

This PR adds a signed keyset pagination engine (KeysetCursorCodec) and a hierarchical RBAC evaluator (RBACPolicyEvaluator) in python-fullstack/backend/pagination.py.

Component Diagnostics & Enhancements

  • HMAC-SHA256 Signed Keyset Pagination (KeysetCursorCodec):
    • Serializes deterministic (sort_field, sort_value, record_id, direction, expires_at) cursors as unpadded base64url(payload).base64url(hmac_sha256).
    • Verifies integrity using constant-time hmac.compare_digest prior to JSON parsing, enforces cursor TTL (CursorExpiredError), and restricts sort_field against explicit allowlists to prevent ORDER BY injection.
    • Provides paginate_records for stable (sort_field, id) tie-broken traversal without offset drift.
  • Hierarchical RBAC Policy Evaluator (RBACPolicyEvaluator):
    • Resolves transitive role inheritance graphs (e.g., admin -> instructor -> ta -> student) with cycle-safe traversal.
    • Supports resource:action wildcard matching (courses:*, *), resource ownership checks (allow_owner=True), and unconditional explicit-deny precedence over allows/ownership.

Verification & Test Results

  • Added python-fullstack/backend/tests/test_pagination.py covering tamper detection, SQL field injection rejection, TTL expiration, tie-broken keyset traversal, role inheritance, ownership overrides, and explicit deny dominance.
  • Executed uv run pytest -o pythonpath="." tests/: 23/23 tests passed in 1.11s.

@vercel

vercel Bot commented Nov 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lmskl Error Error Nov 18, 2026 5:41am UTC

@ATLURI0001
ATLURI0001 merged commit 21b9580 into main Nov 18, 2026
6 of 8 checks passed
@ATLURI0001
ATLURI0001 deleted the feat/hmac-keyset-pagination-and-rbac-policy branch November 18, 2026 05:42

This branch had an error being deployed

1 failed deployment
Preview — 6b1446a8 Deployed Nov 18, 2026 by vercel[bot]
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.

1 participant