Skip to content

fix(runtime): HTTPClient configs now propagate to loaders + loader funcs - #48

Merged
philipaconrad merged 1 commit into
open-policy-agent:mainfrom
philipaconrad:philip/http-client-config
Aug 4, 2026
Merged

fix(runtime): HTTPClient configs now propagate to loaders + loader funcs#48
philipaconrad merged 1 commit into
open-policy-agent:mainfrom
philipaconrad:philip/http-client-config

Conversation

@philipaconrad

@philipaconrad philipaconrad commented Aug 4, 2026

Copy link
Copy Markdown
Member

What changed, and why?

An HTTPClient.Configuration passed to OPA.Runtime.init never reached the bundle loaders. The Runtime stored it, but constructed every loader with httpClientConfig: nil, so each loader fell back to the global default config.

We now propagate any provided config down to all bundle loaders, including the discovery bundler loader.

We also now support HTTP config provider closure functions, which can be used to dynamically provide a correct HTTPClient configuration or TLSConfig on each load() call. This is anticipated to make certificate rotation easier to implement for advanced users.

The HTTPClientConfigSource enum is used to select between different ways that the config should be acquired, and only the nil/fixed config cases can TLS settings be overridden by the OPA config:

  • nil (none): Config file owns TLS. credentials.client_tls builds it on top of the global default http client config.
  • .fixed(cfg): Config file owns TLS if credentials.client_tls is set. Without client_tls, the fixed config is used verbatim.
  • .tls(provider): Provider owns TLS.
  • .configuration(provider): Provider owns everything. Nothing from the OPA config is used.

Note: For services using default/bearer/oauth2 credentials the loader never consults services[_].tls, so an injected configuration is currently the only way to configure TLS for them.

How to test

  • New tests should be picked up automatically by CI.

Related Resources

@philipaconrad philipaconrad self-assigned this Aug 4, 2026
@philipaconrad philipaconrad added the enhancement New feature or request label Aug 4, 2026
An `HTTPClient.Configuration` passed to `OPA.Runtime.init` never reached
the bundle loaders. The Runtime stored it, but constructed every loader
with `httpClientConfig: nil`, so each loader fell back to the global
default config.

We now propagate any provided config down to all bundle loaders, including
the discovery bundler loader.

We also now support HTTP config provider *closure* functions, which can be
used to dynamically provide a correct HTTPClient configuration or
TLSConfig on each `load()` call. This is anticipated to make certificate
rotation easier to implement for advanced users.

The `HTTPClientConfigSource` enum is used to select between different ways
that the config should be acquired, and only the nil/fixed config cases
can TLS settings be overridden by the OPA config:

 - `nil (none)`: Config file owns TLS. `credentials.client_tls` builds it on
   top of the global default http client config.
 - `.fixed(cfg)`: Config file owns TLS if `credentials.client_tls` is set.
   Without `client_tls`, the fixed config is used verbatim.
 - `.tls(provider)`: Provider owns TLS.
 - `.configuration(provider)`: Provider owns everything. Nothing from the OPA
   config is used.

Note: For services using default/bearer/oauth2 credentials the loader
never consults `services[_].tls`, so an injected configuration is
currently the only way to configure TLS for them.

Signed-off-by: Philip Conrad <philip_conrad@apple.com>
@philipaconrad
philipaconrad force-pushed the philip/http-client-config branch from f42a111 to a756e66 Compare August 4, 2026 22:57
@philipaconrad
philipaconrad merged commit b6bfa45 into open-policy-agent:main Aug 4, 2026
8 checks passed
@philipaconrad
philipaconrad deleted the philip/http-client-config branch August 4, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant