jhtimmins commented on a change in pull request #14946:
URL: https://github.com/apache/airflow/pull/14946#discussion_r611729062
##########
File path: airflow/www/views.py
##########
@@ -3806,3 +3822,204 @@ def autocomplete(self, session=None):
payload = [row[0] for row in
dag_ids_query.union(owners_query).limit(10).all()]
return wwwutils.json_response(payload)
+
+
+class CustomPermissionModelView(PermissionModelView):
+ """Customize permission names for FAB's builtin PermissionModelView."""
+
+ class_permission_name = permissions.RESOURCE_PERMISSION
+ method_permission_name = {
+ 'list': 'read',
+ }
+ base_permissions = [
+ permissions.ACTION_CAN_READ,
+ ]
+
+
+class CustomPermissionViewModelView(PermissionViewModelView):
+ """Customize permission names for FAB's builtin PermissionViewModelView."""
+
+ class_permission_name = permissions.RESOURCE_PERMISSION_VIEW
+ method_permission_name = {
+ 'list': 'read',
+ }
+ base_permissions = [
+ permissions.ACTION_CAN_READ,
+ ]
+
+
+class CustomResetMyPasswordView(ResetMyPasswordView):
+ """Customize permission names for FAB's builtin ResetMyPasswordView."""
+
+ class_permission_name = permissions.RESOURCE_MY_PASSWORD
+ method_permission_name = {
+ 'this_form_get': 'read',
+ 'this_form_post': 'edit',
+ }
+ base_permissions = [permissions.ACTION_CAN_EDIT,
permissions.ACTION_CAN_READ]
+
+
+class CustomResetPasswordView(ResetPasswordView):
+ """Customize permission names for FAB's builtin ResetPasswordView."""
+
+ class_permission_name = permissions.RESOURCE_PASSWORD
+ method_permission_name = {
+ 'this_form_get': 'read',
+ 'this_form_post': 'edit',
+ }
+
+ base_permissions = [permissions.ACTION_CAN_EDIT,
permissions.ACTION_CAN_READ]
+
+
+class CustomRoleModelView(RoleModelView):
+ """Customize permission names for FAB's builtin RoleModelView."""
+
+ class_permission_name = permissions.RESOURCE_ROLE
+ method_permission_name = {
+ 'delete': 'delete',
+ 'download': 'read',
+ 'show': 'read',
+ 'list': 'read',
+ 'edit': 'edit',
+ 'add': 'create',
+ 'copy_role': 'create',
+ }
+ base_permissions = [
+ permissions.ACTION_CAN_CREATE,
+ permissions.ACTION_CAN_READ,
+ permissions.ACTION_CAN_EDIT,
+ permissions.ACTION_CAN_DELETE,
+ ]
+
+
+class CustomViewMenuModelView(ViewMenuModelView):
+ """Customize permission names for FAB's builtin ViewMenuModelView."""
+
+ class_permission_name = permissions.RESOURCE_VIEW_MENU
+ method_permission_name = {
+ 'list': 'read',
+ }
+ base_permissions = [
+ permissions.ACTION_CAN_READ,
+ ]
+
+
+class CustomUserDBModelView(UserDBModelView):
+ """Customize permission names for FAB's builtin UserDBModelView."""
+
+ _class_permission_name = permissions.RESOURCE_USER
+
+ class_permission_name_mapping = {
+ 'resetmypassword': permissions.RESOURCE_MY_PASSWORD,
+ 'resetpasswords': permissions.RESOURCE_PASSWORD,
Review comment:
`resetmypassword` just lets a user update their own password.
`resetpasswords` lets them update any user's password, and should be limited
to Admin-level users.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]