From eb851ce6e16cdd8d17e413c601046a6b9ed968a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 6 Sep 2018 12:45:07 +0200 Subject: [PATCH] Added some type declarations I added those for a certain use that ended up not being committed, but those declarations are useful anyway. --- pillar/api/utils/authorization.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pillar/api/utils/authorization.py b/pillar/api/utils/authorization.py index 05307658..b7d8f4c9 100644 --- a/pillar/api/utils/authorization.py +++ b/pillar/api/utils/authorization.py @@ -1,5 +1,6 @@ import logging import functools +import typing from bson import ObjectId from flask import g @@ -12,8 +13,9 @@ CHECK_PERMISSIONS_IMPLEMENTED_FOR = {'projects', 'nodes', 'flamenco_jobs'} log = logging.getLogger(__name__) -def check_permissions(collection_name, resource, method, append_allowed_methods=False, - check_node_type=None): +def check_permissions(collection_name: str, resource: dict, method: str, + append_allowed_methods=False, + check_node_type: typing.Optional[str] = None): """Check user permissions to access a node. We look up node permissions from world to groups to users and match them with the computed user permissions. If there is not match, we raise 403. @@ -93,8 +95,9 @@ def compute_allowed_methods(collection_name, resource, check_node_type=None): return allowed_methods -def has_permissions(collection_name, resource, method, append_allowed_methods=False, - check_node_type=None): +def has_permissions(collection_name: str, resource: dict, method: str, + append_allowed_methods=False, + check_node_type: typing.Optional[str] = None): """Check user permissions to access a node. We look up node permissions from world to groups to users and match them with the computed user permissions.