Skip to content
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

Fix issue when using OpenID Authentication with serverBasePath #1899

Merged
merged 48 commits into from
May 10, 2024

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Apr 18, 2024

Description

This PR fixes a bug where the security-dashboards-plugin would redirect back to / instead of /{serverBasePath} after authenticating with OpenID.

This PR also performs all SAML, OpenID and Multi-auth cypress tests both without a basePath and with a basePath

Category

Bug Fix

Issues Resolved

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

cwperks added 16 commits April 18, 2024 09:00
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Copy link

codecov bot commented Apr 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.94%. Comparing base (347f579) to head (bd82997).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1899   +/-   ##
=======================================
  Coverage   69.94%   69.94%           
=======================================
  Files          97       97           
  Lines        2505     2505           
  Branches      336      343    +7     
=======================================
  Hits         1752     1752           
  Misses        672      672           
  Partials       81       81           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

cwperks added 13 commits April 19, 2024 20:41
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Copy link
Collaborator

@derek-ho derek-ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving our testing infrastructure, base path is not something that we usually have in mind as developers, if we are using yarn start --no-base-path, but it is a real world use case. A few minor logistical comments, but otherwise looks good 👍

@peternied peternied mentioned this pull request Apr 26, 2024
23 tasks
RyanL1997
RyanL1997 previously approved these changes Apr 30, 2024
@cwperks cwperks added the backport 2.x backport to 2.x branch label May 3, 2024
Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me @cwperks. Could you please reply to/resolve the 2 open conversations?

@cwperks
Copy link
Member Author

cwperks commented May 8, 2024

@DarshitChanpura Replied to both outstanding comments. I was not able to figure out a way to reduce it to a single step. Can those be addressed in a follow-up PR?

@cwperks cwperks merged commit 9662025 into opensearch-project:main May 10, 2024
20 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 10, 2024
* Test OIDC with basePath

Signed-off-by: Craig Perkins <[email protected]>

* Run OIDC tests with basePath

Signed-off-by: Craig Perkins <[email protected]>

* Run all tests with basePath

Signed-off-by: Craig Perkins <[email protected]>

* Fix kibana url

Signed-off-by: Craig Perkins <[email protected]>

* Remove requirement on nextUrl

Signed-off-by: Craig Perkins <[email protected]>

* Remove duplicate

Signed-off-by: Craig Perkins <[email protected]>

* Add basePath to acs endpoint

Signed-off-by: Craig Perkins <[email protected]>

* Update snapshot

Signed-off-by: Craig Perkins <[email protected]>

* Start IdP where acs contains the basePath

Signed-off-by: Craig Perkins <[email protected]>

* es:lint --fix

Signed-off-by: Craig Perkins <[email protected]>

* Generalize SAML tests to include basePath

Signed-off-by: Craig Perkins <[email protected]>

* Add default

Signed-off-by: Craig Perkins <[email protected]>

* Use -z

Signed-off-by: Craig Perkins <[email protected]>

* Cypress env

Signed-off-by: Craig Perkins <[email protected]>

* Cypress env

Signed-off-by: Craig Perkins <[email protected]>

* Handle undefined

Signed-off-by: Craig Perkins <[email protected]>

* Always pass basePath

Signed-off-by: Craig Perkins <[email protected]>

* Remove ampersand

Signed-off-by: Craig Perkins <[email protected]>

* Pass basePath in yarn_command

Signed-off-by: Craig Perkins <[email protected]>

* re-add osd_base_path

Signed-off-by: Craig Perkins <[email protected]>

* Try ternary

Signed-off-by: Craig Perkins <[email protected]>

* Start with basePath

Signed-off-by: Craig Perkins <[email protected]>

* Use separate steps

Signed-off-by: Craig Perkins <[email protected]>

* Update shortenUrl

Signed-off-by: Craig Perkins <[email protected]>

* Remove basePath in acs endpoint and fix shorten URL

Signed-off-by: Craig Perkins <[email protected]>

* Comma-separated env

Signed-off-by: Craig Perkins <[email protected]>

* update oidc_auth_test.spec.js

Signed-off-by: Craig Perkins <[email protected]>

* Check cookie after login

Signed-off-by: Craig Perkins <[email protected]>

* failOnStatusCode false

Signed-off-by: Craig Perkins <[email protected]>

* mimic SAML

Signed-off-by: Craig Perkins <[email protected]>

* mimic SAML

Signed-off-by: Craig Perkins <[email protected]>

* Remove cy.origin

Signed-off-by: Craig Perkins <[email protected]>

* Add cy.origin back

Signed-off-by: Craig Perkins <[email protected]>

* Try wrapping in cy.url

Signed-off-by: Craig Perkins <[email protected]>

* Visit directly

Signed-off-by: Craig Perkins <[email protected]>

* Try localhost

Signed-off-by: Craig Perkins <[email protected]>

* Comment out test for now

Signed-off-by: Craig Perkins <[email protected]>

* Add another request after logout

Signed-off-by: Craig Perkins <[email protected]>

* Wait for logout

Signed-off-by: Craig Perkins <[email protected]>

* Small update

Signed-off-by: Craig Perkins <[email protected]>

* Add base_redirect_url

Signed-off-by: Craig Perkins <[email protected]>

* Explicitly add minimist as dev dependency

Signed-off-by: Craig Perkins <[email protected]>

---------

Signed-off-by: Craig Perkins <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
Co-authored-by: Jialiang Liang <[email protected]>
(cherry picked from commit 9662025)
DarshitChanpura pushed a commit that referenced this pull request May 10, 2024
#1946)

* Test OIDC with basePath

Signed-off-by: Craig Perkins <[email protected]>

* Run OIDC tests with basePath

Signed-off-by: Craig Perkins <[email protected]>

* Run all tests with basePath

Signed-off-by: Craig Perkins <[email protected]>

* Fix kibana url

Signed-off-by: Craig Perkins <[email protected]>

* Remove requirement on nextUrl

Signed-off-by: Craig Perkins <[email protected]>

* Remove duplicate

Signed-off-by: Craig Perkins <[email protected]>

* Add basePath to acs endpoint

Signed-off-by: Craig Perkins <[email protected]>

* Update snapshot

Signed-off-by: Craig Perkins <[email protected]>

* Start IdP where acs contains the basePath

Signed-off-by: Craig Perkins <[email protected]>

* es:lint --fix

Signed-off-by: Craig Perkins <[email protected]>

* Generalize SAML tests to include basePath

Signed-off-by: Craig Perkins <[email protected]>

* Add default

Signed-off-by: Craig Perkins <[email protected]>

* Use -z

Signed-off-by: Craig Perkins <[email protected]>

* Cypress env

Signed-off-by: Craig Perkins <[email protected]>

* Cypress env

Signed-off-by: Craig Perkins <[email protected]>

* Handle undefined

Signed-off-by: Craig Perkins <[email protected]>

* Always pass basePath

Signed-off-by: Craig Perkins <[email protected]>

* Remove ampersand

Signed-off-by: Craig Perkins <[email protected]>

* Pass basePath in yarn_command

Signed-off-by: Craig Perkins <[email protected]>

* re-add osd_base_path

Signed-off-by: Craig Perkins <[email protected]>

* Try ternary

Signed-off-by: Craig Perkins <[email protected]>

* Start with basePath

Signed-off-by: Craig Perkins <[email protected]>

* Use separate steps

Signed-off-by: Craig Perkins <[email protected]>

* Update shortenUrl

Signed-off-by: Craig Perkins <[email protected]>

* Remove basePath in acs endpoint and fix shorten URL

Signed-off-by: Craig Perkins <[email protected]>

* Comma-separated env

Signed-off-by: Craig Perkins <[email protected]>

* update oidc_auth_test.spec.js

Signed-off-by: Craig Perkins <[email protected]>

* Check cookie after login

Signed-off-by: Craig Perkins <[email protected]>

* failOnStatusCode false

Signed-off-by: Craig Perkins <[email protected]>

* mimic SAML

Signed-off-by: Craig Perkins <[email protected]>

* mimic SAML

Signed-off-by: Craig Perkins <[email protected]>

* Remove cy.origin

Signed-off-by: Craig Perkins <[email protected]>

* Add cy.origin back

Signed-off-by: Craig Perkins <[email protected]>

* Try wrapping in cy.url

Signed-off-by: Craig Perkins <[email protected]>

* Visit directly

Signed-off-by: Craig Perkins <[email protected]>

* Try localhost

Signed-off-by: Craig Perkins <[email protected]>

* Comment out test for now

Signed-off-by: Craig Perkins <[email protected]>

* Add another request after logout

Signed-off-by: Craig Perkins <[email protected]>

* Wait for logout

Signed-off-by: Craig Perkins <[email protected]>

* Small update

Signed-off-by: Craig Perkins <[email protected]>

* Add base_redirect_url

Signed-off-by: Craig Perkins <[email protected]>

* Explicitly add minimist as dev dependency

Signed-off-by: Craig Perkins <[email protected]>

---------

Signed-off-by: Craig Perkins <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
Co-authored-by: Jialiang Liang <[email protected]>
(cherry picked from commit 9662025)

Co-authored-by: Craig Perkins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants