Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for TLS config, OAuth credentials and setup CP integration tests #201

Merged
merged 58 commits into from
Dec 19, 2024

Conversation

rohitsanj
Copy link
Contributor

@rohitsanj rohitsanj commented Dec 3, 2024

Summary of Changes

  • Add cp-demo testcontainers, along with a script to set it up from scratch -- works locally and on CI.
  • Added make targets to start/stop cp-demo.
  • Added make targets to store/load the Docker images into/from Semaphore cache. (I noticed we weren't caching confluent-local, so I've added that too.)
  • Bring @rhauch's implementation of mTLS and OAuth credentials from Add mTLS and OAuth 2.0 support for direct connections to Kafka and SR #211 and tweaked as follows. Mutual TLS is no longer a "credentials" type, but rather a sub-field called ssl under ConnectionSpec.KafkaClusterConfig as well as ConnectionSpec.SchemaRegistryConfig. The ssl config may be set along with any credentials type (basic, apikey/secret, oauth) and can even be set in the absence of creds.
  • The field ssl holds all configs related to TLS. (h/t @flippingbits for this section)
    • It can be used to disable the usage of TLS via the boolean field enabled, in which case the sidecar uses an unencrypted but potentially authenticated channel to interact with the Kafka cluster.
    • It accepts a keystore via the field keystore, a truststore via the field truststore, and allows to disable hostname verification via the boolean field verify_hostname.
    • If ssl is set to null, the sidecar uses an encrypted channel to interact with the Kafka cluster, verifies the hostname, and does not take any custom keystore/truststore into account.

Any additional details or context that should be provided?

Follow up items:

Pull request checklist

Please check if your PR fulfills the following (if applicable):

  • Tests:
    • Added new
    • Updated existing
    • Deleted existing
  • Have you validated this change locally against a running instance of the Quarkus dev server?
    make quarkus-dev
  • Have you validated this change against a locally running native executable?
    make mvn-package-native && ./target/ide-sidecar-*-runner

@confluent-cla-assistant
Copy link

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

rhauch and others added 15 commits December 7, 2024 10:10
Resolves #125 #126

Adds preliminary support to allow Kafka and SR clients to use mTLS and OAuth 2.0 to authenticate for direct connections.

These changes have been unit tested to verify the expected client configurations are generated.

However, those expected configurations have NOT yet been tested against CCloud or CP via integration tests.
Resolves #125 #126

Adds preliminary support to allow Kafka and SR clients to use mTLS and OAuth 2.0 to authenticate for direct connections.

These changes have been unit tested to verify the expected client configurations are generated.

However, those expected configurations have NOT yet been tested against CCloud or CP via integration tests.
…s' into rohitsanj/int-test-cp

# Conflicts:
#	src/generated/resources/openapi.yaml
#	src/main/java/io/confluent/idesidecar/restapi/credentials/MutualTLSCredentials.java
# Conflicts:
#	src/main/java/io/confluent/idesidecar/restapi/messageviewer/MessageViewerContext.java
#	src/main/java/io/confluent/idesidecar/restapi/proxy/ProxyContext.java
Copy link
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

Thanks, @rohitsanj. I took a quick first pass, and wanted to share these questions/suggestions sooner than later.

Copy link
Contributor Author

@rohitsanj rohitsanj left a comment

Choose a reason for hiding this comment

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

Some notes

@rohitsanj rohitsanj changed the title [WIP] Add cp-demo testcontainer classes Add cp-demo testcontainer classes Dec 12, 2024
@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

Copy link
Contributor

@flippingbits flippingbits left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, @rohitsanj! 🎉 I have a few questions and comments. Otherwise, your PR looks good to me. I feel you're very close to being able to merge it into main.

src/generated/resources/openapi.json Outdated Show resolved Hide resolved
src/generated/resources/openapi.json Outdated Show resolved Hide resolved
.withDetail("Kafka cluster truststore path is required and may not be blank")
),
new TestInput(
"Direct spec is invalid with SSL having keystore only",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we rely on the built-in/system certs in the absence of the truststore?
AFAIK, that's how you'd use mTLS with, for instance, Confluent Cloud.

Copy link
Contributor Author

@rohitsanj rohitsanj Dec 19, 2024

Choose a reason for hiding this comment

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

Sounds good -- I'd imagine the built-in/system certs will be picked up automatically by the Java runtime without us having to configure anything.

Or would we need to use the stored Preferences to add any tls_pem_paths to the trust store?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should definitely test if that works with the native executable.

Copy link
Contributor Author

@rohitsanj rohitsanj Dec 19, 2024

Choose a reason for hiding this comment

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

Sounds good -- I've already created #235 for supporting mTLS against Confluent Cloud, so testing would be taken care of as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, I've changed the constraints to allow passing keystore options without truststore.

@rohitsanj
Copy link
Contributor Author

@flippingbits Thanks so much for the review! I've made some updates based on our offline conversation.

@rohitsanj
Copy link
Contributor Author

Seems there's quite a few branches in the ConnectionSpec validation logic that have not been covered with tests. Given how large this PR has gotten, we can add tests in a follow up PR -- #241

@sonarqube-confluent

This comment has been minimized.

@rohitsanj
Copy link
Contributor Author

The two bugs reported by Sonarqube were false positives and I've resolved them with comments.

Copy link
Contributor

@flippingbits flippingbits left a comment

Choose a reason for hiding this comment

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

Thanks for the update, @rohitsanj! This looks great. I have two more very minor comments. Otherwise, your PR looks good to me.

src/generated/resources/openapi.json Outdated Show resolved Hide resolved
src/generated/resources/openapi.json Outdated Show resolved Hide resolved
Copy link
Contributor

@flippingbits flippingbits left a comment

Choose a reason for hiding this comment

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

Thanks for the great work, @rohitsanj! LGTM, pending the results of the CI pipeline.

@sonarqube-confluent

This comment has been minimized.

@rohitsanj
Copy link
Contributor Author

For those following: @rhauch is fine with us merging this.

@sonarqube-confluent
Copy link

Failed

  • 57.90% Coverage on New Code (is less than 80.00%)

Analysis Details

8 Issues

  • Bug 0 Bugs
  • Vulnerability 0 Vulnerabilities
  • Code Smell 8 Code Smells

Coverage and Duplications

  • Coverage 57.90% Coverage (80.10% Estimated after merge)
  • Duplications No duplication information (0.60% Estimated after merge)

Project ID: ide-sidecar

View in SonarQube

@rohitsanj rohitsanj merged commit 0ed73d1 into main Dec 19, 2024
2 checks passed
@rohitsanj rohitsanj deleted the rohitsanj/int-test-cp branch December 19, 2024 23:57
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.

3 participants