go-sse
go-sse copied to clipboard
Conditional publish based on user permissions
I'm enjoying this library and impressed by your responsiveness to people's issues!
One problem I'm having is I need to filter events per session based on authorization rules in my security layer. I have a single SSE endpoint that thousands of users connect to, each with unique permissions that influence the events they receive.
I thought about using a custom MessageWriter
wrapper which might work, but the concrete Message
struct is highly optimized for streaming and I'd rather not have to unmarshal the message data for every connected client on the way out.
I also thought about partitioning my users into separate topics but my permissions are too fine-grained to make this feasible.
Couple of ideas off the top of my head:
- Make
Message
an interface so I can attach arbitrary metadata - Add a public
map[string]any
field toMessage
- Pass
context.Context
toMessageWriter.Send
so I can grab metadata from that - Introduce first-class middleware support
- Tease apart the pub/sub and wire-format responsibilities - looks like this is already on your radar
Cheers!