vincbeck commented on code in PR #59245:
URL: https://github.com/apache/airflow/pull/59245#discussion_r2714352597
##########
providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py:
##########
@@ -299,6 +300,32 @@ def is_logged_in(self) -> bool:
or (not user.is_anonymous and user.is_active)
)
+ def create_token(self, headers: dict[str, str], body: dict[str, Any]) ->
User:
+ """
+ Create a new token from a payload.
+
+ By default, it uses basic authentication (username and password).
+ Override this method to use a different authentication method (e.g.
oauth).
+
+ :param headers: request headers
+ :param body: request body
+ """
+ if not body.get("username") or not body.get("password"):
+ raise ValueError("Username and password must be provided")
+
+ user: User | None = None
+
+ if self.security_manager.auth_type == AUTH_LDAP:
+ user = self.security_manager.auth_user_ldap(
+ body["username"], body["password"], rotate_session_id=False
+ )
+ if user is None:
+ user = self.security_manager.auth_user_db(
+ body["username"], body["password"], rotate_session_id=False
+ )
+
+ return user
Review Comment:
You are correct :)
--
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]