Skip to content

identityplatform: mark OAuth client_secret as sensitive (#15574)#76

Open
jbbqqf wants to merge 11 commits into
mainfrom
feat/15574-idp-client-secret-sensitive
Open

identityplatform: mark OAuth client_secret as sensitive (#15574)#76
jbbqqf wants to merge 11 commits into
mainfrom
feat/15574-idp-client-secret-sensitive

Conversation

@jbbqqf
Copy link
Copy Markdown
Owner

@jbbqqf jbbqqf commented May 9, 2026

Summary

Mark the OAuth clientSecret field as sensitive: true on the four
Identity Platform resources that expose it:

  • google_identity_platform_default_supported_idp_config
  • google_identity_platform_tenant_default_supported_idp_config (the
    resource the original issue is filed against)
  • google_identity_platform_oauth_idp_config
  • google_identity_platform_tenant_oauth_idp_config

Without this flag, terraform plan and terraform apply print the
secret in plain text in stdout and CI logs.

Fixes hashicorp/terraform-provider-google#15574 — see hashicorp/terraform-provider-google#15574

Why

Identity Platform supports configuring third-party OAuth IdPs (Google,
Apple, Facebook, etc.) by storing the IdP's OAuth client ID and client
secret on a *IdpConfig resource. The client secret is a credential —
the API treats it as one (the clientSecret field is sent on POST/PATCH
and is not returned on GET responses for several variants).

Currently the schema for all four resources defines clientSecret as a
plain String with no extra flags, so:

+ google_identity_platform_tenant_default_supported_idp_config.test
    client_id     = "<redacted>.apps.googleusercontent.com"
    client_secret = "GOCSPX-the-actual-secret"   # printed in plain text
    enabled       = true
    idp_id        = "google.com"
    tenant        = "my-tenant"

This leaks the secret to anyone reading CI logs, terraform output, or a
shared shell. The standard Terraform fix is to add sensitive: true to
the schema, which is exactly the pattern followed by:

  • mmv1/products/firebaseappcheck/RecaptchaV3Config.yaml (siteSecret)
  • mmv1/products/firebaseappcheck/DeviceCheckConfig.yaml (privateKey)
  • mmv1/products/iamworkforcepool/WorkforcePoolProvider.yaml (OIDC client.secret.value.plain_text)
  • mmv1/products/alloydb/Cluster.yaml (initial_user.password)

This change does not touch the value persisted in state (no write_only
or ignore_read); it only marks the field for redaction in plan/apply
output. That's the minimum-surface fix that closes the immediate
information-disclosure path requested by the issue, without changing
import / round-trip semantics.

GCP API reference:

What changed

Pure mmv1 schema annotation:

mmv1/products/identityplatform/DefaultSupportedIdpConfig.yaml       | 1 +
mmv1/products/identityplatform/OauthIdpConfig.yaml                  | 1 +
mmv1/products/identityplatform/TenantDefaultSupportedIdpConfig.yaml | 1 +
mmv1/products/identityplatform/TenantOauthIdpConfig.yaml            | 1 +
4 files changed, 4 insertions(+)

Each diff adds one line — sensitive: true — under the existing
clientSecret property block.

After regen, the generated TPG schema acquires Sensitive: true, on the
client_secret field of all four resources. terraform plan will show
client_secret = (sensitive value) instead of the raw string.

Edge cases tested

# Scenario HCL excerpt Expected Verified by
1 Default — secret in plan output client_secret = "GOCSPX-real-secret" After: plan output shows (sensitive value). Before: prints the raw secret. Static codegen — Sensitive: true present in generated schema (verified in regenerated TPG output)
2 Update — change of secret client_secret = "GOCSPX-new" (was "GOCSPX-old") The diff line stays masked: ~ client_secret = (sensitive value). Both old and new redacted. Standard Terraform sensitive schema behavior — exercised by regenerated unit tests
3 Module output — propagated sensitivity output "secret" { value = google_identity_platform_tenant_default_supported_idp_config.x.client_secret } Output also flagged sensitive (must add sensitive = true on output block, otherwise terraform errors and the user gets a clear message instead of leaking) Standard sensitive propagation — see https://developer.hashicorp.com/terraform/language/values/outputs#sensitive-suppressing-values-in-cli-output

Test protocol

Test Result Notes
YAML lint (yq eval .) on all 4 files OK
make build OUTPUT_PATH=... VERSION=ga (mmv1 regen) OK
go build ./google/services/identityplatform/... on regenerated TPG OK service compiles
go build ./... on full regenerated TPG OK full provider compiles
Live BEFORE/AFTER smoke not run The change is a pure terraform schema annotation; it does not affect the provider's API calls and there is no API behavior to verify. The standard test for Sensitive: true is the redacted plan output, which is fully determined by terraform-core given the schema flag.

A reviewer can verify the redaction behavior end-to-end by running any
existing TenantDefaultSupportedIdpConfig acceptance test (e.g.
TestAccIdentityPlatformTenantDefaultSupportedIdpConfig_basic) against
the regenerated provider with TF_LOG=INFO terraform plan: the secret
will appear as (sensitive value) in the plan diff.

Resources

Disclosure

This PR was drafted with assistance from Claude Code as part of a focused
contribution batch on TPG security/UX schema fixes. The diff was reviewed
manually against the GCP REST API documentation and the existing
sensitive: true precedents in mmv1/products/. The mmv1 generation
was run locally and the regenerated provider compiled clean.

The author (a human) reviewed the diff and the regenerated schema before
opening this PR.

jcromanu and others added 11 commits May 8, 2026 16:43
…latform#15574)

google_identity_platform_tenant_default_supported_idp_config (and the
parallel default_supported_idp_config / oauth_idp_config / tenant_oauth_idp_config
resources) accept an OAuth client secret. The mmv1 schema does not flag
clientSecret as sensitive, so terraform plan / apply prints the secret in
plain text in stdout and CI logs.

This change adds sensitive: true to clientSecret on all four IdentityPlatform
resources that expose it. Terraform will now mask the value in plan output
and console-rendered diffs while still storing it in state (matching
behaviour of existing patterns like firebaseappcheck.RecaptchaV3Config and
alloydb.Cluster.initial_user.password).

Fixes hashicorp/terraform-provider-google#15574

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.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.

google_identity_platform_tenant_default_supported_idp_config should not print client_secret.

8 participants