From 1b8cdbc4dda12403f918b1cb8b5ca35ac6f1d703 Mon Sep 17 00:00:00 2001 From: Huaqing Chen Date: Tue, 15 Oct 2024 10:09:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwebsocket=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E4=BD=BF=E7=94=A8Authorization=20Header=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jumpserver/routing.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/jumpserver/routing.py b/apps/jumpserver/routing.py index 0c8e78063..1075cb584 100644 --- a/apps/jumpserver/routing.py +++ b/apps/jumpserver/routing.py @@ -33,17 +33,17 @@ def get_signature_user(scope): return if scope['type'] == 'websocket': scope['method'] = 'GET' - try: - # 因为 ws 使用的是 scope,所以需要转换成 request 对象,用于认证校验 - request = ASGIRequest(scope, None) - backends = [SignatureAuthentication(), - AccessTokenAuthentication()] - for backend in backends: + # 因为 ws 使用的是 scope,所以需要转换成 request 对象,用于认证校验 + request = ASGIRequest(scope, None) + backends = [SignatureAuthentication(), + AccessTokenAuthentication()] + for backend in backends: + try: user, _ = backend.authenticate(request) if user: return user - except Exception as e: - print(e) + except Exception as e: + print(e) return None