chiuinggum opened a new issue, #58091:
URL: https://github.com/apache/airflow/issues/58091

   ### Apache Airflow version
   
   main (development)
   
   ### If "Other Airflow 2/3 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   After updating to a build of Airflow that includes PR #57815, the FAB auth 
manager endpoint `/auth/token` started failing with a 500 error and the 
following exception in the API server logs:
   ```
   RuntimeError: Working outside of application context.
   ...
   File ".../airflow/providers/fab/auth_manager/security_manager/override.py", 
line XXX, in auth_type
       return current_app.config["AUTH_TYPE"]
   ```
   The call stack shows this originates from 
`FABAuthManagerLogin.create_token(...)`, which reads 
`auth_manager.security_manager.auth_type`, and that `auth_type` property is 
implemented as `return current_app.config["AUTH_TYPE"]` in 
`FabAirflowSecurityManagerOverride`.
   
   In PR #57815, the FastAPI routes in 
`providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/routes/login.py`
 were changed: the `create_token`, `create_token_cli`, and `logout` endpoints 
no longer wrap their logic in with `get_application_builder(): ...`. Instead, 
they now call `FABAuthManagerLogin.create_token(...)` (or 
`get_auth_manager().get_url_login()`) directly, without setting up a Flask app 
context.
   
   As a result, when these endpoints are hit via the API server, `current_app` 
is not bound and any access to `current_app.config["AUTH_TYPE"]` (and similar 
properties) fails with `RuntimeError: Working outside of application context.`
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   ```bash
   breeze start-airflow
   ```
   
   ```bash
   curl --location 'http://localhost:28080/auth/token' \
   --header 'Content-Type: application/json' \
   --data '{"username":"admin","password":"admin"}'
   ```
   
   ### Operating System
   
   macOS 15.5
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   Deployment: Breeze local dev environment (Docker Compose, airflow api-server 
with uvicorn)
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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]

Reply via email to