Skip to content
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

[BugFix] Fix LDAP authentication bug where empty password can successfully login on AD server (backport #41982) #42566

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package com.starrocks.mysql.security;

import com.google.common.base.Strings;
import com.starrocks.common.Config;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -19,6 +20,11 @@ public class LdapSecurity {

//bind to ldap server to check password
public static boolean checkPassword(String dn, String password) {
if (Strings.isNullOrEmpty(password)) {
LOG.warn("empty password is not allowed for simple authentication");
return false;
}

String url = "ldap://" + Config.authentication_ldap_simple_server_host + ":" +
Config.authentication_ldap_simple_server_port;
Hashtable<String, String> env = new Hashtable<>();
Expand Down Expand Up @@ -51,6 +57,11 @@ public static boolean checkPassword(String dn, String password) {
//2. search user
//3. if match exactly one, check password
public static boolean checkPasswordByRoot(String user, String password) {
if (Strings.isNullOrEmpty(Config.authentication_ldap_simple_bind_root_pwd)) {
LOG.warn("empty password is not allowed for simple authentication");
return false;
}

String url = "ldap://" + Config.authentication_ldap_simple_server_host + ":" +
Config.authentication_ldap_simple_server_port;
Hashtable<String, String> env = new Hashtable<>();
Expand Down
Loading