11 Commits (4b66bcf85bd4450575b4286aab9e9c58f7cebc5e)

Author SHA1 Message Date
Jessie Murray ea01d687b5
Apply ACL rules to WebSocket commands
ACLs were not considered when processing commands coming over WebSocket
connections. WS commands that are disabled with ACLs are now rejected
with a custom message for JSON and raw WS clients, the two supported
formats for this protocol. For JSON an equivalent HTTP status code is
included in the response, although this is only an indication of how
Webdis would have responded if it came from a regular HTTP request.

Tests are added to validate that DEBUG commands are rejected by Webdis
without even making it to Redis, for both JSON and raw WS clients.

Add DEBUG OBJECT demo to websocket.html: DEBUG is disabled with ACLs
by default in webdis.json. A DEBUG button is added to the WebSocket
HTML demo to show what kind of response is produced when WebSocket
clients attempt to send such a command.

The error responses are documented in the README in the ACL section.

Fixes #240.
12 months ago
Nicolas Favre-Felix 73f29055c1
Improvements to ws_peek_data (by @majklik)
Better handling of WS client frames, contributed in the comments of #212:
* Reject unmasked frames as per RFC 6455
* Avoid unnecessary data copy from/to evbuffer
* Remove conditions on has_mask

2 new tests cover this change:
* minimal ping-pong with masked client frame, unmasked response
* rejected unmasked client frame
3 years ago
Jessie Murray 7d495e30c2
Add test for issue #209, Webdis crashing after receiving FIN frame
Connect, handshake, send FIN frame, disconnect. Webdis shouldn't crash.
3 years ago
Jessie Murray 3be189b527
Use macro for htonll/ntohll for portability
I realized that these functions are not standard, so this is bringing
macros back for the 64-bit transforms.
3 years ago
Jessie Murray e213af3226
Fix for WebSocket payload length using 8 bytes
The 8-byte conversion macros were incorrect, and could be replaced with
standard methods instead. This also adds a test to cover this case.
3 years ago
Jessie Murray 1cbffb63c9
Re-enable pub/sub test in ws-tests 3 years ago
Jessie Murray bb02c1dd04
Formatting only: make ws-tests.py PEP8 compliant. 3 years ago
Jessie Murray 71223ae005
Address review comments (tests) 3 years ago
Jessie Murray 6b090b4ede
Large refactoring of WS code
1. Introduce ws_client struct
2. Handle all communications from websocket.c for WS clients
3. Always use a dedicated Redis connection for WS clients
4. Add rbuf & wbuf evbuffers for incoming & outgoing WS data
5. Use event_base_once to control R/W events
6. WS test: make sure to read complete HTTP response
3 years ago
Jessie Murray 6383cd48dd
Add pub-sub test using WebSockets (disabled)
Add new pub-sub test using WebSockets, disabled by default due to
message ordering not matching what is expected.
Enable the test with `PUBSUB=1 ./ws-tests.py`
3 years ago
Jessie Murray f86bad3bc8
Add Python-based WebSockets tests
1. Create WS tests with the same structure as basic.py
2. Add JSON tests
3. Add "raw" tests
3 years ago