-
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
Add centralized request service #4831
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Desvelao
reviewed
Nov 9, 2022
Desvelao
reviewed
Nov 9, 2022
Desvelao
reviewed
Nov 9, 2022
AlexRuiz7
changed the title
Feature/create centralized request service
Add centralized request service
Nov 9, 2022
Desvelao
reviewed
Nov 10, 2022
Update
|
|
Desvelao
approved these changes
Nov 11, 2022
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.
review:
✔️ code review
✔️ tests for Kibana 7.10.2
- ✔️ X-Pack
- ✔️ ODFE
yenienserrano
approved these changes
Nov 11, 2022
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.
CR: ✔️
tests for Kibana 7.10.2: ✔️
3 tasks
github-actions bot
pushed a commit
that referenced
this pull request
Nov 14, 2022
* create request handler * Add interceptor initialization to app mount * Implement request handling service * Add request disabling to server * Modify changelog * Use core plugin as parameter * Move services to public * Remove service from backend * Modify imports of the service * Add validation for unauthorized requests * Improve code quality * Remove duplicated logic * Add reload on unauthorized requests * Change when check-wazuh is executed * Remove unnecessary verifications * Improve code quality * fix: condition on request service and replace http status code by constant * fix: remove unused import * fix: default value of parameter in request service Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com> Co-authored-by: Antonio David Gutiérrez <antonio.gutierrez@wazuh.com> (cherry picked from commit 99fbab1)
github-actions bot
pushed a commit
that referenced
this pull request
Nov 14, 2022
* create request handler * Add interceptor initialization to app mount * Implement request handling service * Add request disabling to server * Modify changelog * Use core plugin as parameter * Move services to public * Remove service from backend * Modify imports of the service * Add validation for unauthorized requests * Improve code quality * Remove duplicated logic * Add reload on unauthorized requests * Change when check-wazuh is executed * Remove unnecessary verifications * Improve code quality * fix: condition on request service and replace http status code by constant * fix: remove unused import * fix: default value of parameter in request service Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com> Co-authored-by: Antonio David Gutiérrez <antonio.gutierrez@wazuh.com> (cherry picked from commit 99fbab1)
9 tasks
11 tasks
Tostti
added a commit
that referenced
this pull request
Nov 17, 2022
* Add centralized request service (#4831) * create request handler * Add interceptor initialization to app mount * Implement request handling service * Add request disabling to server * Modify changelog * Use core plugin as parameter * Move services to public * Remove service from backend * Modify imports of the service * Add validation for unauthorized requests * Improve code quality * Remove duplicated logic * Add reload on unauthorized requests * Change when check-wazuh is executed * Remove unnecessary verifications * Improve code quality * fix: condition on request service and replace http status code by constant * fix: remove unused import * fix: default value of parameter in request service Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com> Co-authored-by: Antonio David Gutiérrez <antonio.gutierrez@wazuh.com> (cherry picked from commit 99fbab1) * Added unregister and request interceptor Co-authored-by: Nico Guevara <42900763+Tostti@users.noreply.github.com> Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com> Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com>
Tostti
added a commit
that referenced
this pull request
Nov 17, 2022
* Add centralized request service (#4831) * create request handler * Add interceptor initialization to app mount * Implement request handling service * Add request disabling to server * Modify changelog * Use core plugin as parameter * Move services to public * Remove service from backend * Modify imports of the service * Add validation for unauthorized requests * Improve code quality * Remove duplicated logic * Add reload on unauthorized requests * Change when check-wazuh is executed * Remove unnecessary verifications * Improve code quality * fix: condition on request service and replace http status code by constant * fix: remove unused import * fix: default value of parameter in request service Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com> Co-authored-by: Antonio David Gutiérrez <antonio.gutierrez@wazuh.com> (cherry picked from commit 99fbab1) * Added unregister and request interceptor Co-authored-by: Nico Guevara <42900763+Tostti@users.noreply.github.com> Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com> Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com>
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR creates a centralized request service for the plugin
Issues Resolved
#4757
Service description
The created service has validators that disable the possibility to make new requests if a
401
was received due to an expired session. It contains an async function named request, that can be called from different places in the code, and also a function named initializeInterceptor, which must be called at the plugin's start in order to define the interceptor.The request function validates if it is possible to make requests, and in that case make the requests with
axios
. It 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.This PR also modifies the lifecycle of the initialization of the plugin:
Manual testing
Main PR
XPACK
Scenario: Log in to an environment with Xpack
When the Wazuh app is opened
Then it should open without crashing
Scenario: Log in to an environment with Xpack
When the user navigates in the Wazuh APP
It should not crash
Scenario: Log in to an environment with Xpack, and navigate to the Wazuh API Console and manually delete the
sid
cookie to emulate a session expiredWhen the user makes a request to
GET /
Then it should be redirected to the login page
Scenario: Log in to an environment with Xpack with a user without Wazuh enabled
When the sidebar is opened
Then the Wazuh app should not be shown
Without XPACK
Before these tests, is recommended to modify the
kibana.yml
file and add the following line:opendistro_security.session.ttl: 15000
That will make the session to be closed after 15 seconds of inactivity automatically
Scenario: Log in to an environment and open the Wazuh APP before the session expires
When the Wazuh app is opened
Then it should open without crashing
Scenario: Log in to an environment, open the Wazuh APP before the session expires, and navigate inside the app
When the user navigates in the Wazuh APP
It should not crash
Scenario: Log in to an environment, open the Wazuh APP after the session expires
When the Wazuh app is opened
It should redirect to the login
Scenario: Log in to an environment, open the Wazuh APP before the session expires, wait until the session expires and navigate inside the app
When the user navigates in the Wazuh APP
It should redirect to the login page
Scenario: Log in to an environment with a user without Wazuh enabled
When the sidebar is opened
Then the Wazuh app should not be shown
Backport 7.16
Same as main PR
Backport 2.3-wzd
Before these tests, is recommended to modify the
opensearch_dashboards.yml
file and add the following line:opensearch_security.session.ttl: 15000
That will make the session to be closed after 15 seconds of inactivity automatically
Without SAML
Scenario: Log in to an environment and open the Wazuh APP before the session expires
When the Wazuh app is opened
Then it should open without crashing
Scenario: Log in to an environment, open the Wazuh APP before the session expires, and navigate inside the app
When the user navigates in the Wazuh APP
It should not crash
Scenario: Log in to an environment, open the Wazuh APP after the session expires
When the Wazuh app is opened
It should redirect to the login
Scenario: Log in to an environment, open the Wazuh APP before the session expires, wait until the session expires, and navigate inside the app
When the user navigates in the Wazuh APP
It should redirect to the login page
Scenario: Log in to an environment with a user without Wazuh enabled
When the sidebar is opened
Then the Wazuh app should not be shown
With SAML
Scenario: Log in to an environment with SAML and open the Wazuh APP before the session expires
When the Wazuh app is opened
Then it should open without crashing
Scenario: Log in to an environment with SAML, open the Wazuh APP before the session expires, and navigate inside the app
When the user navigates in the Wazuh APP
It should not crash
Scenario: Log in to an environment with SAML, open the Wazuh APP after the session expires
When the Wazuh app is opened
It should redirect to the IDP login
Scenario: Log in to an environment with SAML, open the Wazuh APP before the session expires, wait until the session expires, and navigate inside the app
When the user navigates in the Wazuh APP
It should redirect to the IDP login
Scenario: Log in to an environment with SAML with a user without Wazuh enabled
When the sidebar is opened
Then the Wazuh app should not be shown
Check List
yarn test:jest