-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anonymous users aren't able to view DAGs even with Admin Role #13340
Comments
I believe this is intended behaviour, not sure if that was the intention, but I would see it highly problematic (and dangerous) to give the anonymous user the Admin (or any in that respect) right. I believe the whole purpose of RBAC interface is to enforce authentication for airflow users. @jhtimmins @ryanahamilton WDYT? |
This looks like something we can fix. I am able to imagine several environments where authentication is not needed because the access control is done on a different layer. This configuration is supported by Flask App Builder, so it makes sense for Airflow to support it too. |
@AmarEL Are you willing to submit a PR? |
Yep! |
Yeah. It is supported - but is it intended ? This is my question. I am not sure if this is something that we want to, that's why I would love to hear other's opinion on that if it was a deliberate choice or an acident (I honestly do not know). |
@potiuk I can imagine that some DAGs will be read-only to the public. Giving full administrator privileges is an edge case, but giving read-only one or two DAGs is something that makes sense to support. I looked at the code quickly and I don't find it difficult to add support for this use case. I think if we improve this one SQL query and use get_user_roles instead of our own SQL query it should work. If the user can configure their own role it looks as if this was provided functionality by Flask App Builder. Some actions then require an additional user.is_anonymous case to be considered, but it has low impact |
Yeah. The 'read' use case is s convincing for sure. I thought about it myself. Just want to make sure that there was no reason behind not letting it in the first place and that there is no reason (like potential security problem which we might not be aware of) for disallowing it. |
Maybe I exaggerated in my example with an Admin role rsrsrs @mik-laj I already did some tests using the get_user_roles instead method and it works to show the dags on the home page, but for accessing dag another error occurred. I will continue working on it. |
@AmarEL I assigned you to this ticket. |
So maybe part of the PR will be to only allow READ access for unauthenticated users and fail configuration if any WRITE access is configured? I think this might be both - much more secure and serve the use case that you are talking about ? |
I doubt if we want to have this behaviour change: if the Admin wants to allow Public Role to view specific DAGs (or all DAGs), it's very easy to configure it in the UI as Admin role. There is no need to make any explicit change in my opinion. |
The actual behavior without changes is problematic too because if someone sets the Or another example could be if I create a new role "Anonymous" and attach just the View Dags Permission to this role, the user will still not able to view the dags without changing the code. So, I think that some change is necessary. And I appreciated the @potiuk suggestion and I still looking for it in another branch, but for
more changes are necessary for methods related to Menu Views and other stuff. I'm not sure if is better to fix the behavior that I wrote in this issue and document all these details very well to let the developer configure this correctly if he wants to give READ permission for an anonymous user or deny any READ permission for an anonymous user (it needs to be very well documented too). |
Fixes the issue wherein regardless of what role anonymous users are assigned (via the `AUTH_ROLE_PUBLIC` env var), they can't see any DAGs. Current behavior causes: Anonymous users are handled as a special case by Airflow's DAG-related security methods (`.has_access()` and `.get_accessible_dags()`). Rather than checking the `AUTH_ROLE_PUBLIC` value to check for role permissions, the methods reject access to view or edit any DAGs. Changes in this PR: Rather than hardcoding permission rules inside the security methods, this change checks the `AUTH_ROLE_PUBLIC` value and gives anonymous users all permissions linked to the designated role. **This places security in the hands of the Airflow users. If the value is set to `Admin`, anonymous users will have full admin functionality.** This also changes how the `Public` role is created. Currently, the `Public` role is created automatically by Flask App Builder. This PR explicitly declares `Public` as a default role with no permissions in `security.py`. This change makes it easier to test. closes: #13340
Fixes the issue wherein regardless of what role anonymous users are assigned (via the `AUTH_ROLE_PUBLIC` env var), they can't see any DAGs. Current behavior causes: Anonymous users are handled as a special case by Airflow's DAG-related security methods (`.has_access()` and `.get_accessible_dags()`). Rather than checking the `AUTH_ROLE_PUBLIC` value to check for role permissions, the methods reject access to view or edit any DAGs. Changes in this PR: Rather than hardcoding permission rules inside the security methods, this change checks the `AUTH_ROLE_PUBLIC` value and gives anonymous users all permissions linked to the designated role. **This places security in the hands of the Airflow users. If the value is set to `Admin`, anonymous users will have full admin functionality.** This also changes how the `Public` role is created. Currently, the `Public` role is created automatically by Flask App Builder. This PR explicitly declares `Public` as a default role with no permissions in `security.py`. This change makes it easier to test. closes: #13340 (cherry picked from commit 78aa921)
Fixes the issue wherein regardless of what role anonymous users are assigned (via the `AUTH_ROLE_PUBLIC` env var), they can't see any DAGs. Current behavior causes: Anonymous users are handled as a special case by Airflow's DAG-related security methods (`.has_access()` and `.get_accessible_dags()`). Rather than checking the `AUTH_ROLE_PUBLIC` value to check for role permissions, the methods reject access to view or edit any DAGs. Changes in this PR: Rather than hardcoding permission rules inside the security methods, this change checks the `AUTH_ROLE_PUBLIC` value and gives anonymous users all permissions linked to the designated role. **This places security in the hands of the Airflow users. If the value is set to `Admin`, anonymous users will have full admin functionality.** This also changes how the `Public` role is created. Currently, the `Public` role is created automatically by Flask App Builder. This PR explicitly declares `Public` as a default role with no permissions in `security.py`. This change makes it easier to test. closes: #13340 (cherry picked from commit 78aa921)
Apache Airflow version: 2.0.0 (Current master)
Kubernetes version (if you are using kubernetes) (use
kubectl version
):Environment:
uname -a
): Linux ubuntu 5.4.0-58-generic Hive Metastore Browser plugin #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64 x86_64 x86_64 GNU/Linuxwebserver_config.py file config:
What happened:
After disabling the authentication, all users are identified as "Anonymous User" and no dags are load on the screen because there is a method that returns an empty set for roles when a user is anonymous.
views.py file:
security.py file:
What you expected to happen:
Since the option to disable login exists, I expect that all anonymous users have the Role specified in the webserver_config.py file in the AUTH_ROLE_PUBLIC entry.
It will make anonymous users able to see/edit dags if the roles specified as the default for anonymous users match the DAG roles.
How to reproduce it:
Set the following entry in webserver_config.py file config to disable authentication and make all users anonymous with the 'Admin" role:
With the current master branch installed, run
airflow webserver
No DAGs will appear:
Anything else we need to know:
The methods have explicit comments about being used for authenticated user:
But there is no way for anonymous users to be able to see DAGs on the screen without modifying the behavior of this method.
The text was updated successfully, but these errors were encountered: