diff options
author | Serena Feng <feng.xiaowei@zte.com.cn> | 2017-10-23 01:27:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-10-23 01:27:12 +0000 |
commit | d62585d81b030d9c94e14ff3f0a6fb3205bbd61b (patch) | |
tree | 67510b97e2ac5a170006969e3f29b40a24061e40 /testapi/opnfv_testapi/ui/auth | |
parent | f97f2212e862644178b87708ea62eb091b51a506 (diff) | |
parent | 839c1468cbe2025e759458bbe82c2f99a5ea347f (diff) |
Merge "allow authentication to be disabled"
Diffstat (limited to 'testapi/opnfv_testapi/ui/auth')
-rw-r--r-- | testapi/opnfv_testapi/ui/auth/user.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/testapi/opnfv_testapi/ui/auth/user.py b/testapi/opnfv_testapi/ui/auth/user.py index ab86007..ff2c2a9 100644 --- a/testapi/opnfv_testapi/ui/auth/user.py +++ b/testapi/opnfv_testapi/ui/auth/user.py @@ -1,5 +1,6 @@ from opnfv_testapi.common import constants from opnfv_testapi.common import raises +from opnfv_testapi.common.config import CONF from opnfv_testapi.resources import handlers from opnfv_testapi.resources import models @@ -19,8 +20,14 @@ class UserHandler(handlers.GenericApiHandler): self.table_cls = User def get(self): - username = self.get_secure_cookie(constants.TESTAPI_ID) - if username: - self._get_one(query={'user': username}) + if CONF.api_authenticate: + username = self.get_secure_cookie(constants.TESTAPI_ID) + if username: + self._get_one(query={'user': username}) + else: + raises.Unauthorized('Unauthorized') else: - raises.Unauthorized('Unauthorized') + self.finish_request(User('anonymous', + 'anonymous@linuxfoundation.com', + 'anonymous lf', + constants.TESTAPI_USERS).format()) |