prevent ws endpoint from running without valid token

This commit is contained in:
Timothy Pogue 2022-11-24 13:41:10 -07:00
parent 101dec461e
commit fc59b02255
2 changed files with 6 additions and 7 deletions

View File

@ -81,8 +81,6 @@ async def validate_ws_token(
except HTTPException:
pass
# No checks passed, deny the connection
logger.debug("Denying websocket request.")
# If it doesn't match, close the websocket connection
await ws.close(code=status.WS_1008_POLICY_VIOLATION)

View File

@ -97,8 +97,9 @@ async def message_endpoint(
rpc: RPC = Depends(get_rpc),
message_stream: MessageStream = Depends(get_message_stream)
):
async with create_channel(websocket) as channel:
await channel.run_channel_tasks(
channel_reader(channel, rpc),
channel_broadcaster(channel, message_stream)
)
if token:
async with create_channel(websocket) as channel:
await channel.run_channel_tasks(
channel_reader(channel, rpc),
channel_broadcaster(channel, message_stream)
)