|
|
@ -33,17 +33,17 @@ def get_signature_user(scope):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if scope['type'] == 'websocket':
|
|
|
|
if scope['type'] == 'websocket':
|
|
|
|
scope['method'] = 'GET'
|
|
|
|
scope['method'] = 'GET'
|
|
|
|
try:
|
|
|
|
# 因为 ws 使用的是 scope,所以需要转换成 request 对象,用于认证校验
|
|
|
|
# 因为 ws 使用的是 scope,所以需要转换成 request 对象,用于认证校验
|
|
|
|
request = ASGIRequest(scope, None)
|
|
|
|
request = ASGIRequest(scope, None)
|
|
|
|
backends = [SignatureAuthentication(),
|
|
|
|
backends = [SignatureAuthentication(),
|
|
|
|
AccessTokenAuthentication()]
|
|
|
|
AccessTokenAuthentication()]
|
|
|
|
for backend in backends:
|
|
|
|
for backend in backends:
|
|
|
|
try:
|
|
|
|
user, _ = backend.authenticate(request)
|
|
|
|
user, _ = backend.authenticate(request)
|
|
|
|
if user:
|
|
|
|
if user:
|
|
|
|
return user
|
|
|
|
return user
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
print(e)
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|