2727from airflow .configuration import conf
2828from airflow .providers .fab .auth_manager .api_fastapi .datamodels .login import LoginBody , LoginResponse
2929from airflow .providers .fab .auth_manager .api_fastapi .services .login import FABAuthManagerLogin
30- from airflow .providers .fab .auth_manager .cli_commands .utils import get_application_builder
3130
3231login_router = AirflowRouter (tags = ["FabAuthManager" ])
3332
4039)
4140def create_token (body : LoginBody ) -> LoginResponse :
4241 """Generate a new API token."""
43- with get_application_builder ():
44- return FABAuthManagerLogin .create_token (body = body )
42+ return FABAuthManagerLogin .create_token (body = body )
4543
4644
4745@login_router .post (
@@ -52,10 +50,9 @@ def create_token(body: LoginBody) -> LoginResponse:
5250)
5351def create_token_cli (body : LoginBody ) -> LoginResponse :
5452 """Generate a new CLI API token."""
55- with get_application_builder ():
56- return FABAuthManagerLogin .create_token (
57- body = body , expiration_time_in_seconds = conf .getint ("api_auth" , "jwt_cli_expiration_time" )
58- )
53+ return FABAuthManagerLogin .create_token (
54+ body = body , expiration_time_in_seconds = conf .getint ("api_auth" , "jwt_cli_expiration_time" )
55+ )
5956
6057
6158@login_router .get (
@@ -64,18 +61,17 @@ def create_token_cli(body: LoginBody) -> LoginResponse:
6461)
6562def logout (request : Request ) -> RedirectResponse :
6663 """Generate a new API token."""
67- with get_application_builder ():
68- login_url = get_auth_manager ().get_url_login ()
69- secure = request .base_url .scheme == "https" or bool (conf .get ("api" , "ssl_cert" , fallback = "" ))
70- response = RedirectResponse (login_url )
71- response .delete_cookie (
72- key = "session" ,
73- secure = secure ,
74- httponly = True ,
75- )
76- response .delete_cookie (
77- key = COOKIE_NAME_JWT_TOKEN ,
78- secure = secure ,
79- httponly = True ,
80- )
81- return response
64+ login_url = get_auth_manager ().get_url_login ()
65+ secure = request .base_url .scheme == "https" or bool (conf .get ("api" , "ssl_cert" , fallback = "" ))
66+ response = RedirectResponse (login_url )
67+ response .delete_cookie (
68+ key = "session" ,
69+ secure = secure ,
70+ httponly = True ,
71+ )
72+ response .delete_cookie (
73+ key = COOKIE_NAME_JWT_TOKEN ,
74+ secure = secure ,
75+ httponly = True ,
76+ )
77+ return response
0 commit comments