sonora icon indicating copy to clipboard operation
sonora copied to clipboard

Add support for Interceptors

Open public opened this issue 6 years ago • 4 comments

Interceptors are gRPC specific middlewares that can apply both at the client and the server level.

public avatar Nov 03 '19 15:11 public

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!

b3nav avatar Jun 18 '21 11:06 b3nav

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 :)

public avatar Jun 18 '21 11:06 public

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.

b3nav avatar Jun 18 '21 21:06 b3nav

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.

public avatar Jun 19 '21 11:06 public