Skip to content

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

Merged
aponcedeleonch merged 2 commits into
stacklok:mainfrom
7487:fix-oidc-middleware-flags
Oct 23, 2026
Merged

aponcedeleonch merged 2 commits into
stacklok:mainfrom
7487:fix-oidc-middleware-flags

Conversation

@7487

@7487 7487 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

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 setupOIDCConfiguration → createOIDCConfig 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 <[email protected]>
Signed-off-by: 7487 <[email protected]>
@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
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.00%. Comparing base (83859e4) to head (2b8d211).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6529   +/-   ##
=======================================
  Coverage   79.99%   80.00%           
=======================================
  Files         837      837           
  Lines       85205    85205           
=======================================
+ Hits        68156    68164    +8     
+ Misses      17044    17036    -8     
  Partials        5        5           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aponcedeleonch
aponcedeleonch merged commit f4f0d83 into stacklok:main Oct 23, 2026
40 checks passed
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)

2 participants