@@ -152,20 +152,24 @@ def get_app(config: ApplicationConfig):
152152 return app
153153
154154
155- def access_task_permission (
155+ async def access_task_permission (
156156 opa : Annotated [OpaUserClient | None , Depends (opa )],
157157 task_id : str ,
158158 fedid : Fedid ,
159159 runner : Annotated [WorkerDispatcher , Depends (_runner )],
160160):
161161 task = runner .run (interface .get_task_by_id , task_id )
162162
163- if opa and not opa .admin () and (task and fedid != task .task .metadata .get ("user" )):
163+ if (
164+ opa
165+ and not await opa .admin ()
166+ and (task and fedid != task .task .metadata .get ("user" ))
167+ ):
164168 raise HTTPException (status_code = status .HTTP_404_NOT_FOUND )
165169
166170
167171# start_task_permission is used when there is WorkerTask
168- def start_task_permission (
172+ async def start_task_permission (
169173 task : WorkerTask ,
170174 opa : Annotated [OpaUserClient , Depends (opa )],
171175 fedid : Fedid ,
@@ -176,7 +180,7 @@ def start_task_permission(
176180 status_code = status .HTTP_422_UNPROCESSABLE_CONTENT ,
177181 detail = "No task id provided" ,
178182 )
179- access_task_permission (opa , task .task_id , fedid , runner )
183+ await access_task_permission (opa , task .task_id , fedid , runner )
180184
181185
182186async def on_key_error_404 (_ : Request , __ : Exception ):
0 commit comments