grpc-ecosystem / go-grpc-middleware

Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.
Apache License 2.0
6.29k stars 693 forks source link

Feature: Auth Interceptor: Add support for partial per service AuthFunc override #707

Open seinshah opened 6 months ago

seinshah commented 6 months ago

Sometimes, there is a possibility that some of the methods in a service are publicly available and some need authentication. The current ServiceAuthFuncOverride allows each service to override the global AuthFunc. However, if a service needs to override the global AuthFunc for some methods, it needs to duplicate AuthFunc logic. It would be nice to allow services to override AuthFunc, but also allow them to fallback to the global AuthFunc if they want to only override it for certain methods and not all of them.

johanbrandhorst commented 6 months ago

Thanks for your issue. For this sort of thing I usually recommend just forking the repo and implementing what you need. I'm opposed to functionality bloat because it can spiral out of control quickly. Even just copy pasting the handler logic you need (preserving the license, of course) is not that big of a deal.

seinshah commented 6 months ago

@johanbrandhorst, that's kind of what I did and diverged from this repo to address the need. However, as you mentioned, if this is not something people face very often, it might not worth being added to the source code. Thanks for your comment.