-
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
Make the role assigned to anonymous users customizable #14042
Make the role assigned to anonymous users customizable #14042
Conversation
Looks perfect, I did some similar tests here and this should work |
tests/www/test_security.py
Outdated
user = mock.MagicMock() | ||
user.is_anonymous = True | ||
self.app.config['AUTH_ROLE_PUBLIC'] = 'Public' | ||
assert self.app.appbuilder.sm.get_user_roles(user) == [self.app.appbuilder.sm.find_role("Public")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert self.app.appbuilder.sm.get_user_roles(user) == [self.app.appbuilder.sm.find_role("Public")] | |
assert self.app.appbuilder.sm.get_user_roles(user) == [self.app.appbuilder.sm.get_public_role()] |
The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest master or amend the last commit of the PR, and push it with --force-with-lease. |
236ea97
to
80112c3
Compare
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)
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 theAUTH_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, thePublic
role is created automatically by Flask App Builder. This PR explicitly declaresPublic
as a default role with no permissions insecurity.py
. This change makes it easier to test.closes: #13340