Skip to content

Commit c7e9ac7

Browse files
erikhhErik Hoogeveen
and
Erik Hoogeveen
authored
Fix for #43. Excape double quotes in credentials. (#44)
Co-authored-by: Erik Hoogeveen <erik@contactonboard.com>
1 parent dde5854 commit c7e9ac7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,19 @@ private static void handleAuthentication(AtomicReference<String> username, Atomi
6868
}
6969

7070
String value = String.format("%s required username=\"%s\" password=\"%s\";",
71-
loginModule, username.get(), password.get());
71+
loginModule, escape(username.get()), escape(password.get()));
7272
config.put(SaslConfigs.SASL_JAAS_CONFIG, value);
7373
} else if (username.get() != null) {
7474
throw new MissingConfigurationException("KAFKA_SASL_JAAS_PASSWORD");
7575
} else if (password.get() != null) {
7676
throw new MissingConfigurationException("KAFKA_SASL_JAAS_USERNAME");
7777
}
7878
}
79+
80+
private static String escape(String value) {
81+
if (value != null) {
82+
return value.replace("\"", "\\\"");
83+
}
84+
return null;
85+
}
7986
}

0 commit comments

Comments
 (0)