grpc-swift
grpc-swift copied to clipboard
Make handling asynchronous auth easier to handle
Currently, auth is handled with Client/ServerInterceptors and that of course works. But this has a number of pitfalls:
- It requires you to call
send/receiveon the correctEventLoop(that could actually be fixed) - It requires you to call the
send/receives in the order you got called. That means for async auth you will need to manually buffer! (see for example this user's illegal state issue: https://stackoverflow.com/questions/76534719/eventloopfuture-causing-invalid-state-unable-to-write-message/76535053#76535053 as well as https://github.com/grpc/grpc-swift/issues/1181#issuecomment-842116341)
Basically it's way too hard to get this right for something that many/most(?) people will need.
I think gRPC should provide a very straightforward async throws hook that gets to see the headers and is then allowed to mutate/accept/reject them. This is both important for clients (which may want to add a token) and servers (which may want to validate a token).
Related: #1619 / #1620 / #1181