This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Initial #9
Closed
Closed
Initial #9
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
492d71d
add a gitignore file for Java dev
chris-giblin 1cdc81e
added reference to the new modules
chris-giblin 46e039c
initial version of proxy and encryption module
chris-giblin 8ba3b15
set log level to INFO
chris-giblin e953cf2
reorg imports
chris-giblin 954d333
Add configuration by JSON file
chris-giblin 53666ec
add config by json file for proxy
chris-giblin 75da212
filter config file
chris-giblin 64afaa9
include vertx-config
chris-giblin ca28b96
add getting started document
chris-giblin b48c635
use kafka-dump-log.sh as per suggestion from Tom
chris-giblin 9bc4ed9
add debug logging, use int to count enc/dec as per suggestion by Tom
chris-giblin e63c383
Add javadoc
chris-giblin f7ad948
debug logging, r->record
chris-giblin 71e5f44
Add javadoc comments
chris-giblin 1dcd19f
remove empty implementation, will add back when ready
chris-giblin 27de901
use int to count decryptions, Fetch instantiation only during debug, …
chris-giblin c602497
revise README, link to getting started doc
chris-giblin 18a0145
add references section to overview doc
chris-giblin b38212c
correct Java version 11 -> 17
chris-giblin 204ceba
correct Java version 11 -> 17
chris-giblin 2518233
Add README for proxy
chris-giblin 6c9065a
typo
chris-giblin b7a5558
renamed start-started
chris-giblin 21d857a
renamed start-started
chris-giblin a698781
set members to 'private final'
chris-giblin afc534d
Update encmod/src/main/java/io/strimzi/kafka/topicenc/enc/CryptoUtils…
chris-giblin 3a03abb
set members to 'private'
chris-giblin 59a440f
set members to 'private'
chris-giblin 699e3ea
throw GeneralSecurityException, require non-empty IV
chris-giblin 1ae63da
throw GeneralSecurityException
chris-giblin 883b546
set members to 'private final'
chris-giblin 0198b6e
set members to 'private'
chris-giblin bdf0698
set members to 'private'
chris-giblin 2b529fa
Remove encMod and config members - not used in this class
chris-giblin 3fef8e3
set members to 'private final'
chris-giblin 76b93b7
remove unused props, dependencies
chris-giblin de167be
remove method with rx4java argument
chris-giblin d04fd37
make test methods public
chris-giblin d972b3c
refactor to allow catching of ecnryption exceptions (prep for issue 11)
chris-giblin d6fd80f
Merge branch 'main' into initial
chris-giblin df49c09
declare members as private
chris-giblin 1010d3e
add a gitignore file for Java dev
chris-giblin 10303f7
added reference to the new modules
chris-giblin e4a58f8
initial version of proxy and encryption module
chris-giblin b4d0029
set log level to INFO
chris-giblin da98df8
reorg imports
chris-giblin 3740f6b
Add configuration by JSON file
chris-giblin 3907193
add config by json file for proxy
chris-giblin daf5ba6
filter config file
chris-giblin e98791e
include vertx-config
chris-giblin c566e44
add getting started document
chris-giblin 8d552e4
use kafka-dump-log.sh as per suggestion from Tom
chris-giblin 3dddc3a
add debug logging, use int to count enc/dec as per suggestion by Tom
chris-giblin 177af2c
Add javadoc
chris-giblin 8387a22
debug logging, r->record
chris-giblin 14b3b5d
Add javadoc comments
chris-giblin 3c0ab25
remove empty implementation, will add back when ready
chris-giblin 59e6b98
use int to count decryptions, Fetch instantiation only during debug, …
chris-giblin 3a3cdbb
revise README, link to getting started doc
chris-giblin ef259e5
add references section to overview doc
chris-giblin 1a4f52d
correct Java version 11 -> 17
chris-giblin 4a634fb
correct Java version 11 -> 17
chris-giblin 2859046
Add README for proxy
chris-giblin 9543ae9
typo
chris-giblin 969f44c
renamed start-started
chris-giblin 14f5d54
renamed start-started
chris-giblin 094607d
set members to 'private final'
chris-giblin df76ba5
Update encmod/src/main/java/io/strimzi/kafka/topicenc/enc/CryptoUtils…
chris-giblin 444751a
set members to 'private'
chris-giblin 48fbd8b
set members to 'private'
chris-giblin 73f1fe7
throw GeneralSecurityException, require non-empty IV
chris-giblin c153f2a
throw GeneralSecurityException
chris-giblin 6492bb7
set members to 'private final'
chris-giblin a9c7fde
set members to 'private'
chris-giblin e3b8156
set members to 'private'
chris-giblin e23b88b
Remove encMod and config members - not used in this class
chris-giblin 9a54db3
set members to 'private final'
chris-giblin 513af0c
remove unused props, dependencies
chris-giblin edfa964
remove method with rx4java argument
chris-giblin 66b46f8
make test methods public
chris-giblin c63c3ce
refactor to allow catching of ecnryption exceptions (prep for issue 11)
chris-giblin 76617a8
add a gitignore file for Java dev
chris-giblin 17560b0
declare members as private
chris-giblin 50497f2
merge
chris-giblin eaade32
add getting started document
chris-giblin bc6d882
use kafka-dump-log.sh as per suggestion from Tom
chris-giblin b530d53
use int to count decryptions, Fetch instantiation only during debug, …
chris-giblin e65d18a
correct Java version 11 -> 17
chris-giblin 73d9256
renamed start-started
chris-giblin 41737da
Merge branch 'initial' of github.com:strimzi/topic-encryption into in…
chris-giblin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,6 @@ classes/ | |
# MacOS | ||
.DS_Store | ||
|
||
# config files | ||
vertx-proxy/src/main/resources/config.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>strimzi.io</groupId> | ||
<artifactId>common</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Getting started | ||
|
||
Requirements: | ||
- a Kafka instance, version 2.8.0 or older, which you can configure | ||
- Java 17 | ||
- Apache maven installed in your command line environment | ||
- git command | ||
|
||
|
||
The steps for getting started with this initial version of topic encryption are outlined below: | ||
1. Clone the repository and set your working path. | ||
2. Compile | ||
3. Configure the Kafka advertised address | ||
4. Configure the proxy | ||
5. Run the proxy | ||
6. Start kafka | ||
7. Run kafka clients | ||
|
||
Each of these steps is described in detail below with an example. | ||
|
||
## Scenario | ||
|
||
In the scenario to get started, all components run on the same system, `localhost`. The Kafka broker can also run remotely. The minimum requirement is that one can update the broker configuration file and restart the broker. In this example, however, we run the broker locally. | ||
|
||
The proxy will listen on port 1234 and the broker listens on its standard port 9092 as depicted below: | ||
|
||
``` | ||
Kafka client Proxy Kafka broker | ||
o------------o 1234 o------------o 9092 | ||
``` | ||
|
||
The clients are reconfigured to use port 1234 (details below). | ||
|
||
A policy to encrypt all topics with the same key, along with a test key management system (KMS) which returns a hard-coded AES key, is used. | ||
|
||
The following sections provide details for each step in running the encrypting proxy. | ||
|
||
### 1. Clone the repository and set your working path | ||
``` | ||
git clone [email protected]:strimzi/topic-encryption.git | ||
cd topic-encryption | ||
``` | ||
|
||
### 2. Compile | ||
|
||
``` | ||
mvn install | ||
``` | ||
|
||
### 3. Configure the Kafka broker's listeners | ||
The address advertised by Kafka must be that of the proxy, not the broker itself. | ||
|
||
Modify the `advertised.listeners` property in `$KAFKA_HOME/config/server.properties` to point to the proxy host and port, as shown in the snippet below: | ||
|
||
``` | ||
# The address the socket server listens on. It will get the value returned from | ||
# java.net.InetAddress.getCanonicalHostName() if not configured. | ||
# FORMAT: | ||
# listeners = listener_name://host_name:port | ||
# EXAMPLE: | ||
# listeners = PLAINTEXT://your.host.name:9092 | ||
listeners=PLAINTEXT://:9092 | ||
|
||
# Hostname and port the broker will advertise to producers and consumers. If not set, | ||
# it uses the value for "listeners" if configured. Otherwise, it will use the value | ||
# returned from java.net.InetAddress.getCanonicalHostName(). | ||
advertised.listeners=PLAINTEXT://127.0.0.1:1234 | ||
``` | ||
Stop the Kafka broker and start it after the proxy is running. | ||
|
||
### 4. Configure the proxy | ||
Set the working directory to the proxy's target folder: | ||
``` | ||
$ cd vertx-proxy/target/ | ||
``` | ||
|
||
Create a configuration file, `config.json` and add the following JSON contents: | ||
|
||
``` | ||
{ | ||
"listening_port" : 1234, | ||
"kafka_broker" : "localhost:9092", | ||
"policy_repo" : "test" | ||
} | ||
``` | ||
### 5. Run the proxy | ||
With the current path set to the target directory, run the proxy with the following Java invocation: | ||
|
||
``` | ||
$ java -cp vertx-proxy-0.0.1-SNAPSHOT-fat.jar io.strimzi.kafka.proxy.vertx.VertRunner | ||
``` | ||
|
||
If successfully started, the following output appears: | ||
``` | ||
$ java -cp vertx-proxy-0.0.1-SNAPSHOT-fat.jar io.strimzi.kafka.proxy.vertx.VertRunner | ||
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance. | ||
2022-04-13 10:30:12 INFO KafkaProxyVerticle:46 35 - Kafka version: 2.8.0 | ||
2022-04-13 10:30:12 INFO KafkaProxyVerticle:75 35 - Listening on port 1234 | ||
``` | ||
|
||
### 6. Start Kafka broker | ||
|
||
Now start the Kafka broker, for example: | ||
``` | ||
$KAFKA_HOME/bin/kafka-server-start.sh config/server.properties | ||
``` | ||
|
||
### 7. Run Kafka clients | ||
Start the Kafka console producer (note the proxy address in the broker list): | ||
|
||
``` | ||
$KAFKA_HOME/bin/kafka-console-producer.sh --broker-list localhost:1234 --topic enctest --producer.config config/producer.properties | ||
``` | ||
|
||
Start the Kafka console consumer, like the producer, specifying the proxy host and port: | ||
``` | ||
$KAFKA_HOME/bin/kafka-console-consumer.sh --bootstrap-server localhost:1234 --consumer.config config/consumer.properties --topic enctest --from-beginning | ||
``` | ||
|
||
Enter arbitry data in the producer and verify that it appears in consumer. | ||
|
||
Inspect the topic segment files and verify they indeed are encrypted. | ||
``` | ||
$KAFKA_HOME/kafka-dump-log.sh --files /tmp/kafka-logs/enctest-0/00000000000000000000.log --value-decoder-class kafka.serializer.StringDecoder | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Topic Encryption Module | ||
|
||
This component is concerned strictly with the encryption and decryption of Kafka records. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.strimzi</groupId> | ||
<artifactId>topic-encryption</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>encmod</artifactId> | ||
<name>encryption module</name> | ||
<description>desc</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.kafka</groupId> | ||
<artifactId>kafka-clients</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-slf4j-impl</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
28 changes: 28 additions & 0 deletions
28
encmod/src/main/java/io/strimzi/kafka/topicenc/EncModControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Strimzi authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.strimzi.kafka.topicenc; | ||
|
||
/** | ||
* This defines the interface to the Encryption Module to functions | ||
* controlling its internal state. So, for example, can an implementation | ||
* receiving events from a key management system (KMS), notify the module | ||
* to purge a key because it has expired. If we consider the | ||
* Encryption Module's encrypt() and decrypt() functions to comprise | ||
* the data path, this interface describes its control path. | ||
* | ||
* Currently this interface is a placeholder but will be continually | ||
* extended as the implementation matures. | ||
*/ | ||
public interface EncModControl { | ||
tombentley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Purge the key, indicated by the keyRef argument, from any | ||
* internal state such that the key in question is now longer used. | ||
* This supports key revokation. | ||
* | ||
* @param keyref A key reference, understood by the Encryption Module and its KMS, identifying the key to purge. | ||
*/ | ||
void purgeKey(String keyref); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this really be excluded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The config file could contain credentials as we integrate with key management systems. Excluding the config file, at least for the time being, is a defensive action to prevent credentials being accidentally pushed into github in the future.