Repository navigation
feat(backend): add HMAC-SHA256 keyset pagination codec and hierarchical RBAC policy evaluator - #30
Merged
Conversation
…al RBAC policy evaluator
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Architectural Overview
Paginating large course catalogs, enrollment ledgers, and submission queues via SQL
OFFSETdegrades 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) inpython-fullstack/backend/pagination.py.Component Diagnostics & Enhancements
KeysetCursorCodec):(sort_field, sort_value, record_id, direction, expires_at)cursors as unpaddedbase64url(payload).base64url(hmac_sha256).hmac.compare_digestprior to JSON parsing, enforces cursor TTL (CursorExpiredError), and restrictssort_fieldagainst explicit allowlists to prevent ORDER BY injection.paginate_recordsfor stable(sort_field, id)tie-broken traversal without offset drift.RBACPolicyEvaluator):admin -> instructor -> ta -> student) with cycle-safe traversal.courses:*,*), resource ownership checks (allow_owner=True), and unconditional explicit-deny precedence over allows/ownership.Verification & Test Results
python-fullstack/backend/tests/test_pagination.pycovering tamper detection, SQL field injection rejection, TTL expiration, tie-broken keyset traversal, role inheritance, ownership overrides, and explicit deny dominance.uv run pytest -o pythonpath="." tests/: 23/23 tests passed in 1.11s.