fanout / django-eventstream

Server-Sent Events for Django
MIT License
650 stars 85 forks source link

save signed metadata in next link #19

Closed jkarneges closed 6 years ago

jkarneges commented 6 years ago

This puts the current channels and user ID in the Grip-Link URL, signed in a JWT using settings.SECRET_KEY. When the proxy makes a request to the URL, the supplied channels are used instead of calling get_channels_for_request, and the supplied user is passed to any can_read_channel calls.

Basically this makes channel auth by Django user actually work. The first request uses normal auth, and subsequent requests use custom auth via the special JWT.

A notable side-effect of this change is you can't change the channels of a stream once it starts (which was possible when get_channels_for_request was called every time), but this is a pretty strange thing to need to do. Revoking access is still possible since can_read_channel is still called as normal.

Code needs testing.