@@ -188,6 +188,10 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
188
188
String jaasConfigProp1 = "com.sun.security.auth.module.JndiLoginModule required;" ;
189
189
assertThrows (IllegalArgumentException .class , () -> configurationEntry (JaasContext .Type .CLIENT , jaasConfigProp1 ));
190
190
191
+ //test LdapLoginModule is not allowed by default
192
+ String jaasConfigProp2 = "com.sun.security.auth.module.LdapLoginModule required;" ;
193
+ assertThrows (IllegalArgumentException .class , () -> configurationEntry (JaasContext .Type .CLIENT , jaasConfigProp2 ));
194
+
191
195
//test ListenerName Override
192
196
writeConfiguration (Arrays .asList (
193
197
"KafkaServer { test.LoginModuleDefault required; };" ,
@@ -196,11 +200,19 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
196
200
assertThrows (IllegalArgumentException .class , () -> JaasContext .loadServerContext (new ListenerName ("plaintext" ),
197
201
"SOME-MECHANISM" , Collections .emptyMap ()));
198
202
203
+ //test ListenerName Override
204
+ writeConfiguration (Arrays .asList (
205
+ "KafkaServer { test.LoginModuleDefault required; };" ,
206
+ "plaintext.KafkaServer { com.sun.security.auth.module.LdapLoginModule requisite; };"
207
+ ));
208
+ assertThrows (IllegalArgumentException .class , () -> JaasContext .loadServerContext (new ListenerName ("plaintext" ),
209
+ "SOME-MECHANISM" , Collections .emptyMap ()));
210
+
199
211
//test org.apache.kafka.disallowed.login.modules system property with multiple modules
200
212
System .setProperty (DISALLOWED_LOGIN_MODULES_CONFIG , " com.ibm.security.auth.module.LdapLoginModule , com.ibm.security.auth.module.Krb5LoginModule " );
201
213
202
- String jaasConfigProp2 = "com.ibm.security.auth.module.LdapLoginModule required;" ;
203
- assertThrows (IllegalArgumentException .class , () -> configurationEntry (JaasContext .Type .CLIENT , jaasConfigProp2 ));
214
+ String jaasConfigProp3 = "com.ibm.security.auth.module.LdapLoginModule required;" ;
215
+ assertThrows (IllegalArgumentException .class , () -> configurationEntry (JaasContext .Type .CLIENT , jaasConfigProp3 ));
204
216
205
217
//test ListenerName Override
206
218
writeConfiguration (Arrays .asList (
@@ -215,6 +227,7 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
215
227
System .setProperty (DISALLOWED_LOGIN_MODULES_CONFIG , "" );
216
228
217
229
checkConfiguration ("com.sun.security.auth.module.JndiLoginModule" , LoginModuleControlFlag .REQUIRED , new HashMap <>());
230
+ checkConfiguration ("com.sun.security.auth.module.LdapLoginModule" , LoginModuleControlFlag .REQUIRED , new HashMap <>());
218
231
219
232
//test ListenerName Override
220
233
writeConfiguration (Arrays .asList (
@@ -226,6 +239,17 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
226
239
assertEquals (1 , context .configurationEntries ().size ());
227
240
checkEntry (context .configurationEntries ().get (0 ), "com.sun.security.auth.module.JndiLoginModule" ,
228
241
LoginModuleControlFlag .REQUISITE , Collections .emptyMap ());
242
+
243
+ //test ListenerName Override
244
+ writeConfiguration (Arrays .asList (
245
+ "KafkaServer { com.sun.security.auth.module.LdapLoginModule required; };" ,
246
+ "plaintext.KafkaServer { com.sun.security.auth.module.LdapLoginModule requisite; };"
247
+ ));
248
+ context = JaasContext .loadServerContext (new ListenerName ("plaintext" ),
249
+ "SOME-MECHANISM" , Collections .emptyMap ());
250
+ assertEquals (1 , context .configurationEntries ().size ());
251
+ checkEntry (context .configurationEntries ().get (0 ), "com.sun.security.auth.module.LdapLoginModule" ,
252
+ LoginModuleControlFlag .REQUISITE , Collections .emptyMap ());
229
253
}
230
254
231
255
@ Test
0 commit comments