From a82fd6def07744fa40bef836a1a1e06a01b4ae8d Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Fri, 28 May 2021 22:02:35 +0200 Subject: [PATCH] =?UTF-8?q?[acl]=C2=A0ajout=20de=20l'acl=20private=20(test?= =?UTF-8?q?=20purposes)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- halfapi/lib/acl.py | 5 +++++ halfapi/lib/jwt_middleware.py | 5 ++++- tests/test_jwt_middleware.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/halfapi/lib/acl.py b/halfapi/lib/acl.py index 57556c8..e6f3dd7 100644 --- a/halfapi/lib/acl.py +++ b/halfapi/lib/acl.py @@ -15,6 +15,11 @@ def public(*args, **kwargs) -> bool: "Unlimited access" return True +def private(*args, **kwargs) -> bool: + "Forbidden access" + return False + + def connected(fct=public): """ Decorator that checks if the user object of the request has been set """ diff --git a/halfapi/lib/jwt_middleware.py b/halfapi/lib/jwt_middleware.py index ddfe144..9501fc1 100644 --- a/halfapi/lib/jwt_middleware.py +++ b/halfapi/lib/jwt_middleware.py @@ -72,7 +72,10 @@ class JWTUser(BaseUser): (self.payload.get('name'), self.payload.get('firstname'))) @property - def identity(self) -> str: + def id(self) -> str: + return self.__id + + return self.__id diff --git a/tests/test_jwt_middleware.py b/tests/test_jwt_middleware.py index eee24d5..54996b1 100644 --- a/tests/test_jwt_middleware.py +++ b/tests/test_jwt_middleware.py @@ -26,7 +26,7 @@ def test_JWTUser(): token = '{}' payload = {} user = JWTUser(uid, token, payload) - assert user.identity == uid + assert user.id == uid assert user.token == token assert user.payload == payload assert user.is_authenticated == True