-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[enhance](auth) introduction of configuration property to prohibit login with empty LDAP password #61440
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
base: master
Are you sure you want to change the base?
[enhance](auth) introduction of configuration property to prohibit login with empty LDAP password #61440
Changes from all commits
0b02055
8e76ba6
417b8dd
22147fb
a4a8562
00b5785
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| import org.apache.doris.mysql.privilege.Auth; | ||
| import org.apache.doris.mysql.privilege.Role; | ||
|
|
||
| import org.junit.After; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
@@ -47,6 +48,12 @@ public class LdapManagerTest { | |
| public void setUp() { | ||
| Config.authentication_type = "ldap"; | ||
| LdapConfig.ldap_default_roles = new String[0]; | ||
| LdapConfig.ldap_allow_empty_pass = true; | ||
| } | ||
|
|
||
| @After | ||
| public void tearDown() { | ||
| LdapConfig.ldap_allow_empty_pass = true; | ||
| } | ||
|
|
||
| private void mockClient(boolean userExist, boolean passwd) { | ||
|
|
@@ -108,6 +115,32 @@ public void testCheckUserPasswd() { | |
| Assert.assertFalse(ldapManager.checkUserPasswd(USER2, "123")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testUserLoginWithEmptyLDAPPasswordDefault() { | ||
| LdapManager ldapManager = new LdapManager(); | ||
| Assert.assertTrue(ldapManager.checkLoginWithEmptyPasswordForLdapIsAllowed("username", null)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Exercise the production empty-password chokepoint These new tests call the helper directly, so they still pass if its invocation is deleted from |
||
| Assert.assertTrue(ldapManager.checkLoginWithEmptyPasswordForLdapIsAllowed("username", "")); | ||
| Assert.assertTrue(ldapManager.checkLoginWithEmptyPasswordForLdapIsAllowed("username", "password")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testUserLoginWithEmptyLDAPPasswordEnabled() { | ||
| LdapManager ldapManager = new LdapManager(); | ||
| LdapConfig.ldap_allow_empty_pass = true; | ||
| Assert.assertTrue(ldapManager.checkLoginWithEmptyPasswordForLdapIsAllowed("username", null)); | ||
| Assert.assertTrue(ldapManager.checkLoginWithEmptyPasswordForLdapIsAllowed("username", "")); | ||
| Assert.assertTrue(ldapManager.checkLoginWithEmptyPasswordForLdapIsAllowed("username", "password")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testUserLoginWithEmptyLDAPPasswordDisabled() { | ||
| LdapManager ldapManager = new LdapManager(); | ||
| LdapConfig.ldap_allow_empty_pass = false; | ||
| Assert.assertFalse(ldapManager.checkLoginWithEmptyPasswordForLdapIsAllowed("username", null)); | ||
| Assert.assertFalse(ldapManager.checkLoginWithEmptyPasswordForLdapIsAllowed("username", "")); | ||
| Assert.assertTrue(ldapManager.checkLoginWithEmptyPasswordForLdapIsAllowed("username", "password")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetUserInfoWithLdapDefaultRolesWithoutLdapGroups() { | ||
| LdapManager ldapManager = new LdapManager(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.