diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-11-10 12:29:19 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-11-10 12:29:19 +0200 |
commit | 6eb2d9bd81368aa1bbc4c80656db1ea5db419a21 (patch) | |
tree | 57e62f9670840220a105a4079cc447064c622cdc | |
parent | 362cfba9f10f26cccf7ef90d2edab7b4dba38d47 (diff) | |
download | muck-poc-6eb2d9bd81368aa1bbc4c80656db1ea5db419a21.tar.gz |
Change: catch and log exceptions when handling requests
-rwxr-xr-x | muck_poc | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -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 |