Skip to content

Add insecure HTTP OIDC support for local development - #2292

Merged
JAORMX merged 5 commits into
mainfrom
add-insecure-http-oidc-support
Oct 23, 2025
Merged

JAORMX merged 5 commits into
mainfrom
add-insecure-http-oidc-support

Conversation

@JAORMX

@JAORMX JAORMX commented Oct 22, 2025

Copy link
Copy Markdown
Collaborator

Summary

Adds insecureAllowHTTP configuration option to allow HTTP (non-HTTPS) OIDC issuers for local development and testing scenarios with MCPRemoteProxy.

This addresses the issue where MCPRemoteProxy requires HTTPS for OIDC issuer URLs even when jwksAllowPrivateIP: true is set, making local development with tools like Keycloak difficult.

Changes

  • Add InsecureAllowHTTP bool field to InlineOIDCConfig CRD type with +kubebuilder:default=false
  • Update OIDC resolver to extract and propagate flag through kubernetes, configMap, and inline config types
  • Add ValidateEndpointURLWithInsecure() function for conditional URL scheme validation
  • Update DiscoverOIDCEndpointsInsecure() to allow HTTP URLs when flag is enabled
  • Add security warning logs when insecure mode is active
  • Update WithOIDCConfig() function signature to include insecureAllowHTTP parameter
  • Update all call sites across operator, CLI, proxyrunner, and API
  • Preserve CA certificate, auth token, and private IP support
  • Update all test files to pass the new parameter
  • Add nolint comment for pre-existing complexity issue

Security Considerations

  • Default: false (HTTPS required) - secure by default
  • Opt-in: Must be explicitly enabled
  • Clear warnings: Field name and docs explicitly mark this as insecure
  • Logging: Warning message logged when enabled
  • Scope: Only affects OIDC issuer URL validation, not token transmission

Example Configuration

apiVersion: toolhive.stacklok.dev/v1alpha1
kind: MCPServer
metadata:
  name: example
spec:
  oidcConfig:
    type: inline
    inline:
      issuer: http://localhost:8080/realms/toolhive
      jwksAllowPrivateIP: true
      insecureAllowHTTP: true  # New field for local development only

Testing

  • ✅ All unit tests pass
  • ✅ Linter passes (0 issues)
  • ✅ Build succeeds
  • ✅ Backward compatibility verified - all existing functionality preserved
  • ✅ All function call sites updated (4 locations)

Backward Compatibility

This change is fully backward compatible:

  • New field is optional with omitempty JSON tag
  • Defaults to false (secure behavior)
  • Existing MCPServer resources work without modification
  • Original ValidateEndpointURL() function unchanged
  • Parameter added at END of function signatures (Go best practice)

Fixes #2288

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 22, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.22222% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.61%. Comparing base (5948453) to head (5c61491).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/auth/token.go 61.11% 6 Missing and 1 partial ⚠️
pkg/networking/http_client.go 57.14% 3 Missing ⚠️
pkg/networking/utilities.go 0.00% 3 Missing ⚠️
cmd/thv-operator/pkg/controllerutil/oidc.go 0.00% 1 Missing ⚠️
pkg/auth/oauth/oidc.go 90.90% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2292   +/-   ##
=======================================
  Coverage   53.61%   53.61%           
=======================================
  Files         239      239           
  Lines       30704    30733   +29     
=======================================
+ Hits        16463    16479   +16     
- Misses      13071    13083   +12     
- Partials     1170     1171    +1     

☔ View full report in Codecov by Sentry.
📢 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.

@JAORMX
JAORMX force-pushed the add-insecure-http-oidc-support branch from c82c6ce to 3f69f22 Compare October 23, 2025 06:54
JAORMX and others added 2 commits October 23, 2025 12:08
Adds `insecureAllowHTTP` configuration option to allow HTTP (non-HTTPS)
OIDC issuers for local development and testing scenarios. This addresses
the issue where MCPRemoteProxy requires HTTPS for OIDC issuer URLs even
in local development environments with tools like Keycloak.

The new field is available in the MCPServer CRD under inline OIDC
configuration and is disabled by default for security. When enabled,
a warning is logged to alert operators of the security implications.

Changes:
- Add InsecureAllowHTTP field to InlineOIDCConfig CRD type
- Update OIDC resolver to propagate the flag through all config types
- Add ValidateEndpointURLWithInsecure() for conditional validation
- Update OIDC discovery to allow HTTP when flag is enabled
- Add security warning logs when insecure mode is active
- Preserve CA certificate and auth token support
- Update all function signatures and call sites
- Add tests and fix linting issues

Security: This flag defaults to false and is clearly marked as insecure
in all documentation and warning messages. It should only be used for
local development, testing, or trusted internal networks.

Fixes #2288

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Juan Antonio Osorio <[email protected]>
Bumps the operator-crds Helm chart version from 0.0.41 to 0.0.42 to
reflect CRD changes (addition of insecureAllowHTTP field).

Also regenerates:
- CRD API documentation (crd-api.md)
- Swagger/OpenAPI documentation for the server API
- Helm chart README with updated version badge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@JAORMX
JAORMX force-pushed the add-insecure-http-oidc-support branch from 3f69f22 to d756310 Compare October 23, 2025 09:09
blkt
blkt previously approved these changes Oct 23, 2025

@blkt blkt 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.

Minor nit, just trying to reduce the amount of dead code.

Comment thread pkg/auth/oauth/oidc.go Resolved
@jhrozek

jhrozek commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

So I said on Slack that I was using a similar approach..but different, the thing I was using was your patch, but also setting INSECURE_DISABLE_URL_VALIDATION=true to prevent the transport-level checks from being used. In your case, these changes were enough? Just checking if enabling this CRD field should also disable the transport level checks.

JAORMX and others added 2 commits October 23, 2025 12:54
This addresses PR feedback from blkt and jhrozek:

1. Remove unused DiscoverOIDCEndpointsInsecure function
   - This public API was added but never used
   - The actual functionality works through internal functions

2. Fix critical bug: propagate insecureAllowHTTP to transport layer
   - The original PR only validated URLs at the application layer
   - The HTTP transport layer (ValidatingTransport) still enforced HTTPS
   - This would cause HTTP OIDC connections to fail at runtime

Changes:
- Add InsecureAllowHTTP field to ValidatingTransport struct
- Update RoundTrip to skip HTTPS check when flag is true
- Add insecureAllowHTTP to HttpClientBuilder with WithInsecureAllowHTTP()
- Update discoverOIDCConfiguration to pass flag to HTTP client builder
- Update NewTokenValidator to pass flag when creating JWKS HTTP client

This ensures HTTP OIDC URLs are allowed at both validation AND transport
layers when the insecureAllowHTTP flag is enabled.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…HTTP

This addresses the critical gap identified by the code review agents where
the insecureAllowHTTP feature was missing from the CLI.

CLI Integration:
- Add InsecureAllowHTTP field to RunFlags struct
- Add --oidc-insecure-allow-http CLI flag with security warning
- Pass runFlags.InsecureAllowHTTP instead of hardcoded false

Test Coverage:
- Add ConfigMap test case for insecureAllowHTTP in resolver_test.go
- Add inline OIDC config test case for insecureAllowHTTP
- Add ValidatingTransport tests for InsecureAllowHTTP field
- Verify HTTP URLs work with flag enabled
- Verify HTTPS URLs still work with flag enabled

This ensures feature parity between Kubernetes operator and CLI usage,
allowing developers to use HTTP OIDC providers for local development
via both interfaces.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
blkt
blkt previously approved these changes Oct 23, 2025
Signed-off-by: Juan Antonio Osorio <[email protected]>
@JAORMX
JAORMX merged commit 7d66bc7 into main Oct 23, 2025
@JAORMX
JAORMX deleted the add-insecure-http-oidc-support branch October 23, 2025 13:01
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.

MCPRemoteProxy: Add insecure HTTP OIDC support for local development/testing

3 participants