Airflow API Returns 403 Forbidden When Using Azure AD Authentication via Custom API Backend #47029
-
Apache Airflow version2.10.5 If "Other Airflow 2 version" selected, which one?2.10.4 What happened?I deployed Airflow on Azure K8s (AKS) via the Airflow Official Helm Chart. For UI authentication I use Azure AD via OAuth2 for that I have Azure App Registration for handling AIrflow access via Role-based access control (RBAC). Everything works as expected. So, I use a custom Airflow API backend to access Airflow and manage Roles via endpoint:
here is my custom API backend: And I get error:
There is the custom Airflow API Backend:
I use There are a couple of logs from API backend:
I get the same error:
using Postman and just pure python through GET request and {"Authorization": f"Bearer {access_token}"} in header What you think should happen instead?I expect that if I use the Airflow API backend I should have access to API if the backend code was passed.`` How to reproducedeploy Airflow on AKS and use custom API backend to use Azure AD token. Operating SystemPRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" Versions of Apache Airflow Providersairflow@airflow-webserver-7fdffbcd6b-cznnc:/opt/airflow$ pip freeze | grep apache-airflow-provider DeploymentOfficial Apache Airflow Helm Chart Deployment detailsAKS, Official Airflow Helm Chart. Anything else?No response Are you willing to submit PR?
Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 2 replies
-
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval. |
Beta Was this translation helpful? Give feedback.
-
that's an interesting discussion and maybe someone will be able to help, but I think expecting that somene will help with debugging your custom authentication is homestly I think a bit too much for people who are trying to help otehrs in their free time. Maybe somoene will help you to debug it, but unless you will distill it to something that will show that this is an airlfow and not your custom backend issue, you are mostly left to debugging your own code. |
Beta Was this translation helpful? Give feedback.
-
Converted it to a discussion. |
Beta Was this translation helpful? Give feedback.
-
@potiuk thanks for your comment. I just cannot understand how I can see error if custom api backed finished successfully. I mean, I expect if I follow needed syntax to use custom api backed and instead of any validation just put ‘pass’ it should works …so, |
Beta Was this translation helpful? Give feedback.
-
Hi @seniut airflow.cfg
my error logs
|
Beta Was this translation helpful? Give feedback.
-
Can reproduce the same issue, doesn't matter what I do, it's always 403, i created a new endpoint and made authorization via my custom requires_authentication and everything worked, however if I try to use it as a plugin - it doesn't work and return 403 |
Beta Was this translation helpful? Give feedback.
-
So, here’s a summary of the steps I took to make the setup work successfully. It can be valuable for someone else. But feel free to share with me better solution. Env variables:
Here is my function to get Azure AD token:
Here is the full code of API Auth backend:
Here are the needed updates in Azure App registrations : Permissions have to be requested for your API. Admin is a group added in App roles : Permissions have to be granted by the Admin (Admin consent required).
Once all of these were done, Airflow will recognize the AppR clientID as an Admin user, allowing it to authenticate and access Airflow APIs as expected. |
Beta Was this translation helpful? Give feedback.
So, here’s a summary of the steps I took to make the setup work successfully. It can be valuable for someone else. But feel free to share with me better solution.
Env variables: