Merge branch 'dev/granularPermissions' into devel
# Conflicts: # src/octoprint/server/api/files.py # src/octoprint/server/api/job.py # src/octoprint/static/js/app/viewmodels/users.js
This commit is contained in:
commit
d8eb57548d
99 files changed
+5806
-2273
No files matched your search
@@ -16,7 +16,8 @@ from octoprint.settings import settings, valid_boolean_trues
|
||||
|
||||
from octoprint.server import admin_permission, printer
|
||||
from octoprint.server.api import api, NO_CONTENT
|
||||
from octoprint.server.util.flask import restricted_access, with_revalidation_checking
|
||||
from octoprint.server.util.flask import require_firstrun, with_revalidation_checking
|
||||
from octoprint.access.permissions import Permissions
|
||||
|
||||
import octoprint.plugin
|
||||
import octoprint.util
|
||||
@@ -40,7 +41,7 @@ def _etag(lm=None):
|
||||
sorted_plugin_settings[key] = plugin_settings.get(key, dict())
|
||||
|
||||
if current_user is not None and not current_user.is_anonymous:
|
||||
roles = sorted(current_user.roles)
|
||||
roles = sorted(current_user.permissions)
|
||||
else:
|
||||
roles = []
|
||||
|
||||
@@ -83,7 +84,8 @@ def getSettings():
|
||||
data = {
|
||||
"api": {
|
||||
"enabled": s.getBoolean(["api", "enabled"]),
|
||||
"key": s.get(["api", "key"]) if admin_permission.can() else None,
|
||||
"keyEnforced": s.getBoolean(["api", "keyEnforced"]),
|
||||
"key": s.get(["api", "key"]) if Permissions.ADMIN.can() else None,
|
||||
"allowCrossOrigin": s.get(["api", "allowCrossOrigin"])
|
||||
},
|
||||
"appearance": {
|
||||
@@ -275,8 +277,8 @@ def _get_plugin_settings():
|
||||
|
||||
|
||||
@api.route("/settings", methods=["POST"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
@require_firstrun
|
||||
@Permissions.SETTINGS.require(403)
|
||||
def setSettings():
|
||||
if not "application/json" in request.headers["Content-Type"]:
|
||||
return make_response("Expected content-type JSON", 400)
|
||||
@@ -298,16 +300,16 @@ def setSettings():
|
||||
|
||||
|
||||
@api.route("/settings/apikey", methods=["POST"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
@require_firstrun
|
||||
@Permissions.SETTINGS.require(403)
|
||||
def generateApiKey():
|
||||
apikey = settings().generateApiKey()
|
||||
return jsonify(apikey=apikey)
|
||||
|
||||
|
||||
@api.route("/settings/apikey", methods=["DELETE"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
@require_firstrun
|
||||
@Permissions.SETTINGS.require(403)
|
||||
def deleteApiKey():
|
||||
settings().deleteApiKey()
|
||||
return NO_CONTENT
|
||||
@@ -323,6 +325,7 @@ def _saveSettings(data):
|
||||
|
||||
if "api" in data.keys():
|
||||
if "enabled" in data["api"]: s.setBoolean(["api", "enabled"], data["api"]["enabled"])
|
||||
if "keyEnforced" in data["api"]: s.setBoolean(["api", "keyEnforced"], data["api"]["keyEnforced"])
|
||||
if "allowCrossOrigin" in data["api"]: s.setBoolean(["api", "allowCrossOrigin"], data["api"]["allowCrossOrigin"])
|
||||
|
||||
if "appearance" in data.keys():
|
||||
|
||||
Reference in new issue
Block a user