mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 00:20:43 -04:00
add restrict_admin_usage arg to admin_override
rather than allow admins to do everything specifically, we should only block them from things we conciously don't want them to do. This is "Don't let platform admins send letters from services they're not in". Everything else the platform admins can do. This is step one, adding a restrict_admin_usage flag, and setting that for those restricted endpoints around creating api keys, uploading CSVs and sending one-off messages. Also, this commit separates the two use cases for permissions: * user.has_permission for access control * user.has_permission_for_service for user info - this is used for showing checkboxes on the manage-users page for example With this, we can remove the admin_override flag from the permission decorator.
This commit is contained in:
@@ -59,15 +59,14 @@ class BrowsableItem(object):
|
||||
pass
|
||||
|
||||
|
||||
def user_has_permissions(*permissions, admin_override=False, any_=False):
|
||||
def user_has_permissions(*permissions, **permission_kwargs):
|
||||
def wrap(func):
|
||||
@wraps(func)
|
||||
def wrap_func(*args, **kwargs):
|
||||
if current_user and current_user.is_authenticated:
|
||||
if current_user.has_permissions(
|
||||
*permissions,
|
||||
admin_override=admin_override,
|
||||
any_=any_
|
||||
**permission_kwargs
|
||||
):
|
||||
return func(*args, **kwargs)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user