-
Notifications
You must be signed in to change notification settings - Fork 196
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 #4758
Add centralized request service #4758
Conversation
|
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.
TR: ✔️
LGTM
Attached Evidence
Test case 1)
Screencast.from.07-11-22.12.48.35.webm
Test case 2)
Screencast.from.07-11-22.12.49.45.webm
Test case 3)
Screencast.from.07-11-22.12.51.34.webm
Test case 4)
Screencast.from.07-11-22.12.52.40.webm
With @Tostti we found an error with the expire session on Open search Logout. The logout service return a 401 error when te session expires. IMG_1979.MOV |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.3-7.16 4.3-7.16
# Navigate to the new working tree
cd .worktrees/backport-4.3-7.16
# Create a new branch
git switch --create backport-4758-to-4.3-7.16
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 34c3fae84fe27d41330777996ee4b53c6d43e66f
# Push it to GitHub
git push --set-upstream origin backport-4758-to-4.3-7.16
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.3-7.16 Then, create a pull request where the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.3-1.2-wzd 4.3-1.2-wzd
# Navigate to the new working tree
cd .worktrees/backport-4.3-1.2-wzd
# Create a new branch
git switch --create backport-4758-to-4.3-1.2-wzd
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 34c3fae84fe27d41330777996ee4b53c6d43e66f
# Push it to GitHub
git push --set-upstream origin backport-4758-to-4.3-1.2-wzd
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.3-1.2-wzd Then, create a pull request where the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.4-7.16 4.4-7.16
# Navigate to the new working tree
cd .worktrees/backport-4.4-7.16
# Create a new branch
git switch --create backport-4758-to-4.4-7.16
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 34c3fae84fe27d41330777996ee4b53c6d43e66f
# Push it to GitHub
git push --set-upstream origin backport-4758-to-4.4-7.16
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.4-7.16 Then, create a pull request where the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.3-7.10 4.3-7.10
# Navigate to the new working tree
cd .worktrees/backport-4.3-7.10
# Create a new branch
git switch --create backport-4758-to-4.3-7.10
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 34c3fae84fe27d41330777996ee4b53c6d43e66f
# Push it to GitHub
git push --set-upstream origin backport-4758-to-4.3-7.10
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.3-7.10 Then, create a pull request where the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.4-7.10 4.4-7.10
# Navigate to the new working tree
cd .worktrees/backport-4.4-7.10
# Create a new branch
git switch --create backport-4758-to-4.4-7.10
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 34c3fae84fe27d41330777996ee4b53c6d43e66f
# Push it to GitHub
git push --set-upstream origin backport-4758-to-4.4-7.10
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.4-7.10 Then, create a pull request where the |
* create service * Improve service functionality * add timeout handling * Improve code quality * Fix issue that caused infinite loop * separate interceptor initialization * add interceptor to plugin start * fix double reload and add abort * Add function to disable requests externally * Add auth validation on server to disable requests * Update changelog * Add missing parameters verification * Add missing parameter validation * Add reload to interceptor * Change structure of code * Implement new service * Fix bug * Fix errors * Create unit tests * Fix bad reference to previous PR in changelog * Add missing previous change in changelog (cherry picked from commit 34c3fae)
* create service * Improve service functionality * add timeout handling * Improve code quality * Fix issue that caused infinite loop * separate interceptor initialization * add interceptor to plugin start * fix double reload and add abort * Add function to disable requests externally * Add auth validation on server to disable requests * Update changelog * Add missing parameters verification * Add missing parameter validation * Add reload to interceptor * Change structure of code * Implement new service * Fix bug * Fix errors * Create unit tests * Fix bad reference to previous PR in changelog * Add missing previous change in changelog (cherry picked from commit 34c3fae)
* create service * Improve service functionality * add timeout handling * Improve code quality * Fix issue that caused infinite loop * separate interceptor initialization * add interceptor to plugin start * fix double reload and add abort * Add function to disable requests externally * Add auth validation on server to disable requests * Update changelog * Add missing parameters verification * Add missing parameter validation * Add reload to interceptor * Change structure of code * Implement new service * Fix bug * Fix errors * Create unit tests * Fix bad reference to previous PR in changelog * Add missing previous change in changelog (cherry picked from commit 34c3fae)
* create service * Improve service functionality * add timeout handling * Improve code quality * Fix issue that caused infinite loop * separate interceptor initialization * add interceptor to plugin start * fix double reload and add abort * Add function to disable requests externally * Add auth validation on server to disable requests * Update changelog * Add missing parameters verification * Add missing parameter validation * Add reload to interceptor * Change structure of code * Implement new service * Fix bug * Fix errors * Create unit tests * Fix bad reference to previous PR in changelog * Add missing previous change in changelog (cherry picked from commit 34c3fae)
* create service * Improve service functionality * add timeout handling * Improve code quality * Fix issue that caused infinite loop * separate interceptor initialization * add interceptor to plugin start * fix double reload and add abort * Add function to disable requests externally * Add auth validation on server to disable requests * Update changelog * Add missing parameters verification * Add missing parameter validation * Add reload to interceptor * Change structure of code * Implement new service * Fix bug * Fix errors * Create unit tests * Fix bad reference to previous PR in changelog * Add missing previous change in changelog (cherry picked from commit 34c3fae)
Description
This PR creates a centralized request service for the plugin
Issues Resolved
#4757
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 receives an object with the next parameters:
Method: GET, PUT, POST, DELETE, PATCH
Headers: an object with the desired headers. Plugin platform and content type headers are not needed.
Path: the path to which the request should be made. It can include queries, and should not include the basePath.
Data: the payload of the request.
Timeout: desired timeout in ms. If it's missing or the value is 0, no timeout will be set.
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, it will be rejected and contain the error.
This function makes the request with the core.http.fetch service. If there is a 401 unauthorized response from the server, due to the session expired, it will prevent doing any other request, abort the current ones and reload the page to trigger the login process. The prevention and abortion of new requests can also be done externally with the
disableRequests
function.This PR also adds a verification on the server definition to prevent the component from making requests if the user is not authenticated. This is because on the reload/login process sometimes the plugin was initialized, a request was done and that caused the login process to be broken. There is detailed information about that on #4757
Check List
yarn test:jest
Manual testing
To test the integration of the service, an environment of OSD with SAML is required. It is recommended to add the following line to
opensearch_dashboards.yml
:opensearch_security.session.ttl: 10000
. That will make the session to be invalid after 10 seconds of inactivity (default is 1h)Scenario: Log in with SAML
Given the idle time after logging in is less than the session validity (10s in the above example)
When the Wazuh app is opened
Then it should open without crashing
Scenario: Log in with SAML
Given the idle time after logging in is more than the session validity (10s in the above example)
When the Wazuh app is opened
Then the system should revalidate the SAML session and redirect to the home page (not Wazuh)
Scenario: Log in with SAML and immediately after that open the Wazuh App
Given the idle time after opening the app is less than the session validity (10s in the above example)
When an interaction happens
Then it should work normally, with the expected behavior of that interaction.
Scenario: Log in with SAML and immediately after that open the Wazuh App
Given the idle time after opening the app is more than the session validity (10s in the above example)
When an interaction happens
Then the system should revalidate the SAML session and redirect to the home page (not Wazuh)