sonora
sonora copied to clipboard
Add support for Interceptors
Interceptors are gRPC specific middlewares that can apply both at the client and the server level.
Hi @public - is this still in the works or has it been parked for the time being?
Currently we have a Django + gRPC that we run using Sonora and would be great to add an authentication interceptor to check for the provided credentials per each request.
Either that or having regular gRPC support would be awesome!
Love the project!
Interceptors should not be too hard to implement, not sure when I can get around to doing it myself but happy to review a PR if you want to take a go :)
Thanks for the prompt response - I personally am not exactly sure where to start to look to implement such feature so any initial pointers would be helpful to me or any potential contributor.
I did a bit more digging and actually it's more complicated than I originally thought because the upstream API is quite weird and seems like they hacked it on as an after thought really.
I might take a look at it in the next few weeks but also I am reminded why I didn't bother originally. You can quite easily replicate the behaviour of interceptors for many use cases using ASGI/WSGI middleware on the server side and by messing around with (the admittedly undocumented but not going anywhere) WebChannel._session attribute on the client side. Both the urllib3 sync client and aiohttp async client let you do things like set default headers for every request which is usually sufficient for auth purposes.