ashb commented on code in PR #46981:
URL: https://github.com/apache/airflow/pull/46981#discussion_r1989929703
##########
airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -84,25 +84,29 @@ def deserialize_user(self, token: dict[str, Any]) -> T:
"""Create a user object from dict."""
@abstractmethod
- def serialize_user(self, user: T) -> dict[str, Any]:
- """Create a dict from a user object."""
+ def serialize_user(self, user: T) -> tuple[str, dict[str, Any]]:
+ """Create a subject and extra claims dict from a user object."""
def get_user_from_token(self, token: str) -> BaseUser:
"""Verify the JWT token is valid and create a user object from it if
valid."""
try:
- payload: dict[str, Any] =
self._get_token_signer().verify_token(token)
+ payload: dict[str, Any] =
self._get_token_validator().validated_claims(token)
return self.deserialize_user(payload)
except InvalidTokenError as e:
log.error("JWT token is not valid")
raise e
- def get_jwt_token(
+ def generate_jwt(
self, user: T, *, expiration_time_in_seconds: int = conf.getint("api",
"auth_jwt_expiration_time")
) -> str:
"""Return the JWT token from a user object."""
- return self._get_token_signer(
- expiration_time_in_seconds=expiration_time_in_seconds
- ).generate_signed_token(self.serialize_user(user))
+ return
self._get_token_signer(expiration_time_in_seconds=expiration_time_in_seconds).generate(
+ *self.serialize_user(user)
+ )
+
+ @abstractmethod
+ def is_logged_in(self) -> bool:
+ """Return whether the user is logged in."""
Review Comment:
🤦🏻 thanks!
--
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]