-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Convert RestWrapper to an explicit Interceptor #104291
Conversation
Adds a new `RestInterceptor` interface and converts `RestServerActionPlugin.getRestHandlerInterceptor` to return this new type instead of a wrapping function. This has the following benefits: - Less object creation, there is 1 instance of the interceptor class (see `SecurityRestFilter`) rather than an instance per handler - More control over the sequence of steps in processing a request. The explicit interceptor separates it from the deprecation handler or any validation that might be needed, and the controller can be intentional about the order in which these operations are applied.
@elasticmachine update branch |
I'm happy enough with this as a point along the journey, but it's not in the final state. What it has:
What is missing
I'm happy for either:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with this as a first step. I think @jakelandis should take a quick look at the security side, but otherwise I will merge this PR and open some followups.
try { | ||
sendFailure(finalChannel, e); | ||
} catch (IOException ex) { | ||
logger.info("Failed to send error [{}] to HTTP client", ex.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to log the error that we failed to send, not the ioexception that the http channel spit back (or probably both)?
only had limited time and couldn't get into the details. ++ to the general direction. I never really liked that the OperatorOnlyRegistry handles sending the response on channel ... as alluded to in the comment, with this change I think we could refactor operator privs to not do that (and just throw an exception) and in turn (i think) would no longer need the new API to expose the boolean as part of the listener contract (which is kinda awkward). |
Pinging @elastic/es-core-infra (Team:Core/Infra) |
This commit changs `OperatorOnlyRegistry.checkRest` to handle failures via an exception rather than a return value and the use of a channel This fits better into the way that the `SecurityRestFilter` works (since elastic#104291) with a dedicated `RestInterceptor` interface
This commit changs `OperatorOnlyRegistry.checkRest` to handle failures via an exception rather than a return value and the use of a channel This fits better into the way that the `SecurityRestFilter` works (since #104291) with a dedicated `RestInterceptor` interface
Adds a new
RestInterceptor
interface and convertsRestServerActionPlugin.getRestHandlerInterceptor
to return this new type instead of a wrapping function.This has the following benefits:
SecurityRestFilter
) rather than an instance per handler