Description
Is your feature request related to a problem? Please describe.
When developing a custom auth extension, @rlankfo mentioned he needs access to the request URI to determine the proper auth parameters (tenant, for instance). Instead of just adding the possibility of specifying the interceptors to use as part of the auth package and using the experience gathered over the past couple of years since implementing the auth capabilities, I think it might be helpful to add support for middleware extensions instead: middleware extensions would have the possibility of intercepting the incoming requests (HTTP and gRPC) and potentially doing things that are beyond auth (and possibly advanced auth scenarios, like @rlankfo's). Another example of a middleware extension would be @MovieStoreGuy's open-telemetry/opentelemetry-collector-contrib#6908.
Depending on how we progress with this idea, server auth extensions could be implemented as a specialization of a middleware extension.
Describe the solution you'd like
I had a proposal for "authorizers" as part of @MovieStoreGuy's rate limiting extension proposal, and I would change that a bit, so that it reads middleware instead:
extensions:
oidc:
ratelimiter:
qps: 1000
blocklist:
source: https://example.com/blocklist.txt
receivers:
otlp:
protocols:
grpc:
auth:
authenticator: oidc
middlewares:
- blocklist
- ratelimiter
processors:
exporters:
logging:
service:
extensions: [oidc, ratelimiter]
pipelines:
traces:
receivers: [otlp]
processors: []
exporters: [logging]
Describe alternatives you've considered
Solving @rlankfo's problem could also be done by adding the notion of Interceptors to the server auth extension interface, with the current interptors (http.Handler, gRPC's Unary and Stream interceptors) as default implementations, allowing auth extensions to override when needed via options (WithInterceptor in addition to the current WithAuthenticate). Another possible solution to the original problem would be to add request metadata (URL, for instance) to the client's context, which is made available later on to auth extensions.