File tree Expand file tree Collapse file tree
distributed/http/scheduler Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,29 +14,27 @@ def require_auth(method_func):
1414 def wrapper (self ):
1515 auth = self .request .headers .get ("Authorization" , None )
1616 key = dask .config .get ("distributed.scheduler.http.api-key" )
17- if (
18- key is None
19- or key == ""
20- or (
21- key
22- and (
23- not auth
24- or not auth .startswith ("Bearer " )
25- or key != auth .split (" " )[- 1 ]
26- )
27- )
17+ if key is False or (
18+ key and auth and auth .startswith ("Bearer " ) and key == auth .split (" " )[- 1 ]
2819 ):
29- self .set_status (403 , "Unauthorized" )
30- return
20+ if not asyncio .iscoroutinefunction (method_func ):
21+ return method_func (self )
22+ else :
3123
32- if not asyncio .iscoroutinefunction (method_func ):
33- return method_func (self )
34- else :
24+ async def tmp ():
25+ return await method_func (self )
3526
36- async def tmp ():
37- return await method_func (self )
27+ return tmp ()
28+ else :
29+ self .set_status (403 , "Unauthorized" )
30+ if not asyncio .iscoroutinefunction (method_func ):
31+ return
32+ else :
33+ # When wrapping a coroutine we need to return a coroutine even if it just returns None
34+ async def tmp ():
35+ return
3836
39- return tmp ()
37+ return tmp ()
4038
4139 return wrapper
4240
You can’t perform that action at this time.
0 commit comments