From fc768f7f525fe730692434bf17f6338795a6d9b2 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 7 Dec 2017 21:07:46 +0200 Subject: Prepare to release version 0.29 --- NEWS | 4 +++- apifw/bottleapp.py | 21 +++++++++++++++++---- apifw/version.py | 4 ++-- debian/changelog | 4 ++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 7fd193a..3879990 100644 --- a/NEWS +++ b/NEWS @@ -4,9 +4,11 @@ apifw NEWS This file summarizes changes between releases of `apifw`. -Version 0.19+git, not yet released +Version 0.29, released 2017-12-07 ---------------------------------- +* Logging now always goes via the logger specified by the application, + instead of the logging stdlib library. Version 0.19, released 2017-12-07 ---------------------------------- diff --git a/apifw/bottleapp.py b/apifw/bottleapp.py index b204884..9a907f0 100644 --- a/apifw/bottleapp.py +++ b/apifw/bottleapp.py @@ -79,6 +79,10 @@ class BottleAuthorizationPlugin: self.iss = None self.aud = None self._authz_routes = set() + self._logger = lambda **kwags: None + + def set_logger(self, logger): + self._logger = logger def set_token_signing_public_key(self, pubkey): self.pubkey = Crypto.PublicKey.RSA.importKey(pubkey) @@ -93,9 +97,13 @@ class BottleAuthorizationPlugin: key = self.route_key(route) if route.get('needs-authorization', True): self._authz_routes.add(key) - logging.info('Route %r does DOES need authorization', key) + self._logger( + msg_type='info', msg_text='Route does DOES need authorization', + route=key) else: - logging.info('Route %r does NOT need authorization', key) + self._logger( + msg_type='info', msg_text='Route does NOT need authorization', + route=key) def route_key(self, route): # route can be a dict (from find_missing_route), or a @@ -164,8 +172,11 @@ class BottleAuthorizationPlugin: route_scope = self.get_scope_for_route(route['method'], route['rule']) if route_scope in scopes: return True - logging.error( - 'Route scope %s is NOT in scopes %r', route_scope, scopes) + self._logger( + msg_type='error', + msg_text='Route scope is NOT in scopes', + route_scope=route_scope, + scopes=scopes) return False def get_scope_for_route(self, method, rule): @@ -285,6 +296,8 @@ def create_bottle_application( app.add_plugin(plugin) authz = BottleAuthorizationPlugin() + if logger: + authz.set_dict_logger(logger) authz.set_token_signing_public_key(config['token-public-key']) authz.set_expected_issuer(config['token-issuer']) authz.set_expected_audience(config['token-audience']) diff --git a/apifw/version.py b/apifw/version.py index 4adb7d4..a9a5482 100644 --- a/apifw/version.py +++ b/apifw/version.py @@ -1,2 +1,2 @@ -__version__ = "0.19+git" -__version_info__ = (0, 19, '+git') +__version__ = "0.29" +__version_info__ = (0, 29) diff --git a/debian/changelog b/debian/changelog index dec0526..80ddbd8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -apifw (0.19+git-1) UNRELEASED; urgency=medium +apifw (0.29-1) unstable; urgency=medium * New upstream version. - -- Lars Wirzenius Thu, 07 Dec 2017 20:33:57 +0200 + -- Lars Wirzenius Thu, 07 Dec 2017 21:07:46 +0200 apifw (0.19-1) unstable; urgency=medium -- cgit v1.2.1