This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new ed13326 Sync FAB Permissions for all base views (#12162)
ed13326 is described below
commit ed133267f58cb4251e27d83a87454ca7f8cc3285
Author: Kaxil Naik <[email protected]>
AuthorDate: Sat Nov 7 17:32:53 2020 +0000
Sync FAB Permissions for all base views (#12162)
If a user has set `[webserver] update_fab_perms = False` and runs `airflow
sync-perm` command to sync all permissions, they will receive the following
error:
```
webserver_1 | [2020-11-07 15:13:07,431] {decorators.py:113} WARNING -
Access is Denied for: can_index on: Airflow
```
and if the user was created before and some perms were sync'd a user won't
be able to find Security Menu & Configurations View
---
airflow/cli/commands/sync_perm_command.py | 2 ++
tests/cli/commands/test_sync_perm_command.py | 1 +
2 files changed, 3 insertions(+)
diff --git a/airflow/cli/commands/sync_perm_command.py
b/airflow/cli/commands/sync_perm_command.py
index b072e8d..41a5a60 100644
--- a/airflow/cli/commands/sync_perm_command.py
+++ b/airflow/cli/commands/sync_perm_command.py
@@ -27,6 +27,8 @@ def sync_perm(args):
appbuilder = cached_app().appbuilder # pylint: disable=no-member
print('Updating permission, view-menu for all existing roles')
appbuilder.sm.sync_roles()
+ # Add missing permissions for all the Base Views
+ appbuilder.add_permissions(update_perms=True)
print('Updating permission on all DAG views')
dags = DagBag(read_dags_from_db=True).dags.values()
for dag in dags:
diff --git a/tests/cli/commands/test_sync_perm_command.py
b/tests/cli/commands/test_sync_perm_command.py
index e194447..e06a4fa 100644
--- a/tests/cli/commands/test_sync_perm_command.py
+++ b/tests/cli/commands/test_sync_perm_command.py
@@ -59,6 +59,7 @@ class TestCliSyncPerm(unittest.TestCase):
'no_access_control',
None,
)
+ appbuilder.add_permissions.assert_called_once_with(update_perms=True)
def expect_dagbag_contains(self, dags, dagbag_mock):
dagbag = mock.Mock()