Skip to content

Commit a9bd5c4

Browse files
authored
feat: SASL_SCRAM support + minor "GUI" fixes (#8)
* Add support from scram login * gui fixes
1 parent 039c512 commit a9bd5c4

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

Dockerfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
FROM openjdk:8-slim
1+
FROM openjdk:8-jre-slim
22

3-
RUN apt-get update && apt-get install -y python3 python3-pip curl
4-
5-
COPY ./build/output/kafka-gitops /usr/local/bin/kafka-gitops
3+
RUN apt-get update && apt-get --yes upgrade && \
4+
apt-get install -y python3 python3-pip curl && \
5+
rm -rf /var/lib/apt/lists/*
66

7+
COPY ./build/output/kafka-gitops /usr/local/bin/kafka-gitops

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jar {
6969
}
7070

7171
task buildExecutableJar(type: Exec) {
72-
commandLine "bash", "build.sh"
72+
commandLine "sh", "build.sh"
7373
}
7474

7575
task buildRelease(type: Zip, group: "build") {

src/main/java/com/devshawn/kafka/gitops/config/KafkaGitopsConfigLoader.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,21 @@ private static void handleDefaultConfig(Map<String, Object> config) {
5656

5757
private static void handleAuthentication(AtomicReference<String> username, AtomicReference<String> password, Map<String, Object> config) {
5858
if (username.get() != null && password.get() != null) {
59-
String value = String.format("org.apache.kafka.common.security.plain.PlainLoginModule required username=\"%s\" password=\"%s\";",
60-
username.get(), password.get());
59+
60+
// Do we need the Plain or SCRAM module?
61+
String loginModule = null;
62+
if (config.get("sasl.mechanism").equals("PLAIN")) {
63+
loginModule = "org.apache.kafka.common.security.plain.PlainLoginModule";
64+
}
65+
else if (config.get("sasl.mechanism").equals("SCRAM-SHA-256")) {
66+
loginModule = "org.apache.kafka.common.security.scram.ScramLoginModule";
67+
}
68+
else {
69+
throw new MissingConfigurationException("KAFKA_SASL_MECHANISM");
70+
}
71+
72+
String value = String.format("%s required username=\"%s\" password=\"%s\";",
73+
loginModule, username.get(), password.get());
6174
config.put("sasl.jaas.config", value);
6275
} else if (username.get() != null) {
6376
throw new MissingConfigurationException("KAFKA_SASL_JAAS_PASSWORD");

src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ private static void printAclPlan(AclPlan aclPlan) {
8686
System.out.println("\n");
8787
break;
8888
case REMOVE:
89-
System.out.println(red(String.format("+ [ACL] %s", aclPlan.getName())));
90-
System.out.println(red(String.format("\t + resource_name: %s", aclDetails.getName())));
91-
System.out.println(red(String.format("\t + resource_type: %s", aclDetails.getType())));
92-
System.out.println(red(String.format("\t + resource_pattern: %s", aclDetails.getPattern())));
93-
System.out.println(red(String.format("\t + resource_principal: %s", aclDetails.getPrincipal())));
94-
System.out.println(red(String.format("\t + host: %s", aclDetails.getHost())));
95-
System.out.println(red(String.format("\t + operation: %s", aclDetails.getOperation())));
96-
System.out.println(red(String.format("\t + permission: %s", aclDetails.getPermission())));
89+
System.out.println(red(String.format("- [ACL] %s", aclPlan.getName())));
90+
System.out.println(red(String.format("\t - resource_name: %s", aclDetails.getName())));
91+
System.out.println(red(String.format("\t - resource_type: %s", aclDetails.getType())));
92+
System.out.println(red(String.format("\t - resource_pattern: %s", aclDetails.getPattern())));
93+
System.out.println(red(String.format("\t - resource_principal: %s", aclDetails.getPrincipal())));
94+
System.out.println(red(String.format("\t - host: %s", aclDetails.getHost())));
95+
System.out.println(red(String.format("\t - operation: %s", aclDetails.getOperation())));
96+
System.out.println(red(String.format("\t - permission: %s", aclDetails.getPermission())));
9797
System.out.println("\n");
9898
break;
9999
}
@@ -152,7 +152,7 @@ private static void printLegend(PlanOverview planOverview) {
152152
}
153153

154154
if (planOverview.getRemove() > 0) {
155-
System.out.println(red(" ~ delete"));
155+
System.out.println(red(" - delete"));
156156
}
157157
System.out.println("\nThe following actions will be performed:\n");
158158

0 commit comments

Comments
 (0)