diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-08-24 10:55:45 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-08-24 10:55:45 +0000 |
commit | c29127408211f69f03d9c5b59eb00bdd47780966 (patch) | |
tree | 70ab6cb6fb027af482869040e735ca1f55c3f35d | |
parent | bb97fb549413e47ae8e798c26c2efe301ac0a1a2 (diff) | |
download | apifw-c29127408211f69f03d9c5b59eb00bdd47780966.tar.gz |
Fix: drop /<foo> from paths (rules)
-rw-r--r-- | apifw/bottleapp.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/apifw/bottleapp.py b/apifw/bottleapp.py index 012a48b..869a77f 100644 --- a/apifw/bottleapp.py +++ b/apifw/bottleapp.py @@ -98,8 +98,13 @@ class BottleAuthorizationPlugin: logging.info('Route %r does NOT need authorization', key) def route_key(self, route): + # route can be a dict (from find_missing_route), or a + # bottle.Route object. method = route.get('method', 'GET') - path = route.get('path', route.get('rule')) + path = route.get('path') + if not path: + rule = route.get('rule') + path = re.sub(r'/<[^>]+>', '', rule) return (method, path) def apply(self, callback, route): @@ -107,7 +112,7 @@ class BottleAuthorizationPlugin: call = False if self.needs_authorization(route): - call = self.is_authorized(route) + call = self.is_authorized(route) else: call = True if call: |