summaryrefslogtreecommitdiffstats
path: root/module/web/api_app.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-09-27 16:24:03 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-09-27 16:24:03 +0200
commit5f8a4d25ea9034cadc8ae19a2ffab788f62cc56c (patch)
tree9d947797aafb3e9d97dbf10313c5f48f6f3d6198 /module/web/api_app.py
parentMerge (diff)
downloadpyload-5f8a4d25ea9034cadc8ae19a2ffab788f62cc56c.tar.xz
reworked authorization, now works on api level
Diffstat (limited to 'module/web/api_app.py')
-rw-r--r--module/web/api_app.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/module/web/api_app.py b/module/web/api_app.py
index 32b128e6a..156922d6a 100644
--- a/module/web/api_app.py
+++ b/module/web/api_app.py
@@ -14,7 +14,6 @@ from utils import toDict, set_session
from webinterface import PYLOAD
from module.common.json_layer import json_dumps
-from module.database.UserDatabase import ROLE
try:
from ast import literal_eval
@@ -46,9 +45,12 @@ def call_api(func, args=""):
if 'session' in request.POST:
s = s.get_by_id(request.POST['session'])
- if not s or not s.get("authenticated", False) or s.get("role", -1) != ROLE.ADMIN:
+ if not s or not s.get("authenticated", False):
return HTTPError(401, json_dumps("Unauthorized"))
+ if not PYLOAD.isAuthorized(func, {"role": s["role"], "permission": s["perms"]}):
+ return HTTPError(403, json_dumps("Forbidden"))
+
args = args.split("/")[1:]
kwargs = {}