prevent ws endpoint from running without valid token
This commit is contained in:
parent
101dec461e
commit
fc59b02255
@ -81,8 +81,6 @@ async def validate_ws_token(
|
|||||||
except HTTPException:
|
except HTTPException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# No checks passed, deny the connection
|
|
||||||
logger.debug("Denying websocket request.")
|
|
||||||
# If it doesn't match, close the websocket connection
|
# If it doesn't match, close the websocket connection
|
||||||
await ws.close(code=status.WS_1008_POLICY_VIOLATION)
|
await ws.close(code=status.WS_1008_POLICY_VIOLATION)
|
||||||
|
|
||||||
|
@ -97,8 +97,9 @@ async def message_endpoint(
|
|||||||
rpc: RPC = Depends(get_rpc),
|
rpc: RPC = Depends(get_rpc),
|
||||||
message_stream: MessageStream = Depends(get_message_stream)
|
message_stream: MessageStream = Depends(get_message_stream)
|
||||||
):
|
):
|
||||||
async with create_channel(websocket) as channel:
|
if token:
|
||||||
await channel.run_channel_tasks(
|
async with create_channel(websocket) as channel:
|
||||||
channel_reader(channel, rpc),
|
await channel.run_channel_tasks(
|
||||||
channel_broadcaster(channel, message_stream)
|
channel_reader(channel, rpc),
|
||||||
)
|
channel_broadcaster(channel, message_stream)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user