diff options
author | Lars Wirzenius <lwirzenius@wikimedia.org> | 2019-07-01 18:27:29 +0300 |
---|---|---|
committer | Lars Wirzenius <lwirzenius@wikimedia.org> | 2019-07-01 18:27:29 +0300 |
commit | fe0928490feffb8125ba33f031e994af5811677a (patch) | |
tree | 9181fb41c89c4fe35680748d38d3a3839fc23616 | |
parent | f028319bb1b0d447214e1cc72806c76d699a166a (diff) | |
download | wmf-ci-arch-fe0928490feffb8125ba33f031e994af5811677a.tar.gz |
Change: api.py to require hello scope for /hello endpoint
-rw-r--r-- | api.py | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -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'], }, ] |