Skip to content

Conversation

tombentley
Copy link
Member

It's been suggested to break #71 into separate proposals to simplify review etc. This PR adds a proposal for a plugin API for runtime selection of the TLS certificate to be used on the proxy-to-server connection.

@tombentley tombentley requested a review from a team as a code owner July 25, 2025 03:50
*/
interface Context {
Optional<ClientTlsContext> clientTlsContext();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that currently there is no method for getting the ClientSaslContext proposed in #74). That's because that SASL info would be provided by a SASL terminator, which can currently only be invoked once a filter chain is instantiated, which happens after the proxy-server connection is established. So a cyclic dependency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be visible somewhere in a proposal, it's a bit tricky since it's cumulative over the proposals. Maybe just a note somewhere like:

Plugins will not be able to use the downstream SASL client identity proposed in 006 for TLS credential selection initially, because the filter are currently installed after the upstream connection is established.

edit: maybe in a Future Work section like I've commented elsewhere.

@tombentley tombentley mentioned this pull request Jul 29, 2025
*/
interface Context {
Optional<ClientTlsContext> clientTlsContext();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be visible somewhere in a proposal, it's a bit tricky since it's cumulative over the proposals. Maybe just a note somewhere like:

Plugins will not be able to use the downstream SASL client identity proposed in 006 for TLS credential selection initially, because the filter are currently installed after the upstream connection is established.

edit: maybe in a Future Work section like I've commented elsewhere.

It will use the usual Kroxylicious plugin mechanism, leveraging `java.util.Service`-based discovery.
However, this plugin is not the same thing as a `FilterFactory`.
Rather, an implementation class will be defined on the `TargetCluster` configuration object, and instantiated once for each target cluster.
The TargetCluster's `tls` object will gain a `tlsCredentialSupplier` property, supporting `type` and `config` properties (similarly to how filters are configured).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sidebar: not for this proposal. Wonder where we would put this in the operator API. In operator land KafkaService has the upstream tls details, but we can reuse a KafkaService across virtual kafka clusters. Would we put it on KafkaService, so users need multiple KafkaServices if they want different selection logic per virtual cluster. Or put it on VirtualCluster, with the downside that we spread out the upstream TLS settings across two CRs.

Copy link
Member

@k-wall k-wall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Signed-off-by: Tom Bentley <[email protected]>
Copy link
Member

@SamBarker SamBarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few references to Filter that I thought we were trying to avoid, using plugin instead, but otherwise LGTM

* @return executor
* @throws IllegalStateException if the factory is not bound to a channel yet.
*/
ScheduledExecutorService filterDispatchExecutor();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call this pluginDispatchExecutor?

Comment on lines +106 to +107
* Implemented by a {@link io.kroxylicious.proxy.filter.Filter} that provides
* the credentials for the TLS connection between the proxy and the Kafka server.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Implemented by a {@link io.kroxylicious.proxy.filter.Filter} that provides
* the credentials for the TLS connection between the proxy and the Kafka server.
* Implemented by a class annotated with {@link io.kroxylicious.proxy.plugin.Plugin} that provides
* the credentials for the TLS connection between the proxy and the Kafka server.

I don't think the intention is for filters to implement this, is it?

Copy link

@kidpollo kidpollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@robobario robobario left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @tombentley

@robobario
Copy link
Member

An update on this, @tombentley was wanting to prototype this before merging the design. He's working on other things currently, so if anyone wants to build the prototype implementation let us know.

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.

5 participants