feat: add missing CRUD hooks and auth event hooks#2450
Open
feat: add missing CRUD hooks and auth event hooks#2450
Conversation
6b6d813 to
fbdf1a1
Compare
Add post_add/post_update calls to UserApi and GroupApi post()/put() methods which were skipping these hooks unlike the base ModelRestApi. Add on_user_login, on_user_login_failed, and on_user_logout overridable hooks to BaseSecurityManager for audit logging and custom auth event handling. Called from update_user_auth_stat and logout views respectively. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fbdf1a1 to
a5da4e7
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.
Summary
post_add/post_updatehook calls inUserApi.post()/put()andGroupApi.post()/put()— these custom overrides were skipping the hooks thatModelRestApinormally callson_user_login,on_user_login_failed, andon_user_logoutoverridable methods onBaseSecurityManagerfor audit logging and custom auth event handlingon_user_login/on_user_login_failedfromupdate_user_auth_stat()andon_user_logoutfrom all logout views (including SAML SLO)get_user_by_id(g.user.id)to resolve the user beforelogout_user()sinceg.useris aLocalProxythat would resolve to anonymous after logoutTest plan
tests/test_hooks.py— all passingUserApi:post_addcalled on POST,post_updatecalled on PUTGroupApi:post_addcalled on POST,post_updatecalled on PUTon_user_logincalled on successful loginon_user_login_failedcalled on bad passwordon_user_logoutcalled on browser logoutUsermodel instance🤖 Generated with Claude Code