-
Notifications
You must be signed in to change notification settings - Fork 187
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
Create centralized request handling service #4757
Comments
UpdateBeen working on the service in #4758. The files where it should be added are:
However, there may be a timing issue: this service blocks the requests once it receives a 401 unauthorized response. If requests are made with little time between them, it is possible that several requests are triggered before the blocking happens. In the next example we can see that the system blocks the requests 54ms after the first one, but there is a second request made 41ms after the initial one. This behaviour can lead to errors in some scenarios. |
UpdateAfter investigating the source code of OpenSearch and different plugins, I discovered that the plugins have access to the requests made to the server on the server's I tested the plugin for over 3 hours with the last changes and no errors or crashes were detected. |
UpdateDuring the tests, it was discovered that using |
ResearchWhile we are testing using an OpenSearch Dashboards in development mode (v2.3.0), we detected some cases where some requests from the Wazuh plugin were done between the calls of the login process. This causes the error to appear. For this case, the request was done through a client that is a wrapper of Digging the solutionDue to the nature of the Wazuh plugin to self-repair (check Wazuh API is available, existence of index patterns, redirections to health check), the plugin can do some request that interferes with the login process. Because eliminating this nature is a structural of plugin, the solution was:
TestsWe are testing this implementation and we enhanced the experience. Some successful tests:
We experienced the problem in the next cases:
Tests casesSome use cases we tried to replicate the error: Wazuh plugin
Platform
|
Merged corresponding PRs |
Related issue #4595
Description
To follow the proposed solution on issue #4595, we need to create a service that will centralize all the requests made in the application. Currently, the requests are made by different services, leading to issues.
Requirements
It should use thecore.http
functions to make the requests.Service description
The created service has an async function named request, that can be called from different places in the code. It also contains a function named initializeInterceptor, which must be called at the plugin's start in order to define the interceptor.
The request function makes requests with axios, but prevents requests from happening if a 401 is received in a Kibana/Wazuh-dashboard request (i.e. if the session is no longer valid). When that happens, it also aborts the current requests that didn't yet received a response.
The function receives an object with all the options that can be sent to axios (method, headers, url, etc). Once executed, it returns a promise. If there are no errors, it will be accepted and contain the result of the request. If there are errors, or the requests are disabled due to a previously received 401, it will be rejected and contain the a message.
Related issue
During the lifecycle of the plugin, there is a request to verify if Wazuh is enabled for the user that is made during the mount of the plugin. That request causes issues when SAML is enabled, the session has expired and the user tries to open the Wazuh App.
The solution is to verify that before the mounting of the component, and it's implemented on the same PR.
The text was updated successfully, but these errors were encountered: