-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
KAFKA-17921: Support SASL_PLAINTEXT protocol with java.security.auth.login.config #17671
base: trunk
Are you sure you want to change the base?
Conversation
7490314
to
3d304c4
Compare
3d304c4
to
fd8f47b
Compare
535eedb
to
ee1d321
Compare
c8ddc37
to
e205bb8
Compare
e205bb8
to
cefdcde
Compare
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.
@FrankYang0529 thanks for this patch
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
public class JaasModule { |
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.
Is this duplicate to core JaasModule?
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.
Yes, this is duplicated. Original JaasModule is in core module. I think we can remove original one after we migrate all sasl test case to new framework. WDYT?
@@ -602,6 +630,9 @@ public void close() throws Exception { | |||
waitForAllFutures(futureEntries); | |||
futureEntries.clear(); | |||
Utils.delete(baseDirectory); | |||
if (jaasFile.isPresent()) { |
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.
Could you please use ifPresent instead?
|
||
import javax.security.auth.login.Configuration; | ||
|
||
public class JaasTestUtils { |
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.
It is already in xxx.test package, maybe we can call it JaasUtils?
public static final String KAFKA_PLAIN_ADMIN = "plain-admin"; | ||
public static final String KAFKA_PLAIN_ADMIN_PASSWORD = "plain-admin-secret"; | ||
|
||
public static File writeJaasContextsToFile(List<JaasSection> jaasSections) throws IOException { |
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.
Do we really need this object? How about using map? It is more simple
|
||
private final Map<String, String> entries; | ||
|
||
private JaasModule(String name, boolean debug, Map<String, String> entries) { |
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.
Could you please try to use record class?
configs.put(SaslConfigs.SASL_JAAS_CONFIG, | ||
String.format("org.apache.kafka.common.security.plain.PlainLoginModule required username=\"%s\" password=\"%s\";", | ||
JaasTestUtils.KAFKA_PLAIN_USER1, JaasTestUtils.KAFKA_PLAIN_USER1_PASSWORD)); | ||
try (Admin admin = clusterInstance.admin(configs)) { |
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.
Those helper should return authorized client object, right? Otherwise, developers have to configure them manually
7e4b4a6
to
c9ea0ad
Compare
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.
@FrankYang0529 thanks for this patch. two minor comments are left PTAL
assertDoesNotThrow(() -> admin.describeAcls(AclBindingFilter.ANY).values().get()); | ||
} | ||
String topic = "sasl-plaintext-topic"; | ||
Assertions.assertDoesNotThrow(() -> clusterInstance.createTopic(topic, 1, (short) 1)); |
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.
Since the APIs in question only throw runtime exceptions, there's no need to use assertDoesNotThrow
, which is typically employed to convert checked exceptions into runtime exceptions.
} | ||
|
||
// client with non-admin credentials | ||
Map<String, Object> nonAdminConfig = Map.of( |
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 helper methods of clusterInstance
should be able configure the sasl.jaas.config
automatically - that is why we add those helper to clusterInstance
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.
Hi @chia7712, thanks for the review. Yes, we already set default user to admin
, consumer
, and producer
helper function automatically. Here, we would like to test developer overrides sasl.jaas.config
with non-admin credentials. We also test overriding with unknown credential, so we can make sure the cluster instance with sasl plaintext works.
…login.config Signed-off-by: PoAn Yang <[email protected]>
c9ea0ad
to
dacb066
Compare
Support SASL_PLAINTEXT protocol in ClusterTest framework.
Committer Checklist (excluded from commit message)