🔒️ Require ADMIN for user management

So far it only required SETTINGS for historic reasons. The
description of SETTINGS however doesn't hint at that kind
of access and so this was misleading and could have led
to dangerous configurations.
This commit is contained in:
Gina Häußge committed 2022-09-08 17:22:52 +02:00
1 parent e550c94068
commit dc201416b6
2 files changed
+12 -12

No files matched your search

+11 -11
View File
@@ -25,14 +25,14 @@ def get_permissions():
@api.route("/access/groups", methods=["GET"])
@no_firstrun_access
@Permissions.SETTINGS.require(403)
@Permissions.ADMIN.require(403)
def get_groups():
return jsonify(groups=list(map(lambda g: g.as_dict(), groupManager.groups)))
@api.route("/access/groups", methods=["POST"])
@no_firstrun_access
@Permissions.SETTINGS.require(403)
@Permissions.ADMIN.require(403)
def add_group():
if "application/json" not in request.headers["Content-Type"]:
abort(400, description="Expected content-type JSON")
@@ -69,7 +69,7 @@ def add_group():
@api.route("/access/groups/<key>", methods=["GET"])
@no_firstrun_access
@Permissions.SETTINGS.require(403)
@Permissions.ADMIN.require(403)
def get_group(key):
group = groupManager.find_group(key)
if group is not None:
@@ -80,7 +80,7 @@ def get_group(key):
@api.route("/access/groups/<key>", methods=["PUT"])
@no_firstrun_access
@Permissions.SETTINGS.require(403)
@Permissions.ADMIN.require(403)
def update_group(key):
if "application/json" not in request.headers["Content-Type"]:
abort(400, description="Expected content-type JSON")
@@ -113,7 +113,7 @@ def update_group(key):
@api.route("/access/groups/<key>", methods=["DELETE"])
@no_firstrun_access
@Permissions.SETTINGS.require(403)
@Permissions.ADMIN.require(403)
def remove_group(key):
try:
groupManager.remove_group(key)
@@ -129,14 +129,14 @@ def remove_group(key):
@api.route("/access/users", methods=["GET"])
@no_firstrun_access
@Permissions.SETTINGS.require(403)
@Permissions.ADMIN.require(403)
def get_users():
return jsonify(users=list(map(lambda u: u.as_dict(), userManager.get_all_users())))
@api.route("/access/users", methods=["POST"])
@no_firstrun_access
@Permissions.SETTINGS.require(403)
@Permissions.ADMIN.require(403)
def add_user():
if "application/json" not in request.headers["Content-Type"]:
abort(400, description="Expected content-type JSON")
@@ -188,7 +188,7 @@ def get_user(username):
@api.route("/access/users/<username>", methods=["PUT"])
@no_firstrun_access
@Permissions.SETTINGS.require(403)
@Permissions.ADMIN.require(403)
def update_user(username):
user = userManager.find_user(username)
if user is not None:
@@ -223,7 +223,7 @@ def update_user(username):
@api.route("/access/users/<username>", methods=["DELETE"])
@no_firstrun_access
@Permissions.SETTINGS.require(403)
@Permissions.ADMIN.require(403)
def remove_user(username):
try:
userManager.remove_user(username)
@@ -243,7 +243,7 @@ def change_password_for_user(username):
and not current_user.is_anonymous
and (
current_user.get_name() == username
or current_user.has_permission(Permissions.SETTINGS)
or current_user.has_permission(Permissions.ADMIN)
)
):
if "application/json" not in request.headers["Content-Type"]:
@@ -257,7 +257,7 @@ def change_password_for_user(username):
if "password" not in data or not data["password"]:
abort(400, description="new password is missing")
if not current_user.has_permission(Permissions.SETTINGS) or "current" in data:
if not current_user.has_permission(Permissions.ADMIN) or "current" in data:
if "current" not in data or not data["current"]:
abort(400, description="current password is missing")
@@ -862,7 +862,7 @@ $(function () {
access.onUserLoggedIn =
access.onUserLoggedOut =
function (user) {
if (access.loginState.hasPermission(access.permissions.SETTINGS)) {
if (access.loginState.hasPermission(access.permissions.ADMIN)) {
access.groups.requestData().done(function () {
access.users.requestData();
});