Open
Conversation
dave2wave
requested changes
Feb 12, 2026
Member
dave2wave
left a comment
There was a problem hiding this comment.
A trivial change. A cursory review shows what looks like a comprehensive PR!
28e65be to
cec8185
Compare
Contributor
Author
|
Worth noting @sbp @dave2wave I did not test with actual changes in LDAP or a ban, just revoking manually with the admin menu item. |
cec8185 to
6232741
Compare
6232741 to
d0878c5
Compare
133ab83 to
929a8c3
Compare
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.
Invalidate PATs when user account is disabled
Fixes #598
Problem
When an LDAP account is banned or deleted, the user's Personal Access Tokens remain in the database. While the existing LDAP check in
issue_jwt()prevents banned users from exchanging PATs for JWTs, the stale tokens persist for up to 180 days, violating ASVS 7.4.2.Solution
Three layers of defense, two of which are new:
issue_jwt()rejects banned users immediatelyChanges
New files
atr/token_cleanup.py— background cleanup loop withcleanup_loop()andrevoke_pats_for_banned_users()atr/admin/templates/revoke-user-tokens.html— admin page templatetests/unit/test_token_cleanup.py— 7 unit tests covering active accounts, banned accounts, deleted accounts, LDAP failures, race conditions, and multi-user cleanuptests/e2e/admin/— e2e tests for the admin revoke tokens page (page rendering, form validation, revocation flow, nav link)Modified files
atr/storage/writers/tokens.py— addsFoundationAdminclass withrevoke_all_user_tokens()atr/storage/__init__.py— wirestokensintoWriteAsFoundationAdminatr/server.py— starts/stops the cleanup loop taskatr/admin/__init__.py— addsRevokeUserTokensForm, GET/POST route handlersatr/templates/includes/topnav.html— adds "Revoke user tokens" nav link under Adminatr/docs/authentication-security.md— documents the three-layer defense and automated cleanupatr/docs/authorization-security.md— documents admin bulk revocation and automated cleanup access controlDesign decisions
cache.py—cache.pyis solely about LDAP admin caching; token cleanup is active security enforcement. A separate module also avoids circular imports (cache→storage→user→cache).revoke_pats_for_banned_users()is public — directly callable from tests and potentially a future "run now" button.storage.audit()) and manual (viaappend_to_audit_log()).Required acknowledgements
mainbranchRebase confirmation details (optional but encouraged)
Additional notes