sjyangkevin opened a new pull request, #77559:
URL: https://github.com/apache/airflow/pull/77559

   <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull 
request.
   Write a good git commit message following this guide: 
https://chris.beams.io/posts/git-commit/
   
   Please make sure that your code changes are covered with tests.
   And in case of new features or big changes remember to adjust the 
documentation.
   
   For user-facing UI changes, please attach before/after screenshots (or a 
short
   screen recording) so reviewers can assess the visual impact.
   
   Feel free to ping (in general) for the review if you do not see reaction for 
a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we 
sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   ### What
   
   Drop a user from the FAB auth manager's user cache when they are deactivated 
or deleted, so their outstanding tokens stop working on the next request 
instead of after `[fab] cache_ttl`.
   
   #77138 drops the cached user when a password is changed or reset, through 
`update_user`. Three other ways of changing a user do not go through 
`update_user`:
   
   - Editing a user in the UI, for example unticking "Active": FAB saves 
through `datamodel.edit`.
   - Deleting a user in the UI: FAB deletes through `datamodel.delete`.
   - Deleting a user through `DELETE /auth/fab/v1/users/{username}`: the 
service deletes the row directly.
   
   ### How
   
   - The user views' shared mixin now overrides FAB's `post_update` and 
`post_delete` hooks to drop the user from the cache. FAB calls them only after 
the change is committed.
   - `delete_user` in the users API service drops the user right after its 
commit.
   - Both hold `FabAuthManager.cache_lock`, as `update_user` does.
   - The changelog note is updated to also covers deactivation and deletion.
   
   ### Testing
   
   - Added a test that a token accepted before a user is deactivated or deleted 
in the UI is rejected right after the change.
   - Added a test that deleting a user through the users API service drops them 
from the cache.
   
   I ran the FAB provider unit tests and mypy on the changed files, and tested 
it end to end in Breeze against a running API server: after a UI deactivation, 
a UI delete or an API delete, the user's earlier token is rejected, and after 
`airflow users delete` it is rejected once `[fab] cache_ttl` has passed.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: [Claude Code (Opus 5.5)] following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   - I use it to better understand where are the two paths of updates, and 
generate end-to-end test cases.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to