Skip to content

fix: add cognito custom logout params#930

Merged
carlosthe19916 merged 2 commits intoguacsec:mainfrom
carlosthe19916:hotfix/TC-3265
Mar 4, 2026
Merged

fix: add cognito custom logout params#930
carlosthe19916 merged 2 commits intoguacsec:mainfrom
carlosthe19916:hotfix/TC-3265

Conversation

@carlosthe19916
Copy link
Copy Markdown
Collaborator

@carlosthe19916 carlosthe19916 commented Feb 23, 2026

Fixes: https://issues.redhat.com/browse/TC-3265

Summary

Added client_id and logout_uri as extraQueryParams to all signoutRedirect() calls to fix AWS Cognito logout returning HTTP 400.

Context

When using AWS Cognito as the OIDC provider, clicking "Logout" resulted in an error. The oidc-client-ts library follows the OIDC RP-Initiated Logout spec, sending id_token_hint + post_logout_redirect_uri. Keycloak understands these standard parameters, but Cognito's hosted UI predates the spec and requires its own proprietary parameters: client_id and logout_uri.

By adding both as extraQueryParams, the signout URL now contains all four parameters. Each provider reads the ones it understands and ignores the rest:

Parameter Cognito Keycloak
id_token_hint ignores uses
post_logout_redirect_uri ignores uses
client_id requires ignores
logout_uri requires ignores

Summary by Sourcery

Bug Fixes:

  • Fix logout failures with AWS Cognito by adding required client_id and logout_uri parameters to all signoutRedirect calls.

Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Feb 23, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a shared OIDC sign-out configuration that includes Cognito-specific logout query parameters and wires it into all signoutRedirect() call sites to prevent 400 errors when logging out via AWS Cognito while remaining compatible with Keycloak.

Sequence diagram for updated OIDC logout with Cognito and Keycloak

sequenceDiagram
  actor User
  participant FrontendApp
  participant OidcUserManager
  participant OIDCProviderCognito
  participant OIDCProviderKeycloak

  User->>FrontendApp: Click Logout
  FrontendApp->>OidcUserManager: signoutRedirect(oidcSignoutArgs)
  Note over FrontendApp,OidcUserManager: oidcSignoutArgs.extraQueryParams
  OidcUserManager->>OidcUserManager: Build logout URL
  OidcUserManager->>User: Redirect to logout URL

  alt Using Cognito
    User->>OIDCProviderCognito: GET /logout
    Note over OIDCProviderCognito: Reads client_id and logout_uri
    OIDCProviderCognito-->>User: 302 redirect to logout_uri
  else Using Keycloak
    User->>OIDCProviderKeycloak: GET /protocol/openid-connect/logout
    Note over OIDCProviderKeycloak: Reads id_token_hint and post_logout_redirect_uri
    OIDCProviderKeycloak-->>User: 302 redirect to post_logout_redirect_uri
  end

  User-->>FrontendApp: Returns to app after logout
Loading

File-Level Changes

Change Details Files
Introduce a shared OIDC sign-out argument object that appends Cognito-specific logout query parameters while remaining compatible with Keycloak.
  • Define oidcSignoutArgs with extraQueryParams including client_id derived from OIDC_CLIENT_ID and logout_uri derived from window.location.origin.
  • Document behavior differences between Cognito and Keycloak regarding logout parameters to justify the extraQueryParams configuration.
client/src/app/oidc.ts
Update all signoutRedirect() invocations to use the new shared OIDC sign-out arguments so logout works with Cognito in both header-initiated and interceptor-initiated flows.
  • Pass oidcSignoutArgs into userManager.signoutRedirect() in the Axios interceptor error-handling path.
  • Pass oidcSignoutArgs into auth?.signoutRedirect() in the header logout handler.
client/src/app/axios-config/apiInit.ts
client/src/app/layout/header.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:

  • Using window.location.origin at module top-level in oidcSignoutArgs can break in non-browser/SSR/test environments where window is undefined; consider deriving this lazily (inside the logout flow) or guarding with a typeof window !== 'undefined' check.
  • Hardcoding logout_uri to window.location.origin may be too coarse for deployments where the frontend is served under a sub-path; consider making the logout redirect base configurable (e.g., via env) rather than assuming the origin root.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using `window.location.origin` at module top-level in `oidcSignoutArgs` can break in non-browser/SSR/test environments where `window` is undefined; consider deriving this lazily (inside the logout flow) or guarding with a `typeof window !== 'undefined'` check.
- Hardcoding `logout_uri` to `window.location.origin` may be too coarse for deployments where the frontend is served under a sub-path; consider making the logout redirect base configurable (e.g., via env) rather than assuming the origin root.

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 23, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 65.02%. Comparing base (34337dc) to head (9c9a509).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
client/src/app/axios-config/apiInit.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #930      +/-   ##
==========================================
- Coverage   65.07%   65.02%   -0.05%     
==========================================
  Files         195      195              
  Lines        3341     3342       +1     
  Branches      753      753              
==========================================
- Hits         2174     2173       -1     
- Misses        868      872       +4     
+ Partials      299      297       -2     

☔ 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.

@carlosthe19916 carlosthe19916 added this pull request to the merge queue Mar 4, 2026
Merged via the queue into guacsec:main with commit b6b18e6 Mar 4, 2026
11 checks passed
@github-project-automation github-project-automation bot moved this to Done in Trustify Mar 4, 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