Skip to content

fix: Opening link for Packager or SBOMs related to Licenses in new window ignores the filter#922

Merged
stanislavsemeniuk merged 2 commits intoguacsec:mainfrom
stanislavsemeniuk:fix/search-params-clearance
Feb 16, 2026
Merged

fix: Opening link for Packager or SBOMs related to Licenses in new window ignores the filter#922
stanislavsemeniuk merged 2 commits intoguacsec:mainfrom
stanislavsemeniuk:fix/search-params-clearance

Conversation

@stanislavsemeniuk
Copy link
Copy Markdown
Collaborator

@stanislavsemeniuk stanislavsemeniuk commented Feb 10, 2026

This pr is trying to resolve this issue: https://issues.redhat.com/browse/TC-3294

The main problem was that whenever we open any url of tpa application in a new tab, in moment of initialization of an app inside OidcProvider any search params were ignored and cleared. Even when you tried to open something simple like http://localhost:3000?test=123 it ended up looking like this http://localhost:3000/.

So i added search params inside navigation inside OidcProvider.

I am not sure it this was made by accident and it is a bug or it is something that was made like this for reason but i couldn't find any possible pitfalls.

Summary by Sourcery

Bug Fixes:

  • Fix loss of URL query parameters when opening application links in a new tab and returning from OIDC authentication.

…ponent and now onSigninCallback also remembers search params from URL
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Feb 10, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Preserves and restores URL search parameters across OIDC sign-in redirects so that filters and query-based state are not lost when opening the app or specific routes in a new tab, by including the search string in url_state and navigating back using a structured location object.

Sequence diagram for OIDC sign-in redirect with preserved search params

sequenceDiagram
  actor User
  participant Browser
  participant OidcProvider
  participant AuthService
  participant IdentityProvider
  participant AppRoutes

  User->>Browser: Open /path?filter=abc in new tab
  Browser->>OidcProvider: Initialize application
  OidcProvider->>AuthService: Check isAuthenticated
  AuthService-->>OidcProvider: isAuthenticated = false
  OidcProvider->>AuthService: signinRedirect(url_state = window.location.pathname + window.location.search)
  AuthService->>IdentityProvider: Redirect to login with state containing fullPath

  User->>IdentityProvider: Authenticate
  IdentityProvider->>Browser: Redirect back with state including "/path?filter=abc"
  Browser->>OidcProvider: Initialize with callback URL

  OidcProvider->>Browser: Read window.location.search
  OidcProvider->>Browser: new URLSearchParams(window.location.search)
  OidcProvider->>Browser: Extract fullPath from state
  OidcProvider->>Browser: Split fullPath into pathname and search
  OidcProvider->>AppRoutes: navigate({ pathname, search }, { replace: true })
  AppRoutes-->>Browser: Render /path?filter=abc with filters preserved
  Browser-->>User: Show page with correct filters applied
Loading

Flow diagram for OidcProvider URL state handling

flowchart TD
  A[Start OidcProvider] --> B{isAuthenticated?}
  B -- yes --> C[Render children normally]
  B -- no --> D{isLoading or error?}
  D -- yes --> C
  D -- no --> E[Call auth.signinRedirect]
  E --> F[Set url_state = window.location.pathname + window.location.search]
  F --> G[Browser redirects to IdentityProvider]

  subgraph CallbackHandling
    H[OIDC callback received] --> I[onSigninCallback invoked]
    I --> J[Create URLSearchParams from window.location.search]
    J --> K[Read state param and split on ';']
    K --> L[Extract fullPath from state or use '/']
    L --> M{fullPath contains '?'}
    M -- yes --> N[Split fullPath into pathname and search]
    M -- no --> O[Set pathname = fullPath, search = empty]
    N --> P[Normalize search to '?query' or empty]
    O --> P
    P --> Q[AppRoutes.navigate with pathname & search, replace true]
    Q --> R[Render target route with preserved search params]
  end
Loading

File-Level Changes

Change Details Files
Preserve query string in OIDC redirect state and restore it on sign-in callback navigation.
  • Change url_state passed to signinRedirect to include both pathname and current search parameters so the full URL (path + query) is encoded in the state.
  • On OIDC sign-in callback, derive a fullPath from the stored state (falling back to '/'), then split it into pathname and search components.
  • Use AppRoutes.navigate with a location object containing pathname and correctly prefixed search string instead of navigating with only a path string.
client/src/app/components/OidcProvider.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • When reconstructing fullPath, consider using the URL API or new URL(relative, base) to parse pathname/search/hash instead of manually splitting on ?, which is brittle if query-like content ever appears in other parts of the path.
  • Since state is now used to reconstruct a full path, it would be safer to validate that the parsed pathname is a same-origin relative path (e.g., starts with / and isn’t an absolute URL) before passing it to AppRoutes.navigate to avoid any potential open-redirect style issues.
  • The current change preserves window.location.search but still drops any hash fragment; if deep-linking relies on URL hashes, you may want to include window.location.hash in url_state and restore it on onSigninCallback similarly to the search params.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When reconstructing `fullPath`, consider using the `URL` API or `new URL(relative, base)` to parse pathname/search/hash instead of manually splitting on `?`, which is brittle if query-like content ever appears in other parts of the path.
- Since `state` is now used to reconstruct a full path, it would be safer to validate that the parsed `pathname` is a same-origin relative path (e.g., starts with `/` and isn’t an absolute URL) before passing it to `AppRoutes.navigate` to avoid any potential open-redirect style issues.
- The current change preserves `window.location.search` but still drops any hash fragment; if deep-linking relies on URL hashes, you may want to include `window.location.hash` in `url_state` and restore it on `onSigninCallback` similarly to the search params.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.02%. Comparing base (56d5583) to head (d69f4cb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
client/src/app/components/OidcProvider.tsx 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #922      +/-   ##
==========================================
- Coverage   64.98%   64.02%   -0.97%     
==========================================
  Files         195      195              
  Lines        3339     3341       +2     
  Branches      751      753       +2     
==========================================
- Hits         2170     2139      -31     
- Misses        872      914      +42     
+ Partials      297      288       -9     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Collaborator

@carlosthe19916 carlosthe19916 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @stanislavsemeniuk

@carlosthe19916 carlosthe19916 changed the title Opening link for Packager or SBOMs related to Licenses in new window ignores the filter fix: Opening link for Packager or SBOMs related to Licenses in new window ignores the filter Feb 16, 2026
@stanislavsemeniuk stanislavsemeniuk added this pull request to the merge queue Feb 16, 2026
Merged via the queue into guacsec:main with commit 2712cf5 Feb 16, 2026
11 checks passed
@github-project-automation github-project-automation bot moved this to Done in Trustify Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants