summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-11-10 12:29:19 +0200
committerLars Wirzenius <liw@liw.fi>2018-11-10 12:29:19 +0200
commit6eb2d9bd81368aa1bbc4c80656db1ea5db419a21 (patch)
tree57e62f9670840220a105a4079cc447064c622cdc
parent362cfba9f10f26cccf7ef90d2edab7b4dba38d47 (diff)
downloadmuck-poc-6eb2d9bd81368aa1bbc4c80656db1ea5db419a21.tar.gz
Change: catch and log exceptions when handling requests
-rwxr-xr-xmuck_poc20
1 files changed, 13 insertions, 7 deletions
diff --git a/muck_poc b/muck_poc
index 1912ca4..4072228 100755
--- a/muck_poc
+++ b/muck_poc
@@ -76,13 +76,19 @@ class MuckAPI:
def _check_authz(self, req_method, req_scope, callback):
def check_authz():
- r = muck.Request(method=bottle.request.method)
- r.add_headers(bottle.request.headers)
- if self._ac.request_is_allowed(r, req_method, [req_scope]):
- claims = self._ac.get_claims_from_token(r)
- return callback(claims)
- logging.error('Access denied')
- return bottle.HTTPError(401)
+ try:
+ rr = bottle.request
+ logging.info('Request: %s %s', rr.method, rr.path)
+ r = muck.Request(method=rr.method)
+ r.add_headers(rr.headers)
+ if self._ac.request_is_allowed(r, req_method, [req_scope]):
+ claims = self._ac.get_claims_from_token(r)
+ return callback(claims)
+ logging.error('Access denied')
+ return bottle.HTTPError(401)
+ except BaseException as e:
+ logging.error(repr(e), exc_info=True)
+ raise
return check_authz