Fix auth bug when no token is set

This commit is contained in:
Matthias 2022-09-12 07:28:31 +02:00
parent 5483cf21f6
commit 715a71465d
2 changed files with 4 additions and 5 deletions

View File

@ -88,11 +88,10 @@ class DataProvider:
def _set_producer_pairs(self, pairlist: List[str], producer_name: str = "default"):
"""
Set the pairs received to later be used.
This only supports 1 Producer right now.
:param pairlist: List of pairs
"""
self.__producer_pairs[producer_name] = pairlist.copy()
self.__producer_pairs[producer_name] = pairlist
def get_producer_pairs(self, producer_name: str = "default") -> List[str]:
"""
@ -100,7 +99,7 @@ class DataProvider:
:returns: List of pairs
"""
return self.__producer_pairs.get(producer_name, [])
return self.__producer_pairs.get(producer_name, []).copy()
def _emit_df(
self,

View File

@ -59,7 +59,7 @@ async def validate_ws_token(
secret_ws_token = api_config.get('ws_token', None)
secret_jwt_key = api_config.get('jwt_secret_key', 'super-secret')
if ws_token and secrets.compare_digest(secret_ws_token, ws_token):
if ws_token and secret_ws_token and secrets.compare_digest(secret_ws_token, ws_token):
# Just return the token if it matches
return ws_token
else:
@ -69,7 +69,7 @@ async def validate_ws_token(
# If the token is a jwt, and it's valid return the user
except HTTPException:
pass
logger.info("Denying websocket request")
logger.debug("Denying websocket request.")
# If it doesn't match, close the websocket connection
await ws.close(code=status.WS_1008_POLICY_VIOLATION)