Skip to content

feat(auth): Allow ForceIntrospection, pass optional Client ID/Secret on Introspect - #3831

Open
danielmustafa wants to merge 3 commits into
googleapis:mainfrom
danielmustafa:main
Open

feat(auth): Allow ForceIntrospection, pass optional Client ID/Secret on Introspect#3831
danielmustafa wants to merge 3 commits into
googleapis:mainfrom
danielmustafa:main

Conversation

@danielmustafa

@danielmustafa danielmustafa commented Aug 15, 2026

Copy link
Copy Markdown

Description

  1. Introduces new parameter forceIntrospection. Some identity providers require introspection on access_token validation (instead of the normal JWKS validation approach). If the value is true, will treat the incoming token as opaque and perform introspection validation. This is only enabled when mcpEnabled is true.
  2. Introduces environment variables INTROSPECTION_CLIENT_ID and INTROSPECTION_CLIENT_SECRET. Some identity providers require a client id/secret to be set when performing introspection on an access token. If both environment variables are set, the logic will send Basic<client_id:client_secret> as the user/pass of the introspection request. If only one environment variable is populated, a warning log will be written.

PR Checklist

Thank you for opening a Pull Request! Before submitting your PR, there are a
few things you can do to make sure it goes smoothly:

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure you have manually reviewed the entire diff before requesting a
    review
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes #<issue_number_goes_here>

@danielmustafa
danielmustafa requested a review from a team as a code owner August 15, 2026 18:47

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a forceIntrospection configuration option to the generic authentication service, allowing tokens to be validated via the introspection endpoint even if they are JWT-shaped. It also adds support for HTTP Basic Authentication on the introspection endpoint using environment variables. Feedback on these changes suggests refining the environment variable validation logic to prevent redundant warning logs when both variables are unset, and correcting a typo in a test function name.

Comment on lines +112 to 116
if introspectionClientID == "" || introspectionClientSecret == "" {
log.Printf("WARNING: Introspection client ID or secret not set in environment variables %s and %s. Will not be used until both are set.", IntrospectionClientIDEnvVar, IntrospectionClientSecretEnvVar)
introspectionClientID = ""
introspectionClientSecret = ""
}

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.

medium

The current condition logs a warning even when both environment variables are empty (the default case). This will cause unnecessary warning logs on every startup for users who do not use introspection client authentication. We should only log a warning if exactly one of the environment variables is set.

if introspectionClientID == "" || introspectionClientSecret == "" {
		if (introspectionClientID == "") != (introspectionClientSecret == "") {
			log.Printf("WARNING: Only one of %s or %s is set. Both must be set to enable introspection client authentication.", IntrospectionClientIDEnvVar, IntrospectionClientSecretEnvVar)
		}
		introspectionClientID = ""
		introspectionClientSecret = ""
	}

Comment thread internal/auth/generic/generic_test.go Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants