Skip to content

fix: configurable oauth scope instead of hardcoded 'openid' scope [Backport release/0.6.z] - #2573

Merged
Strum355 merged 1 commit into
release/0.6.zfrom
backport-2566-to-release/0.6.z
Aug 12, 2026
Merged

fix: configurable oauth scope instead of hardcoded 'openid' scope [Backport release/0.6.z]#2573
Strum355 merged 1 commit into
release/0.6.zfrom
backport-2566-to-release/0.6.z

Conversation

@trustify-ci-bot

@trustify-ci-bot trustify-ci-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

Description

Backport of #2566 to release/0.6.z.

Summary by Sourcery

Make OAuth scopes for OIDC client-credentials flows configurable instead of hardcoded, propagating them from CLI arguments through configuration into the token provider.

New Features:

  • Add optional CLI and environment-configurable OAuth scope parameter for exploit intelligence OIDC client-credentials token requests.
  • Add optional CLI and environment-configurable OAuth scope parameter for the generic OpenID token provider used in client-credentials flows.

Enhancements:

  • Extend OIDC configuration and provider structures to carry an optional scope value and use it when requesting and refreshing tokens instead of a fixed "openid" scope.

Tests:

  • Update and add tests to cover default behavior with no scope set and propagation of configured scopes through to the OIDC provider config.

@sourcery-ai

sourcery-ai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Make OAuth/OIDC scopes configurable instead of hardcoded, wiring a new optional scope argument through CLI/env configuration, OIDC configs, and token provider behavior (including tests).

Sequence diagram for token requests with configurable scope

sequenceDiagram
    participant Args as OpenIdTokenProviderConfigArguments
    participant Config as OpenIdTokenProviderConfig
    participant Provider as OpenIdTokenProvider
    participant Client as openid::Client

    Args->>Config: into_config()
    Config-->>Config: scope: Option<String>
    Config->>Provider: from_config(config)
    Provider-->>Provider: new(client, refresh_before, config.scope)

    alt initial token
        Provider->>Client: request_token_using_client_credentials(Provider.scope.as_deref())
        Client-->>Provider: TemporalBearerGuard
    else refresh with refresh_token
        Provider->>Client: refresh_token(current_token, Provider.scope.as_deref())
        Client-->>Provider: TemporalBearerGuard
    end
Loading

File-Level Changes

Change Details Files
Add configurable OAuth/OIDC scope to EiOidc and OpenId token provider CLI/env configuration and propagate it into the runtime config objects.
  • Introduce an optional scope field on EiOidcArguments with CLI flag and environment variable wiring.
  • Introduce an optional scope field on OpenIdTokenProviderConfigArguments with CLI flag and environment variable wiring.
  • Extend EiOidcArguments::into_config and OpenIdTokenProviderConfig::from_arguments to carry the scope option into their respective config structs.
  • Add scope defaults (None) to dev-mode/config constructors.
server/src/profile/api.rs
common/auth/src/client/provider/openid.rs
Update OpenId token provider to store the configured scope and use it when requesting and refreshing tokens instead of the previously hardcoded "openid" scope.
  • Extend OpenIdTokenProvider struct to hold an optional scope and propagate it through the constructors.
  • Change initial_token to pass the configured scope to request_token_using_client_credentials instead of a fixed "openid" scope.
  • Change refresh_token calls to pass through the configured scope when present.
  • Update Debug implementation implicitly via the new field (derive-based) and ensure construction via OpenIdTokenProvider::from_config passes scope.
common/auth/src/client/provider/openid.rs
Extend tests to cover propagation and defaulting behavior of the new scope configuration for EiOidc arguments and OpenId token provider config.
  • Update existing EiOidc tests to assert scope is None when not provided.
  • Add a new test that verifies EiOidcArguments::into_config correctly propagates a multi-scope value string.
  • Ensure dev-mode and argument-based OpenIdTokenProviderConfig constructors set scope to None, maintaining backward-compatible defaults.
server/src/profile/api.rs
common/auth/src/client/provider/openid.rs

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


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.

@Strum355
Strum355 merged commit e2dab25 into release/0.6.z Aug 12, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Trustify Aug 12, 2026
@Strum355
Strum355 deleted the backport-2566-to-release/0.6.z branch August 12, 2026 18:14
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