Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OriginValidator could raise exception/log message for denied connections #2062

Open
pztrick opened this issue Dec 9, 2023 · 1 comment
Open

Comments

@pztrick
Copy link

pztrick commented Dec 9, 2023

The OriginValidator and AllowedHostsOriginValidator do not currently log anything to stdout/stderr when requests are denied.

API client tools like Insomnia may not set any Origin header when making a websocket request, or users could have their ALLOWED_HOSTS misconfigured, resulting in this output:

WebSocket HANDSHAKING /ws/echo/ [172.20.0.1:51624]
WebSocket REJECT /ws/echo/ [172.20.0.1:51624]
WebSocket DISCONNECT /ws/echo/ [172.20.0.1:51624]

No information is given for why the request was rejected.

The OriginValidator could output an exception to stderr or another logger similar to its HTTP counter-part django.core.exceptions.DisallowedHost. This would result in friendlier output, e.g.:

WebSocket HANDSHAKING /ws/echo/ [172.20.0.1:51624]
> Invalid Origin header: 'example.com:8621'. You may need to add 'example.com' to ALLOWED_HOSTS.
WebSocket REJECT /ws/echo/ [172.20.0.1:51624]
WebSocket DISCONNECT /ws/echo/ [172.20.0.1:51624]
@carltongibson
Copy link
Member

Ok, if we used a logger (rather than stdout/stderr) we could do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants