You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "gongxuanzhang (via GitHub)" <gi...@apache.org> on 2025/01/24 01:17:29 UTC

[PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

gongxuanzhang opened a new pull request, #18683:
URL: https://github.com/apache/kafka/pull/18683

   Fix https://issues.apache.org/jira/browse/KAFKA-18627 and update same test case 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627: Deprecated "org.apache.kafka.disallowed.login.modules" [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on PR #18683:
URL: https://github.com/apache/kafka/pull/18683#issuecomment-2967477364

   @chia7712 PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1947403553


##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",

Review Comment:
   OK I will write a KIP



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627: Deprecated "org.apache.kafka.disallowed.login.modules" [kafka]

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r2144142601


##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -252,6 +252,30 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
         checkEntry(context.configurationEntries().get(0), "com.sun.security.auth.module.LdapLoginModule",
                 LoginModuleControlFlag.REQUISITE, Collections.emptyMap());
     }
+    
+    @Test
+     void testAllowedLoginModulesSystemProperty() {
+
+        //  default
+        String jaasConfigProp1 = "com.ibm.security.auth.module.LdapLoginModule required;";
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+
+        String jaasConfigProp2 = "com.sun.security.auth.module.JndiLoginModule required;";
+        //  set allow dont' set not allow
+        System.setProperty(JaasUtils.ALLOWED_LOGIN_MODULES_CONFIG, "com.ibm.security.auth.module.LdapLoginModule");
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+        assertThrows(IllegalArgumentException.class, () ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp2));
+        
+        //  set allow and set not allow
+        System.setProperty(JaasUtils.DISALLOWED_LOGIN_MODULES_CONFIG, "com.ibm.security.auth.module.LdapLoginModule");
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+        assertThrows(IllegalArgumentException.class, () ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp2));
+        
+        //  don't set allow and set not allow

Review Comment:
   -> set disallowed list, but not set allowed list



##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",
+                    DISALLOWED_LOGIN_MODULES_CONFIG, ALLOWED_LOGIN_MODULES_CONFIG);
+        }
+        String loginModuleName = appConfigurationEntry.getLoginModuleName().trim();
+        String allowedProperty = System.getProperty(ALLOWED_LOGIN_MODULES_CONFIG);
+        if (allowedProperty != null) {
+            Set<String> allowedLoginModuleList = Arrays.stream(allowedProperty.split(","))
+                    .map(String::trim)
+                    .collect(Collectors.toSet());
+            if (!allowedLoginModuleList.contains(loginModuleName)) {
+                throw new IllegalArgumentException(loginModuleName + " is not allowed. Update System property '"
+                        + ALLOWED_LOGIN_MODULES_CONFIG + "' to allow " + loginModuleName);
+            }
+            return;
+        }
+        if (disallowedProperty == null) {
+            disallowedProperty = DISALLOWED_LOGIN_MODULES_DEFAULT;
+        }
+        Set<String> disallowedLoginModuleList = Arrays.stream(disallowedProperty.split(","))
                 .map(String::trim)
                 .collect(Collectors.toSet());
-        String loginModuleName = appConfigurationEntry.getLoginModuleName().trim();
         if (disallowedLoginModuleList.contains(loginModuleName)) {
             throw new IllegalArgumentException(loginModuleName + " is not allowed. Update System property '"
                     + DISALLOWED_LOGIN_MODULES_CONFIG + "' to allow " + loginModuleName);

Review Comment:
   nit: We should also add the deprecation message in this error message to tell users to change to allowList instead.



##########
clients/src/main/java/org/apache/kafka/common/security/JaasUtils.java:
##########
@@ -16,13 +16,17 @@
  */
 package org.apache.kafka.common.security;
 
+

Review Comment:
   +1



##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -252,6 +252,30 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
         checkEntry(context.configurationEntries().get(0), "com.sun.security.auth.module.LdapLoginModule",
                 LoginModuleControlFlag.REQUISITE, Collections.emptyMap());
     }
+    
+    @Test
+     void testAllowedLoginModulesSystemProperty() {
+
+        //  default
+        String jaasConfigProp1 = "com.ibm.security.auth.module.LdapLoginModule required;";
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+
+        String jaasConfigProp2 = "com.sun.security.auth.module.JndiLoginModule required;";
+        //  set allow dont' set not allow
+        System.setProperty(JaasUtils.ALLOWED_LOGIN_MODULES_CONFIG, "com.ibm.security.auth.module.LdapLoginModule");
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+        assertThrows(IllegalArgumentException.class, () ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp2));
+        
+        //  set allow and set not allow

Review Comment:
   -> set both allowed list and disallowed list



##########
docs/upgrade.html:
##########
@@ -197,6 +197,8 @@ <h5><a id="upgrade_servers_400_notable" href="#upgrade_servers_400_notable">Nota
                         </li>
                         <li>The <code>log.message.format.version</code> and <code>message.format.version</code> configs were removed.
                         </li>
+                        <li>The <code>org.apache.kafka.disallowed.login.modules</code> config was deprecated. Please use the <code>org.apache.kafka.allowed.login.modules</code> instead.
+                        </li>

Review Comment:
   We should move this to 4.2 section.



##########
clients/src/main/java/org/apache/kafka/common/security/JaasUtils.java:
##########
@@ -16,13 +16,17 @@
  */
 package org.apache.kafka.common.security;
 
+
 public final class JaasUtils {
     public static final String JAVA_LOGIN_CONFIG_PARAM = "java.security.auth.login.config";
+    @Deprecated
     public static final String DISALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.disallowed.login.modules";
+    public static final String ALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.allowed.login.modules";
     public static final String DISALLOWED_LOGIN_MODULES_DEFAULT =
             "com.sun.security.auth.module.JndiLoginModule,com.sun.security.auth.module.LdapLoginModule";
     public static final String SERVICE_NAME = "serviceName";
 
-    private JaasUtils() {}
+    private JaasUtils() {
+    }

Review Comment:
   +1



##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -224,8 +225,7 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
                 "SOME-MECHANISM", Collections.emptyMap()));
 
 
-        //Remove default value for org.apache.kafka.disallowed.login.modules
-        System.setProperty(DISALLOWED_LOGIN_MODULES_CONFIG, "");
+        // add allowed login modules

Review Comment:
   What does this change mean?



##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -252,6 +252,30 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
         checkEntry(context.configurationEntries().get(0), "com.sun.security.auth.module.LdapLoginModule",
                 LoginModuleControlFlag.REQUISITE, Collections.emptyMap());
     }
+    
+    @Test
+     void testAllowedLoginModulesSystemProperty() {
+
+        //  default
+        String jaasConfigProp1 = "com.ibm.security.auth.module.LdapLoginModule required;";
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+
+        String jaasConfigProp2 = "com.sun.security.auth.module.JndiLoginModule required;";
+        //  set allow dont' set not allow

Review Comment:
   nit: set allowed list, but not set disallowed list



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1945042910


##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",
+                    DISALLOWED_LOGIN_MODULES_CONFIG, ALLOWED_LOGIN_MODULES_CONFIG);
+        }
+        String loginModuleName = appConfigurationEntry.getLoginModuleName().trim();
+        String allowedProperty = System.getProperty(ALLOWED_LOGIN_MODULES_CONFIG);
+        if (allowedProperty != null) {

Review Comment:
   The new logic is to prioritize "allow", right?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1938735858


##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -68,11 +70,13 @@ public void tearDown() throws Exception {
 
     @Test
     public void testConfigNoOptions() throws Exception {
+        System.setProperty(ALLOWED_LOGIN_MODULES_CONFIG, "test.testConfigNoOptions");

Review Comment:
   Adding this change means we break some compatibility ... 
   
   1. print warning message if users define the `org.apache.kafka.disallowed.login.modules`
   2. adopt the `org.apache.kafka.allowed.login.modules` if it is existent
   3. evaluate the modules according to `DISALLOWED_LOGIN_MODULES_DEFAULT`
   
   Additionally, we should open a jira for 5.0 to add `ALLOWED_LOGIN_MODULES_DEFAULT`
   
   WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627: Deprecated "org.apache.kafka.disallowed.login.modules" [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r2152310283


##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -252,6 +254,32 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
         checkEntry(context.configurationEntries().get(0), "com.sun.security.auth.module.LdapLoginModule",
                 LoginModuleControlFlag.REQUISITE, Collections.emptyMap());
     }
+    
+    @Test
+     void testAllowedLoginModulesSystemProperty() {
+
+        //  default
+        String jaasConfigProp1 = "com.ibm.security.auth.module.LdapLoginModule required;";
+        configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1);
+
+        String jaasConfigProp2 = "com.sun.security.auth.module.JndiLoginModule required;";
+        //  set allowed list, but not set disallowed list
+        System.setProperty(JaasUtils.ALLOWED_LOGIN_MODULES_CONFIG, "com.ibm.security.auth.module.LdapLoginModule");
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));

Review Comment:
   we don't need `assertDoesNotThrow`, right?



##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -252,6 +254,32 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
         checkEntry(context.configurationEntries().get(0), "com.sun.security.auth.module.LdapLoginModule",
                 LoginModuleControlFlag.REQUISITE, Collections.emptyMap());
     }
+    
+    @Test
+     void testAllowedLoginModulesSystemProperty() {
+
+        //  default
+        String jaasConfigProp1 = "com.ibm.security.auth.module.LdapLoginModule required;";
+        configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1);
+
+        String jaasConfigProp2 = "com.sun.security.auth.module.JndiLoginModule required;";
+        //  set allowed list, but not set disallowed list
+        System.setProperty(JaasUtils.ALLOWED_LOGIN_MODULES_CONFIG, "com.ibm.security.auth.module.LdapLoginModule");
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+        assertThrows(IllegalArgumentException.class, () ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp2));
+        
+        //  set both allowed list and disallowed list
+        System.setProperty(JaasUtils.DISALLOWED_LOGIN_MODULES_CONFIG, "com.ibm.security.auth.module.LdapLoginModule");
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));

Review Comment:
   ditto



##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -252,6 +254,32 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
         checkEntry(context.configurationEntries().get(0), "com.sun.security.auth.module.LdapLoginModule",
                 LoginModuleControlFlag.REQUISITE, Collections.emptyMap());
     }
+    
+    @Test
+     void testAllowedLoginModulesSystemProperty() {
+
+        //  default
+        String jaasConfigProp1 = "com.ibm.security.auth.module.LdapLoginModule required;";
+        configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1);

Review Comment:
   Should we test `throwIfLoginModuleIsNotAllowed` directly?



##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -252,6 +254,32 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
         checkEntry(context.configurationEntries().get(0), "com.sun.security.auth.module.LdapLoginModule",
                 LoginModuleControlFlag.REQUISITE, Collections.emptyMap());
     }
+    
+    @Test
+     void testAllowedLoginModulesSystemProperty() {
+
+        //  default
+        String jaasConfigProp1 = "com.ibm.security.auth.module.LdapLoginModule required;";
+        configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1);
+
+        String jaasConfigProp2 = "com.sun.security.auth.module.JndiLoginModule required;";
+        //  set allowed list, but not set disallowed list
+        System.setProperty(JaasUtils.ALLOWED_LOGIN_MODULES_CONFIG, "com.ibm.security.auth.module.LdapLoginModule");
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+        assertThrows(IllegalArgumentException.class, () ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp2));
+        
+        //  set both allowed list and disallowed list
+        System.setProperty(JaasUtils.DISALLOWED_LOGIN_MODULES_CONFIG, "com.ibm.security.auth.module.LdapLoginModule");
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+        assertThrows(IllegalArgumentException.class, () ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp2));
+        
+        //  set disallowed list, but not set allowed list
+        System.clearProperty(JaasUtils.ALLOWED_LOGIN_MODULES_CONFIG);
+        IllegalArgumentException error = assertThrows(IllegalArgumentException.class, () ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+        //  Ensure the exception message includes the deprecation warning for the disallowed login modules config
+        assertTrue(error.getMessage().contains("The system property '" + DISALLOWED_LOGIN_MODULES_CONFIG + "' is deprecated."));
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp2));

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1947202861


##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",

Review Comment:
   After re-thinking this deprecation, it is not so critical to be shipped into 4.0. We should have a KIP for it even though it is straightforward. I have added the `need-kip` to the jira and move it to 4.1
   
   @gongxuanzhang could you please write a KIP for it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627: Deprecated "org.apache.kafka.disallowed.login.modules" [kafka]

Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r2148966769


##########
clients/src/main/java/org/apache/kafka/common/security/JaasUtils.java:
##########
@@ -16,9 +16,12 @@
  */
 package org.apache.kafka.common.security;
 
+
 public final class JaasUtils {
     public static final String JAVA_LOGIN_CONFIG_PARAM = "java.security.auth.login.config";
+    @Deprecated
     public static final String DISALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.disallowed.login.modules";
+    public static final String ALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.allowed.login.modules";
     public static final String DISALLOWED_LOGIN_MODULES_DEFAULT =

Review Comment:
   We can add a version to the `@Deprecated` annotation to indicate when the deprecation was introduced.
   ```
   @Deprecated(since = "4.2")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "TaiJuWu (via GitHub)" <gi...@apache.org>.
TaiJuWu commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1945269924


##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",
+                    DISALLOWED_LOGIN_MODULES_CONFIG, ALLOWED_LOGIN_MODULES_CONFIG);
+        }
+        String loginModuleName = appConfigurationEntry.getLoginModuleName().trim();
+        String allowedProperty = System.getProperty(ALLOWED_LOGIN_MODULES_CONFIG);
+        if (allowedProperty != null) {

Review Comment:
   make sense, thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627: Deprecated "org.apache.kafka.disallowed.login.modules" [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on PR #18683:
URL: https://github.com/apache/kafka/pull/18683#issuecomment-2978633312

   @chia7712  PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "TaiJuWu (via GitHub)" <gi...@apache.org>.
TaiJuWu commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1944890059


##########
clients/src/main/java/org/apache/kafka/common/security/JaasUtils.java:
##########
@@ -16,13 +16,17 @@
  */
 package org.apache.kafka.common.security;
 
+
 public final class JaasUtils {
     public static final String JAVA_LOGIN_CONFIG_PARAM = "java.security.auth.login.config";
+    @Deprecated
     public static final String DISALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.disallowed.login.modules";
+    public static final String ALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.allowed.login.modules";
     public static final String DISALLOWED_LOGIN_MODULES_DEFAULT =
             "com.sun.security.auth.module.JndiLoginModule,com.sun.security.auth.module.LdapLoginModule";
     public static final String SERVICE_NAME = "serviceName";
 
-    private JaasUtils() {}
+    private JaasUtils() {
+    }

Review Comment:
   Please revert unrelated this change.



##########
clients/src/main/java/org/apache/kafka/common/security/JaasUtils.java:
##########
@@ -16,13 +16,17 @@
  */
 package org.apache.kafka.common.security;
 
+

Review Comment:
   Please revet this too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on PR #18683:
URL: https://github.com/apache/kafka/pull/18683#issuecomment-2613955550

   @chia7712  PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627: Deprecated "org.apache.kafka.disallowed.login.modules" [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r2144692245


##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -224,8 +225,7 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
                 "SOME-MECHANISM", Collections.emptyMap()));
 
 
-        //Remove default value for org.apache.kafka.disallowed.login.modules
-        System.setProperty(DISALLOWED_LOGIN_MODULES_CONFIG, "");
+        // add allowed login modules

Review Comment:
   The previous code was like this:
   ```java
   // Remove default value for org.apache.kafka.disallowed.login.modules
   System.setProperty(DISALLOWED_LOGIN_MODULES_CONFIG, "");
   ```
   After modifying the logic, the behavior of setting the DISALLOWED_LOGIN_MODULES_CONFIG property changed, so I updated the comment accordingly.
   However, since this PR has been open for a long time, someone removed that line of code during the process, and my comment was left behind.
   Sorry I didn’t review it carefully.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on PR #18683:
URL: https://github.com/apache/kafka/pull/18683#issuecomment-2639996580

   @chia7712  PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "TaiJuWu (via GitHub)" <gi...@apache.org>.
TaiJuWu commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1944945130


##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",
+                    DISALLOWED_LOGIN_MODULES_CONFIG, ALLOWED_LOGIN_MODULES_CONFIG);
+        }
+        String loginModuleName = appConfigurationEntry.getLoginModuleName().trim();
+        String allowedProperty = System.getProperty(ALLOWED_LOGIN_MODULES_CONFIG);
+        if (allowedProperty != null) {

Review Comment:
   Should we need to consider a case if a module in disallow and allow at same time.
   Maybe it will happen in the meantime.



##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",
+                    DISALLOWED_LOGIN_MODULES_CONFIG, ALLOWED_LOGIN_MODULES_CONFIG);
+        }
+        String loginModuleName = appConfigurationEntry.getLoginModuleName().trim();
+        String allowedProperty = System.getProperty(ALLOWED_LOGIN_MODULES_CONFIG);
+        if (allowedProperty != null) {

Review Comment:
   Should we need to consider a case if a module in disallow and allow at same time?
   Maybe it will happen in the meantime.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on PR #18683:
URL: https://github.com/apache/kafka/pull/18683#issuecomment-2641918869

   @chia7712  PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1934947509


##########
clients/src/test/java/org/apache/kafka/common/security/authenticator/ClientAuthenticationFailureTest.java:
##########
@@ -75,6 +76,7 @@ public void setup() throws Exception {
         TestJaasConfig testJaasConfig = TestJaasConfig.createConfiguration("PLAIN", Collections.singletonList("PLAIN"));
         testJaasConfig.setClientOptions("PLAIN", TestJaasConfig.USERNAME, "anotherpassword");
         server = createEchoServer(securityProtocol);
+        JaasUtils.allowDefaultJaasAndCustomJass();

Review Comment:
   This test case reports an error. It may be that a change to the default configuration caused the jaas tested to be rejected.
   So I add this line



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on PR #18683:
URL: https://github.com/apache/kafka/pull/18683#issuecomment-2613734015

   I cannot reproduce this issue locally. I suspect that the test case has added environment variables


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on PR #18683:
URL: https://github.com/apache/kafka/pull/18683#issuecomment-2628748704

   @chia7712  PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1934364823


##########
clients/src/test/java/org/apache/kafka/common/security/authenticator/ClientAuthenticationFailureTest.java:
##########
@@ -75,6 +76,7 @@ public void setup() throws Exception {
         TestJaasConfig testJaasConfig = TestJaasConfig.createConfiguration("PLAIN", Collections.singletonList("PLAIN"));
         testJaasConfig.setClientOptions("PLAIN", TestJaasConfig.USERNAME, "anotherpassword");
         server = createEchoServer(securityProtocol);
+        JaasUtils.allowDefaultJaasAndCustomJass();

Review Comment:
   it does not add any other modules, so do we really need it?



##########
core/src/test/scala/integration/kafka/api/SaslSslAdminIntegrationTest.scala:
##########
@@ -70,7 +70,6 @@ class SaslSslAdminIntegrationTest extends BaseAdminIntegrationTest with SaslSetu
     this.serverConfig.setProperty(DelegationTokenManagerConfigs.DELEGATION_TOKEN_SECRET_KEY_CONFIG, secretKey)
     this.serverConfig.setProperty(DelegationTokenManagerConfigs.DELEGATION_TOKEN_EXPIRY_TIME_MS_CONFIG, Long.MaxValue.toString)
     this.serverConfig.setProperty(DelegationTokenManagerConfigs.DELEGATION_TOKEN_MAX_LIFETIME_CONFIG, Long.MaxValue.toString)
-

Review Comment:
   please revert unrelated change



##########
clients/src/main/java/org/apache/kafka/common/security/JaasUtils.java:
##########
@@ -16,13 +16,32 @@
  */
 package org.apache.kafka.common.security;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 public final class JaasUtils {
     public static final String JAVA_LOGIN_CONFIG_PARAM = "java.security.auth.login.config";
+    @Deprecated
     public static final String DISALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.disallowed.login.modules";
-    public static final String DISALLOWED_LOGIN_MODULES_DEFAULT =
-            "com.sun.security.auth.module.JndiLoginModule,com.sun.security.auth.module.LdapLoginModule";
+    public static final String ALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.allowed.login.modules";
+    public static final String ALLOWED_LOGIN_MODULES_DEFAULT = String.join(",", List.of(
+            "org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule",
+            "org.apache.kafka.common.security.plain.PlainLoginModule",
+            "org.apache.kafka.connect.rest.basic.auth.extension.PropertyFileLoginModule",
+            "org.apache.kafka.common.security.scram.ScramLoginModule",
+            "com.sun.security.auth.module.Krb5LoginModule"
+    ));
     public static final String SERVICE_NAME = "serviceName";
 
-    private JaasUtils() {}
+    private JaasUtils() {
+    }
+
+    public static void allowDefaultJaasAndCustomJass(String... customJaas) {
+        List<String> jaasModules = new ArrayList<>();
+        jaasModules.add(ALLOWED_LOGIN_MODULES_DEFAULT);
+        jaasModules.addAll(Arrays.asList(customJaas));
+        System.setProperty(org.apache.kafka.common.security.JaasUtils.ALLOWED_LOGIN_MODULES_CONFIG, String.join(",", jaasModules));

Review Comment:
   why to use full package name?



##########
clients/src/test/java/org/apache/kafka/common/security/authenticator/SaslAuthenticatorFailureDelayTest.java:
##########
@@ -74,6 +75,7 @@ public void setup() throws Exception {
         credentialCache = new CredentialCache();
         SaslAuthenticatorTest.TestLogin.loginCount.set(0);
         startTimeMs = time.milliseconds();
+        JaasUtils.allowDefaultJaasAndCustomJass();

Review Comment:
   ditto



##########
core/src/test/scala/integration/kafka/api/SaslEndToEndAuthorizationTest.scala:
##########
@@ -46,7 +46,6 @@ abstract class SaslEndToEndAuthorizationTest extends EndToEndAuthorizationTest {
     producerConfig.put(SaslConfigs.SASL_JAAS_CONFIG, clientLoginContext)
     consumerConfig.put(SaslConfigs.SASL_JAAS_CONFIG, clientLoginContext)
     adminClientConfig.put(SaslConfigs.SASL_JAAS_CONFIG, clientLoginContext)
-

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "gongxuanzhang (via GitHub)" <gi...@apache.org>.
gongxuanzhang commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1959006278


##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",

Review Comment:
   @chia7712 
   https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=340037077&src=jira



##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",

Review Comment:
   @chia7712 
   https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=340037077



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627:add allowed modules to JaasUtils [kafka]

Posted by "TaiJuWu (via GitHub)" <gi...@apache.org>.
TaiJuWu commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r1944945130


##########
clients/src/main/java/org/apache/kafka/common/security/JaasContext.java:
##########
@@ -103,12 +104,31 @@ else if (contextModules.length != 1)
             return defaultContext(contextType, listenerContextName, globalContextName);
     }
 
+    @SuppressWarnings("deprecation")
     private static void throwIfLoginModuleIsNotAllowed(AppConfigurationEntry appConfigurationEntry) {
-        Set<String> disallowedLoginModuleList = Arrays.stream(
-                System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG, DISALLOWED_LOGIN_MODULES_DEFAULT).split(","))
+        String disallowedProperty = System.getProperty(DISALLOWED_LOGIN_MODULES_CONFIG);
+        if (disallowedProperty != null) {
+            LOG.warn("System property '{}' is deprecated and will be removed in a future release. Use '{}' instead.",
+                    DISALLOWED_LOGIN_MODULES_CONFIG, ALLOWED_LOGIN_MODULES_CONFIG);
+        }
+        String loginModuleName = appConfigurationEntry.getLoginModuleName().trim();
+        String allowedProperty = System.getProperty(ALLOWED_LOGIN_MODULES_CONFIG);
+        if (allowedProperty != null) {

Review Comment:
   Umm....
   We need to consider a case if a module in disallow and allow at same time.
   Maybe it will happen in the meantime.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627: Deprecated "org.apache.kafka.disallowed.login.modules" [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #18683:
URL: https://github.com/apache/kafka/pull/18683


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-18627: Deprecated "org.apache.kafka.disallowed.login.modules" [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #18683:
URL: https://github.com/apache/kafka/pull/18683#discussion_r2148392691


##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -252,6 +252,30 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
         checkEntry(context.configurationEntries().get(0), "com.sun.security.auth.module.LdapLoginModule",
                 LoginModuleControlFlag.REQUISITE, Collections.emptyMap());
     }
+    
+    @Test
+     void testAllowedLoginModulesSystemProperty() {
+
+        //  default
+        String jaasConfigProp1 = "com.ibm.security.auth.module.LdapLoginModule required;";
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));

Review Comment:
   we don't need to wrap it by `assertDoesNotThrow`



##########
clients/src/test/java/org/apache/kafka/common/security/JaasContextTest.java:
##########
@@ -252,6 +252,30 @@ public void testDisallowedLoginModulesSystemProperty() throws Exception {
         checkEntry(context.configurationEntries().get(0), "com.sun.security.auth.module.LdapLoginModule",
                 LoginModuleControlFlag.REQUISITE, Collections.emptyMap());
     }
+    
+    @Test
+     void testAllowedLoginModulesSystemProperty() {
+
+        //  default
+        String jaasConfigProp1 = "com.ibm.security.auth.module.LdapLoginModule required;";
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+
+        String jaasConfigProp2 = "com.sun.security.auth.module.JndiLoginModule required;";
+        //  set allow dont' set not allow
+        System.setProperty(JaasUtils.ALLOWED_LOGIN_MODULES_CONFIG, "com.ibm.security.auth.module.LdapLoginModule");
+        assertDoesNotThrow(() ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp1));
+        assertThrows(IllegalArgumentException.class, () ->  configurationEntry(JaasContext.Type.CLIENT, jaasConfigProp2));

Review Comment:
   Please check the error message



##########
clients/src/main/java/org/apache/kafka/common/security/JaasUtils.java:
##########
@@ -16,9 +16,12 @@
  */
 package org.apache.kafka.common.security;
 
+
 public final class JaasUtils {
     public static final String JAVA_LOGIN_CONFIG_PARAM = "java.security.auth.login.config";
+    @Deprecated
     public static final String DISALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.disallowed.login.modules";
+    public static final String ALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.allowed.login.modules";
     public static final String DISALLOWED_LOGIN_MODULES_DEFAULT =

Review Comment:
   please add `@Deprecated` to it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org