-
Notifications
You must be signed in to change notification settings - Fork 3.9k
GH-31924: [FlightRPC][Java] Provide standard way to get client IP address #43155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Added RequestInfo to Authenticator classes.
|
|
|
Does this strictly need to be built into Flight? Since you can always use the gRPC APIs directly |
If I am not wrong, using gRPC APIs is a partial solution. Correct me if I am saying something incorrect. You can create a The previous interceptor is executed when a client invokes any method. But it is called after the authentication process is done with |
|
But you're able to get the FlightService directly and fully control the server builder. |
Maybe I'm missing something, but I don't see how it is possible to do that. I only see a way of registering a This With that code, the order of the ServerInterceptors added to gRPC provokes that the I do not see a way of redefining the order of the Maybe a change for adding the possibility to redefine that order would fit better? |
|
arrow/java/flight/flight-core/src/main/java/org/apache/arrow/flight/FlightGrpcUtils.java Lines 126 to 141 in d25ec6a
|
|
So, if I understand correctly, you are suggesting to avoid the usage of the builder In such case, in my opinion, it is a workaround but not the best way to do that thinking on code maintenance and future updates of the library. |
|
It is more likely we will get rid of FlightBuilder than the other way around. |
|
I will try to test that approach today |
|
Hi, I still did not have the chance to test your suggestion. Nevertheless, I was looking the code. It is not only required to create a new There are few methods on that class, but I continue to think that duplicating code is not a good practice. It is clear that instantiating the object by this way will allow to configure the interceptors in the desired order. You can implement one which stores the client information on a In my opinion, it would be better to have that information through an API method, or having the option to configure the order of the interceptors. For example, allowing to define the interceptors executed prior to the flight one, and other interceptors for being executed after that. I think that is the objective of the issue apache/arrow-java#316 |
|
|
|
hey there, whats up with an issue, receiving a standard information like client ip is really scuffed right now, since you often need it at the producer level, not only on interceptor level |
|
The recommendation is still to use gRPC directly. gRPC itself only makes it available at that level, so this is no different, and there's not the maintainer bandwidth to wrap more of gRPC (hence: just use gRPC). |
|
Not quite sure, most libs and langs allow you to retrieve an adress from plain grpc calls, or propagate it from the context, but in flight, especially in Java impl, interceptors called after middlewares, so you cant really do anything with this info outside of interceptor level, maybe i am wrong, i would much appreciate if some examples will be provided |
Rationale for this change
Give access to information about the requests executing the current action to the authentication processs and middlewares.
Adding for now the client and server socket addresses.
This can be useful for checking client origin at authentication phase and to audit accesses on a custom middleware.
What changes are included in this PR?
Create the class
org.apache.arrow.flight.RequestInfofor storing the information.This
RequestInfois also available throughorg.apache.arrow.flight.CallInfo. By this way, it is available for the middlewares.Make also available
RequestInfoto theCallHeaderAuthenticator,BearerTokenAuthenticatorandServerCallHeaderAuthMiddleware.I overloaded the methods:
org.apache.arrow.flight.auth2.CallHeaderAuthenticator#authenticate(org.apache.arrow.flight.CallHeaders, org.apache.arrow.flight.RequestInfo)org.apache.arrow.flight.auth2.BearerTokenAuthenticator#validateBearer(java.lang.String, org.apache.arrow.flight.RequestInfo)with a default implementation for maintaining backward compatibility and not breaking previous implementations.
Are these changes tested?
Tested manually after generated the artifacts with the changes. For now, there are no automated tests until checking if the changes are suitable.