jason810496 commented on code in PR #48498:
URL: https://github.com/apache/airflow/pull/48498#discussion_r2019716349
##########
airflow-core/src/airflow/api_fastapi/auth/managers/simple/routes/login.py:
##########
@@ -41,33 +39,31 @@ def create_token(
body: LoginBody,
) -> LoginResponse:
"""Authenticate the user."""
- return SimpleAuthManagerLogin.create_token(body=body)
+ return
LoginResponse(access_token=SimpleAuthManagerLogin.create_token(body=body))
@login_router.get(
"/token",
- status_code=status.HTTP_307_TEMPORARY_REDIRECT,
+ status_code=status.HTTP_201_CREATED,
responses=create_openapi_http_exception_doc([status.HTTP_403_FORBIDDEN]),
)
-def create_token_all_admins() -> RedirectResponse:
+def create_token_all_admins() -> LoginResponse:
"""Create a token with no credentials only if
``simple_auth_manager_all_admins`` is True."""
- is_simple_auth_manager_all_admins = conf.getboolean("core",
"simple_auth_manager_all_admins")
- if not is_simple_auth_manager_all_admins:
- raise HTTPException(
- status.HTTP_403_FORBIDDEN,
- "This method is only allowed if ``[core]
simple_auth_manager_all_admins`` is True",
- )
- user = SimpleAuthManagerUser(
- username="Anonymous",
- role="ADMIN",
- )
+ return
LoginResponse(access_token=SimpleAuthManagerLogin.create_token_all_admins())
- response = RedirectResponse(url=conf.get("api", "base_url"))
+@login_router.get(
+ "/token/login",
+ status_code=status.HTTP_307_TEMPORARY_REDIRECT,
+ responses=create_openapi_http_exception_doc([status.HTTP_403_FORBIDDEN]),
+)
+def login_all_admins() -> RedirectResponse:
+ """Login the user with no credentials."""
+ response = RedirectResponse(url=conf.get("api", "base_url"))
secure = conf.has_option("api", "ssl_cert")
response.set_cookie(
COOKIE_NAME_JWT_TOKEN,
- get_auth_manager().generate_jwt(user),
+ SimpleAuthManagerLogin.create_token_all_admins(),
Review Comment:
The `create_token_all_admins` here indeed return a `str` instead of
`LoginResponse` I think.
--
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]