|
13 | 13 |
|
14 | 14 | from wes_service.util import visit, WESBackend
|
15 | 15 |
|
| 16 | +class MissingAuthorization(Exception): |
| 17 | + pass |
16 | 18 |
|
17 | 19 | def get_api():
|
| 20 | + if not connexion.request.headers.get('Authorization'): |
| 21 | + raise MissingAuthorization() |
18 | 22 | return arvados.api_from_config(version="v1", apiconfig={
|
19 | 23 | "ARVADOS_API_HOST": os.environ["ARVADOS_API_HOST"],
|
20 | 24 | "ARVADOS_API_TOKEN": connexion.request.headers['Authorization'],
|
@@ -43,6 +47,8 @@ def catch_exceptions_wrapper(self, *args, **kwargs):
|
43 | 47 | return {"msg": e._get_reason(), "status_code": e.resp.status}, int(e.resp.status)
|
44 | 48 | except subprocess.CalledProcessError as e:
|
45 | 49 | 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 |
46 | 52 |
|
47 | 53 | return catch_exceptions_wrapper
|
48 | 54 |
|
@@ -111,6 +117,9 @@ def RunWorkflow(self, body):
|
111 | 117 | if body["workflow_type"] != "CWL" or body["workflow_type_version"] != "v1.0": # NOQA
|
112 | 118 | return
|
113 | 119 |
|
| 120 | + if not connexion.request.headers.get('Authorization'): |
| 121 | + raise MissingAuthorization() |
| 122 | + |
114 | 123 | env = {
|
115 | 124 | "PATH": os.environ["PATH"],
|
116 | 125 | "ARVADOS_API_HOST": os.environ["ARVADOS_API_HOST"],
|
|
0 commit comments