summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2015-10-12 15:03:23 +0200
committerasteroide <thomas.duval@orange.com>2015-10-12 15:03:23 +0200
commit6026d8b28302f131e58a17526375319dbdd524ae (patch)
treec1f73159b222c17647cd39f0c653bc732c25ed56
parenta363067a1bdf411c28032b926b451fc9d0964dc6 (diff)
Fix a bug when raising an exception.
Change-Id: Iec52a659d18f5589e533adc9da2da29f6a38adde
-rw-r--r--keystonemiddleware-moon/keystonemiddleware/authz.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/keystonemiddleware-moon/keystonemiddleware/authz.py b/keystonemiddleware-moon/keystonemiddleware/authz.py
index a24ac897..8dbb60e9 100644
--- a/keystonemiddleware-moon/keystonemiddleware/authz.py
+++ b/keystonemiddleware-moon/keystonemiddleware/authz.py
@@ -317,14 +317,11 @@ class AuthZProtocol(object):
resp = self._get_authz_from_moon(self.x_subject_token, tenant_id, subject_id, object_id, action_id)
self.__unset_token()
if resp.status_code == 200:
- try:
- answer = json.loads(resp.content)
- self._LOG.debug(answer)
- if "authz" in answer and answer["authz"]:
- return self._app(env, start_response)
- except Exception as e:
- # self._LOG.error("You are not authorized to do that!")
- raise exception.Unauthorized(message="You are not authorized to do that! ({})".format(unicode(e)))
+ answer = json.loads(resp.content)
+ self._LOG.debug(answer)
+ if "authz" in answer and answer["authz"]:
+ return self._app(env, start_response)
+ raise exception.Unauthorized(message="You are not authorized to do that! ({})".format(unicode(answer["comment"])))
self._LOG.debug("No action_id found for {}".format(env.get("PATH_INFO")))
# If action is not found, we can't raise an exception because a lots of action is missing
# in function self._get_action, it is not possible to get them all.