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

Update nextUrl validation to incorporate serverBasePath #2048

Merged
merged 13 commits into from
Jul 23, 2024

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Jul 23, 2024

Description

Update nextUrl validation to incorporate the serverBasePath. All nextUrl's must be prefixed with the basePath, so this PR enhances the check by ensuring that the basePath is present in the nextUrl param.

Category

Enhancement

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.

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

codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.34%. Comparing base (2f8c6f4) to head (9ec678a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2048   +/-   ##
=======================================
  Coverage   69.34%   69.34%           
=======================================
  Files          96       96           
  Lines        2587     2587           
  Branches      382      382           
=======================================
  Hits         1794     1794           
  Misses        699      699           
  Partials       94       94           

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

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.

@DarshitChanpura DarshitChanpura added the backport 2.x backport to 2.x branch label Jul 23, 2024
@cwperks
Copy link
Member Author

cwperks commented Jul 23, 2024

Should the mutli auth routes also be validated?
https://github.com/opensearch-project/security-dashboards-plugin/blob/2.x/server/auth/types/multiple/routes.ts#L30

It only needs to be added on /login routes. It is not necessary on /auth/type. For multi-auth, the validation is delegated to the concrete auth type.

@cwperks cwperks added the backport 2.16 backport to 2.16 branch label Jul 23, 2024
@cwperks cwperks merged commit a44e265 into opensearch-project:main Jul 23, 2024
20 of 21 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 23, 2024
* Fix the nextUrl validation test and test url path using regex

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

* Update nextUrl validation regex

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

* Add missing tests

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

* Combine url split to single line

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

* Update docstring

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

* Simplify condition

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

* Add origin on redirect

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

* Remove absolute url on redirect

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

* Update login-page tests

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

* Remove url.origin

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

* Account for server base path that can be numeric

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

* Update docstring

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

---------

Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit a44e265)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 23, 2024
* Fix the nextUrl validation test and test url path using regex

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

* Update nextUrl validation regex

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

* Add missing tests

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

* Combine url split to single line

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

* Update docstring

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

* Simplify condition

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

* Add origin on redirect

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

* Remove absolute url on redirect

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

* Update login-page tests

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

* Remove url.origin

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

* Account for server base path that can be numeric

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

* Update docstring

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

---------

Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit a44e265)
cwperks added a commit that referenced this pull request Jul 23, 2024
* Fix the nextUrl validation test and test url path using regex

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

* Update nextUrl validation regex

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

* Add missing tests

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

* Combine url split to single line

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

* Update docstring

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

* Simplify condition

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

* Add origin on redirect

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

* Remove absolute url on redirect

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

* Update login-page tests

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

* Remove url.origin

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

* Account for server base path that can be numeric

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

* Update docstring

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

---------

Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit a44e265)

Co-authored-by: Craig Perkins <[email protected]>
cwperks added a commit that referenced this pull request Jul 23, 2024
* Fix the nextUrl validation test and test url path using regex

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

* Update nextUrl validation regex

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

* Add missing tests

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

* Combine url split to single line

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

* Update docstring

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

* Simplify condition

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

* Add origin on redirect

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

* Remove absolute url on redirect

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

* Update login-page tests

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

* Remove url.origin

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

* Account for server base path that can be numeric

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

* Update docstring

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

---------

Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit a44e265)

Co-authored-by: Craig Perkins <[email protected]>
@opensearch-trigger-bot
Copy link
Contributor

The backport to 1.3 failed:

The process '/usr/bin/git' failed with exit code 1

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-1.3 1.3
# Navigate to the new working tree
cd .worktrees/backport-1.3
# Create a new branch
git switch --create backport/backport-2048-to-1.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a44e26539345c17e066bc3ceb9ff1e5c07d50428
# Push it to GitHub
git push --set-upstream origin backport/backport-2048-to-1.3
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.3

Then, create a pull request where the base branch is 1.3 and the compare/head branch is backport/backport-2048-to-1.3.

cwperks added a commit to cwperks/security-dashboards-plugin that referenced this pull request Jul 25, 2024
…roject#2048)

* Fix the nextUrl validation test and test url path using regex

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

* Update nextUrl validation regex

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

* Add missing tests

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

* Combine url split to single line

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

* Update docstring

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

* Simplify condition

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

* Add origin on redirect

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

* Remove absolute url on redirect

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

* Update login-page tests

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

* Remove url.origin

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

* Account for server base path that can be numeric

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

* Update docstring

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

---------

Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit a44e265)
DarshitChanpura pushed a commit that referenced this pull request Jul 29, 2024
cwperks added a commit to cwperks/security-dashboards-plugin that referenced this pull request Aug 22, 2024
Crispy-fried-chicken added a commit to Crispy-fried-chicken/security-dashboards-plugin that referenced this pull request Aug 24, 2024
Crispy-fried-chicken added a commit to Crispy-fried-chicken/security-dashboards-plugin that referenced this pull request Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.3 backport 2.x backport to 2.x branch backport 2.16 backport to 2.16 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants