Skip to content

Wire OIDC transport flags into thv run auth middleware config - #6529

Open
7487 wants to merge 1 commit into
stacklok:mainfrom
7487:fix-oidc-middleware-flags
Open

Wire OIDC transport flags into thv run auth middleware config#6529
7487 wants to merge 1 commit into
stacklok:mainfrom
7487:fix-oidc-middleware-flags

Conversation

@7487

@7487 7487 commented Sep 7, 2026

Copy link
Copy Markdown

Summary

thv run accepts --thv-ca-bundle, --jwks-auth-token-file and --oidc-insecure-allow-http, but none of them reach the token validator. The CLI builds the OIDC config twice: WithOIDCConfig fills the deprecated top-level RunConfig.OIDCConfig with every field, while setupOIDCConfigurationcreateOIDCConfig builds the TokenValidatorConfig that WithMiddlewareFromFlags serializes into the auth middleware config. That second struct only carried AllowPrivateIP (wired in #1470), so at runtime auth.CreateMiddleware unmarshals InsecureAllowHTTP: false / CACertPath: "" / AuthTokenFile: "" and OIDC discovery against a local HTTP or private-CA issuer fails with a 401.

  • Pass runFlags.ThvCABundle, runFlags.JWKSAuthTokenFile and runFlags.InsecureAllowHTTP through setupOIDCConfiguration into createOIDCConfig, and set the corresponding TokenValidatorConfig fields there (same shape as Pass allowPrivateIP into createOIDCConfig #1470).
  • Add TestSetupOIDCConfiguration_MiddlewareFlagWiring, which runs the flags through setupOIDCConfiguration and buildRunnerConfig and asserts the serialized auth middleware parameters carry all four transport fields. It fails on main for the three fields this PR wires.

Fixes #6522

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (go test ./cmd/thv/app/)
  • E2E tests (task test-e2e)
  • Linting (golangci-lint run ./cmd/thv/app/..., go vet)
  • Manual testing (describe below)

Does this introduce a user-facing change?

Yes. thv run --thv-ca-bundle, --jwks-auth-token-file and --oidc-insecure-allow-http now take effect for the request-time token validator, so a local HTTP issuer or an issuer with a private CA can be used for thv run as documented.

🤖 Generated with Claude Code

…eware config

createOIDCConfig builds the TokenValidatorConfig that WithMiddlewareFromFlags
serializes into the auth middleware config, which is what the proxy uses at
runtime to build the token validator. It only set AllowPrivateIP, so
--thv-ca-bundle, --jwks-auth-token-file and --oidc-insecure-allow-http reached
the deprecated top-level RunConfig.OIDCConfig via WithOIDCConfig but never the
validator, and thv run could not talk to a local HTTP or private-CA issuer.

Pass the three flags through setupOIDCConfiguration into createOIDCConfig,
mirroring what stacklok#1470 did for AllowPrivateIP, and add a regression test that
checks the auth middleware parameters carry them.

Fixes stacklok#6522

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: 7487 <1042653432@qq.com>
@7487 7487 changed the title Wire CA bundle, auth token file and insecure HTTP into run OIDC middleware config Wire OIDC transport flags into thv run auth middleware config Sep 7, 2026
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.

thv run ignores --oidc-insecure-allow-http and --thv-ca-bundle — both dropped in createOIDCConfig (same as #1470)

1 participant