Skip to content

fix: disable /loaduser [Backport release/0.4.z]#980

Merged
carlosthe19916 merged 1 commit intorelease/0.4.zfrom
backport-975-to-release/0.4.z
Apr 10, 2026
Merged

fix: disable /loaduser [Backport release/0.4.z]#980
carlosthe19916 merged 1 commit intorelease/0.4.zfrom
backport-975-to-release/0.4.z

Conversation

@trustify-ci-bot
Copy link
Copy Markdown
Contributor

@trustify-ci-bot trustify-ci-bot bot commented Apr 9, 2026

Description

Backport of #975 to release/0.4.z.

Summary by Sourcery

Make OIDC user info loading configurable via an environment variable and propagate it through the UI configuration.

New Features:

  • Introduce an OIDC_LOAD_USER environment flag to control whether the OIDC client calls the /loaduser endpoint during authentication.

Bug Fixes:

  • Allow disabling OIDC user info loading to avoid calling the /loaduser endpoint when necessary.

Enhancements:

  • Wire the new OIDC_LOAD_USER flag through the shared environment builder, frontend OIDC settings, and backend UI configuration struct.

Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
(cherry picked from commit 2007d2c)
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Apr 9, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Backports a configuration-driven toggle to disable the OIDC /loaduser call by introducing a new OIDC_LOAD_USER env/config parameter, wiring it through the Rust UI config, shared environment builder, and client OIDC settings so that loadUserInfo can be turned off without code changes.

Sequence diagram for conditional OIDC loadUserInfo call

sequenceDiagram
  actor User
  participant Browser
  participant Config
  participant OIDCProvider

  User->>Browser: Initiate login
  Browser->>Config: Read OIDC_LOAD_USER
  Config-->>Browser: OIDC_LOAD_USER value

  Browser->>OIDCProvider: Authorization request (response_type=code)
  OIDCProvider-->>Browser: Authorization code
  Browser->>OIDCProvider: Token request (code)
  OIDCProvider-->>Browser: ID token and access token

  alt OIDC_LOAD_USER is true
    Browser->>OIDCProvider: /userinfo (loadUserInfo)
    OIDCProvider-->>Browser: User profile
  else OIDC_LOAD_USER is false
    Browser--xOIDCProvider: Skip /userinfo call
  end
Loading

Class diagram for OIDC_LOAD_USER configuration flow

classDiagram
  class TrustificationEnvType {
    +string? OIDC_SERVER_URL
    +string? OIDC_SERVER_EMBEDDED_PATH
    +string? OIDC_CLIENT_ID
    +string? OIDC_SCOPE
    +string? OIDC_LOAD_USER
  }

  class BuildTrustificationEnv {
    +buildTrustificationEnv(AUTH_REQUIRED, OIDC_CLIENT_ID, OIDC_SCOPE, OIDC_LOAD_USER, UI_INGRESS_PROXY_BODY_SIZE, TRUSTIFY_API_URL, OIDC_SERVER_URL, OIDC_SERVER_IS_EMBEDDED, OIDC_SERVER_EMBEDDED_PATH) TrustificationEnvType
  }

  class UI {
    +string oidc_scope
    +string oidc_load_user
  }

  class OidcModule {
    +string OIDC_SERVER_URL
    +string OIDC_CLIENT_ID
    +boolean OIDC_LOAD_USER
  }

  class OidcClientSettings {
    +string authority
    +string client_id
    +string redirect_uri
    +string post_logout_redirect_uri
    +string response_type
    +boolean loadUserInfo
    +string scope
  }

  BuildTrustificationEnv ..> TrustificationEnvType : constructs
  UI ..> TrustificationEnvType : serializes_to_env
  OidcModule ..> TrustificationEnvType : reads_from_ENV
  OidcClientSettings ..> OidcModule : uses
  OidcClientSettings : loadUserInfo = OIDC_LOAD_USER
Loading

File-Level Changes

Change Details Files
Add OIDC_LOAD_USER as a configurable environment flag and propagate it through the shared environment builder and Rust UI config.
  • Extend TrustificationEnvType with an optional OIDC_LOAD_USER flag constrained to string literal values "true" or "false".
  • Update buildTrustificationEnv to accept OIDC_LOAD_USER, defaulting it to "true", and include it in the constructed environment object.
  • Add oidc_load_user field to the Rust UI struct, serialized as OIDC_LOAD_USER, to expose the flag to the frontend build.
common/src/environment.ts
crate/src/lib.rs
Use the OIDC_LOAD_USER flag to control whether the OIDC client loads user info from the /loaduser endpoint.
  • Add OIDC_LOAD_USER constant in the frontend that interprets ENV.OIDC_LOAD_USER as a boolean (true only when the string equals "true").
  • Change oidcClientSettings.loadUserInfo from a hard-coded true to the configurable OIDC_LOAD_USER flag so the behavior can be toggled via configuration.
client/src/app/oidc.ts

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:

  • The frontend currently defaults OIDC_LOAD_USER to false when the env var is missing (ENV.OIDC_LOAD_USER === "true"), which changes behavior if an older backend doesn’t provide the variable; consider defaulting to true (e.g. ENV.OIDC_LOAD_USER !== "false") to preserve existing behavior unless explicitly disabled.
  • On the Rust side, oidc_load_user is modeled as a String; consider using a bool with appropriate serde handling to avoid accidentally accepting invalid values and to better reflect the intended semantics.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The frontend currently defaults `OIDC_LOAD_USER` to `false` when the env var is missing (ENV.OIDC_LOAD_USER === "true"), which changes behavior if an older backend doesn’t provide the variable; consider defaulting to `true` (e.g. `ENV.OIDC_LOAD_USER !== "false"`) to preserve existing behavior unless explicitly disabled.
- On the Rust side, `oidc_load_user` is modeled as a `String`; consider using a `bool` with appropriate serde handling to avoid accidentally accepting invalid values and to better reflect the intended semantics.

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.

@carlosthe19916 carlosthe19916 merged commit 67ed2f4 into release/0.4.z Apr 10, 2026
8 checks passed
@github-project-automation github-project-automation bot moved this to Done in Trustify Apr 10, 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.

1 participant