Skip to content

Conversation

@MasonM
Copy link
Member

@MasonM MasonM commented Sep 29, 2025

Motivation

This updates the dev environment to allow testing the base HREF option, which is necessary for testing the fix in #14909.

Modifications

  • Previously, we used hack/update-sso-redirect-url.sh to update the SSO redirect URL when UI_SECURE is set, but that didn't account for BASE_HREF. Updating it to do so would be possible, but it gets messy because we now need to update two different ConfigMaps, not just workflow-controller-configmap:

    Instead, this removes that script and moves the logic to Makefile, where it does a global sed on the output of kustomize to replace all instances of the redirect URL. Obviously, this is rather hacky, but I couldn't think of a better way of doing this.

  • Update ui/webpack.config.js to respect ARGO_BASE_HREF and use it for both populating the <base href="..."> tag and proxying connections to the API server. This required removing the tag from ui/src/index.html, since Webpack will populate it now.

  • Update tasks.yaml to restart Webpack if webpack.config.js changes, to simplify development

Verification

Tested by running the following commands to start up the environment, then verified I can access the workflows page and login:

  1. make start UI=true
image
  1. make start UI=true PROFILE=sso BASE_HREF=/test
image
  1. make start UI_SECURE=true PROFILE=sso BASE_HREF=/test/argo-workflows
image
  1. make start UI_SECURE=true BASE_HREF=test
image

Documentation

I added a "Proxying" section to the "Running Locally" page to document this: https://argo-workflows--14894.org.readthedocs.build/en/14894/running-locally/#proxying

This updates the dev environment to allow testing the [base HREF
option](https://argo-workflows.readthedocs.io/en/stable/argo-server/#base-href),
since some users have reported issues with that
(argoproj#14668 (comment)).

Tested by running the following commands to start up the environment,
then verified I can access the workflows page and login:
1. `make start UI=true`
2. `make start UI=true PROFILE=sso BASE_HREF=/test`
3. `make start UI_SECURE=true PROFILE=sso BASE_HREF=/test/argo-workflows`
4. `make start UI_SECURE=true BASE_HREF=test`

Signed-off-by: Mason Malone <[email protected]>
@MasonM MasonM marked this pull request as ready for review September 29, 2025 02:40
MasonM added a commit to MasonM/argo-workflows that referenced this pull request Oct 5, 2025
This fixes two bugs when the [base HREF
option](https://argo-workflows.readthedocs.io/en/stable/argo-server/#base-href)
is set:
1. The "Logout" button doesn't delete the `Authorization` cookie
   properly.
2. If you visit the login page directly and click the SSO button, you'll
   be redirected to the `/workflows` page without the base HREF, which
   will likely result in a 404.

The first issue is because logging out `document.cookie = 'authorization=;Max-Age=0';`,
which means the `path` attribute defaults to `/`. However, when the base
HREF option is set, the cookie will have a different `path` attribute,
which means it won't match per [RFC 6265](https://httpwg.org/specs/rfc6265.html#sane-set-cookie-semantics).

The second issue is because the default value of the `redirect` query
parameter was hardcoded to `'/workflows'`, when it should be
`uiUrl('/workflows')`. The `uiUrl()` function handles prepending the
base HREF.

I had to do some refactoring to make this easily testable using [React
Testing
Library](https://testing-library.com/docs/react-testing-library/intro/).

Tested by following these steps:
1. Merge these changes with
   argoproj#14894
2. Run `make start UI_SECURE=true PROFILE=sso BASE_HREF=/test/argo-workflows`
3. Visit https://localhost:8080/test/argo-workflows/login
4. Click the first "Login" button
5. Click "Log in with Example" at Dex
6. Click "Grant Access"
7. Verify I'm redirected to
   https://localhost:8080/test/argo-workflows/workflows
8. Go back to https://localhost:8080/test/argo-workflows/login and click
   "Logout"
9. Verify the `Authorization` cookie is deleted

Signed-off-by: Mason Malone <[email protected]>
MasonM added a commit to MasonM/argo-workflows that referenced this pull request Oct 5, 2025
This fixes two bugs when the [base HREF
option](https://argo-workflows.readthedocs.io/en/stable/argo-server/#base-href)
is set:
1. The "Logout" button doesn't delete the `Authorization` cookie
   properly.
2. If you visit the login page directly and click the SSO button, you'll
   be redirected to the `/workflows` page without the base HREF, which
   will likely result in a 404.

The first issue is because logging out `document.cookie = 'authorization=;Max-Age=0';`,
which means the `path` attribute defaults to `/`. However, when the base
HREF option is set, the cookie will have a different `path` attribute,
which means it won't match per [RFC 6265](https://httpwg.org/specs/rfc6265.html#sane-set-cookie-semantics).

The second issue is because the default value of the `redirect` query
parameter was hardcoded to `'/workflows'`, when it should be
`uiUrl('/workflows')`. The `uiUrl()` function handles prepending the
base HREF.

I had to do some refactoring to make this easily testable using [React
Testing
Library](https://testing-library.com/docs/react-testing-library/intro/).

Tested by following these steps:
1. Merge these changes with
   argoproj#14894
2. Run `make start UI_SECURE=true PROFILE=sso BASE_HREF=/test/argo-workflows`
3. Visit https://localhost:8080/test/argo-workflows/login
4. Click the first "Login" button
5. Click "Log in with Example" at Dex
6. Click "Grant Access"
7. Verify I'm redirected to
   https://localhost:8080/test/argo-workflows/workflows
8. Go back to https://localhost:8080/test/argo-workflows/login and click
   "Logout"
9. Verify the `Authorization` cookie is deleted

Signed-off-by: Mason Malone <[email protected]>
MasonM added a commit to MasonM/argo-workflows that referenced this pull request Oct 5, 2025
This fixes two bugs when the [base HREF
option](https://argo-workflows.readthedocs.io/en/stable/argo-server/#base-href)
is set:
1. The "Logout" button doesn't delete the `Authorization` cookie
   properly.
2. If you visit the login page directly and click the SSO button, you'll
   be redirected to the `/workflows` page without the base HREF, which
   will likely result in a 404.

The first issue is because logging out `document.cookie = 'authorization=;Max-Age=0';`,
which means the `path` attribute defaults to `/`. However, when the base
HREF option is set, the cookie will have a different `path` attribute,
which means it won't match per [RFC 6265](https://httpwg.org/specs/rfc6265.html#sane-set-cookie-semantics).

The second issue is because the default value of the `redirect` query
parameter was hardcoded to `'/workflows'`, when it should be
`uiUrl('/workflows')`. The `uiUrl()` function handles prepending the
base HREF.

I had to do some refactoring to make this easily testable using [React
Testing
Library](https://testing-library.com/docs/react-testing-library/intro/).

Tested by following these steps:
1. Merge these changes with
   argoproj#14894
2. Run `make start UI_SECURE=true PROFILE=sso BASE_HREF=/test/argo-workflows`
3. Visit https://localhost:8080/test/argo-workflows/login
4. Click the first "Login" button
5. Click "Log in with Example" at Dex
6. Click "Grant Access"
7. Verify I'm redirected to
   https://localhost:8080/test/argo-workflows/workflows
8. Go back to https://localhost:8080/test/argo-workflows/login and click
   "Logout"
9. Verify the `Authorization` cookie is deleted

Signed-off-by: Mason Malone <[email protected]>
MasonM added a commit to MasonM/argo-workflows that referenced this pull request Oct 5, 2025
This fixes two bugs when the [base HREF
option](https://argo-workflows.readthedocs.io/en/stable/argo-server/#base-href)
is set:
1. The "Logout" button doesn't delete the `Authorization` cookie
   properly.
2. If you visit the login page directly and click the SSO button, you'll
   be redirected to the `/workflows` page without the base HREF, which
   will likely result in a 404.

The first issue is because logging out `document.cookie = 'authorization=;Max-Age=0';`,
which means the `path` attribute defaults to `/`. However, when the base
HREF option is set, the cookie will have a different `path` attribute,
which means it won't match per [RFC 6265](https://httpwg.org/specs/rfc6265.html#sane-set-cookie-semantics).

The second issue is because the default value of the `redirect` query
parameter was hardcoded to `'/workflows'`, when it should be
`uiUrl('/workflows')`. The `uiUrl()` function handles prepending the
base HREF.

I had to do some refactoring to make this easily testable using [React
Testing
Library](https://testing-library.com/docs/react-testing-library/intro/).

Tested by following these steps:
1. Merge these changes with
   argoproj#14894
2. Run `make start UI_SECURE=true PROFILE=sso BASE_HREF=/test/argo-workflows`
3. Visit https://localhost:8080/test/argo-workflows/login
4. Click the first "Login" button
5. Click "Log in with Example" at Dex
6. Click "Grant Access"
7. Verify I'm redirected to
   https://localhost:8080/test/argo-workflows/workflows
8. Go back to https://localhost:8080/test/argo-workflows/login and click
   "Logout"
9. Verify the `Authorization` cookie is deleted

Signed-off-by: Mason Malone <[email protected]>
@MasonM MasonM requested a review from Joibel October 6, 2025 00:12
@Joibel Joibel enabled auto-merge (squash) October 17, 2025 12:37
@Joibel
Copy link
Member

Joibel commented Oct 17, 2025

Neat, thank you. Tested locally.

@Joibel Joibel added the cherry-pick/3.7 Cherry-pick this to release-3.7 label Oct 17, 2025
@Joibel Joibel merged commit 5d75b62 into argoproj:main Oct 18, 2025
64 of 66 checks passed
@argo-cd-cherry-pick-bot
Copy link

❌ Cherry-pick failed for 3.7. Please check the workflow logs for details.

Joibel pushed a commit that referenced this pull request Oct 20, 2025
Co-authored-by: Alan Clucas <[email protected]>
(cherry picked from commit 5d75b62)

Signed-off-by: Mason Malone <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
@Joibel
Copy link
Member

Joibel commented Oct 20, 2025

@MasonM would you mind creating a cherry-pick PR for this targetting 3.7 - I believe this is needed there? I'm unsure of how to resolve login.tsx correctly and rather than guessing it felt better for you to do it.

Joibel added a commit that referenced this pull request Oct 21, 2025
… 3.7) (#14953)

Signed-off-by: Mason Malone <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Co-authored-by: Mason Malone <[email protected]>
@Joibel
Copy link
Member

Joibel commented Oct 21, 2025

@MasonM would you mind creating a cherry-pick PR for this targetting 3.7 - I believe this is needed there? I'm unsure of how to resolve login.tsx correctly and rather than guessing it felt better for you to do it.

Wrong PR to comment on, sorry.

ItielOlenick pushed a commit to ItielOlenick/argo-workflows that referenced this pull request Oct 26, 2025
Signed-off-by: Mason Malone <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Co-authored-by: Alan Clucas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/3.7 Cherry-pick this to release-3.7

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants