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