Skip to content

Commit 58179f6

Browse files
author
Peter Amstutz
committed
Handle missing or blank authorization header.
1 parent 7841e1b commit 58179f6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

wes_service/arvados_wes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313

1414
from wes_service.util import visit, WESBackend
1515

16+
class MissingAuthorization(Exception):
17+
pass
1618

1719
def get_api():
20+
if not connexion.request.headers.get('Authorization'):
21+
raise MissingAuthorization()
1822
return arvados.api_from_config(version="v1", apiconfig={
1923
"ARVADOS_API_HOST": os.environ["ARVADOS_API_HOST"],
2024
"ARVADOS_API_TOKEN": connexion.request.headers['Authorization'],
@@ -43,6 +47,8 @@ def catch_exceptions_wrapper(self, *args, **kwargs):
4347
return {"msg": e._get_reason(), "status_code": e.resp.status}, int(e.resp.status)
4448
except subprocess.CalledProcessError as e:
4549
return {"msg": str(e), "status_code": 500}, 500
50+
except MissingAuthorization:
51+
return {"msg": "'Authorization' header is missing or empty, expecting Arvados API token", "status_code": 401}, 401
4652

4753
return catch_exceptions_wrapper
4854

@@ -111,6 +117,9 @@ def RunWorkflow(self, body):
111117
if body["workflow_type"] != "CWL" or body["workflow_type_version"] != "v1.0": # NOQA
112118
return
113119

120+
if not connexion.request.headers.get('Authorization'):
121+
raise MissingAuthorization()
122+
114123
env = {
115124
"PATH": os.environ["PATH"],
116125
"ARVADOS_API_HOST": os.environ["ARVADOS_API_HOST"],

0 commit comments

Comments
 (0)