sjyangkevin commented on code in PR #77138:
URL: https://github.com/apache/airflow/pull/77138#discussion_r4623986822
##########
providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py:
##########
@@ -310,23 +312,39 @@ def get_user(self) -> User:
def session(self):
return self.appbuilder.session
- @cachedmethod(lambda self: self.cache, key=lambda _, token:
int(token["sub"]))
def deserialize_user(self, token: dict[str, Any]) -> User:
user_id = int(token["sub"])
+ # Tokens issued before the claim existed count as the initial
generation.
+ token_generation = token.get(TOKEN_GENERATION_CLAIM, 0)
+ if type(token_generation) is not int:
+ raise ValueError(f"Token of user with id {user_id} has an invalid
{TOKEN_GENERATION_CLAIM} claim")
+ user = self._get_active_user(user_id)
+ if token_generation > user.token_generation:
+ # The token was issued after a password change that the cached
user predates.
+ user = self._fetch_active_user(user_id)
+ self.cache[user_id] = user
Review Comment:
Fixed and the test cases are updated.
--
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]