summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lwirzenius@wikimedia.org>2019-07-01 18:27:29 +0300
committerLars Wirzenius <lwirzenius@wikimedia.org>2019-07-01 18:27:29 +0300
commitfe0928490feffb8125ba33f031e994af5811677a (patch)
tree9181fb41c89c4fe35680748d38d3a3839fc23616
parentf028319bb1b0d447214e1cc72806c76d699a166a (diff)
downloadwmf-ci-arch-fe0928490feffb8125ba33f031e994af5811677a.tar.gz
Change: api.py to require hello scope for /hello endpoint
-rw-r--r--api.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/api.py b/api.py
index 0eb850f..d593260 100644
--- a/api.py
+++ b/api.py
@@ -31,12 +31,13 @@ class AccessChecker:
logging.error('No valid access token')
return False
- scopes = token.get('scope', '').split()
- missing = set(required_scopes).difference(scopes)
- if missing:
- logging.error(
- 'Required scopes that are missing from token: %r', missing)
- return False
+ if token:
+ scopes = token.get('scope', '').split()
+ missing = set(required_scopes).difference(scopes)
+ if missing:
+ logging.error(
+ 'Required scopes that are missing from token: %r', missing)
+ return False
return True
@@ -101,7 +102,7 @@ class Controller(API):
'method': 'GET',
'path': '/hello/<name>',
'func': self._hello,
- 'scopes': [],
+ 'scopes': ['hello'],
},
]