-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[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
ca20a76
042ed1f
95c44bd
f5b3066
9d4e971
629cab0
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 |
|---|---|---|
|
|
@@ -175,4 +175,10 @@ public class LdapConfig extends ConfigBase { | |
| public static String getConnectionURL(String hostPortInAccessibleFormat) { | ||
| return ((LdapConfig.ldap_use_ssl ? "ldaps" : "ldap") + "://" + hostPortInAccessibleFormat); | ||
| } | ||
|
|
||
| /** | ||
| * Flag to enable login with empty pass. | ||
| */ | ||
| @ConfigBase.ConfField | ||
| public static boolean ldap_allow_empty_pass = true; | ||
|
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. [Suggestion] This config should be @ConfigBase.ConfField(mutable = true)Rationale: This is a security policy toggle checked at authentication time with no cached state or initialization dependency. An admin discovering empty-password logins as a security risk would want to disable this immediately without restarting FE (which disconnects all users). The precedent in this file ( |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| import org.apache.doris.catalog.Env; | ||
| import org.apache.doris.common.ErrorCode; | ||
| import org.apache.doris.common.ErrorReport; | ||
| import org.apache.doris.common.LdapConfig; | ||
| import org.apache.doris.mysql.authenticate.AuthenticateRequest; | ||
| import org.apache.doris.mysql.authenticate.AuthenticateResponse; | ||
| import org.apache.doris.mysql.authenticate.Authenticator; | ||
|
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. [Nit] The log message includes LOG.info("user:{} login rejected: empty LDAP password is prohibited (ldap_allow_empty_pass=false)", userName); |
||
|
|
@@ -83,7 +84,7 @@ public boolean canDeal(String qualifiedUser) { | |
|
|
||
| /** | ||
| * The LDAP authentication process is as follows: | ||
| * step1: Check the LDAP password. | ||
| * step1: Check the LDAP password (if ldap_allow_empty_pass is false login with empty pass is prohibited). | ||
| * step2: Get the LDAP groups privileges as a role, saved into ConnectContext. | ||
| * step3: Set current userIdentity. If the user account does not exist in Doris, login as a temporary user. | ||
| * Otherwise, login to the Doris account. | ||
|
|
@@ -95,6 +96,14 @@ private AuthenticateResponse internalAuthenticate(String password, String qualif | |
| LOG.debug("user:{}", userName); | ||
| } | ||
|
|
||
| //not allow to login in case when empty password is specified but such mode is disabled by configuration | ||
| if (Strings.isNullOrEmpty(password) && !LdapConfig.ldap_allow_empty_pass) { | ||
| LOG.info("user:{} is not allowed to login to LDAP with empty password because ldap_allow_empty_pass:{}", | ||
| userName, LdapConfig.ldap_allow_empty_pass); | ||
| ErrorReport.report(ErrorCode.ERR_EMPTY_PASSWORD, qualifiedUser + "@" + remoteIp); | ||
| return AuthenticateResponse.failedResponse; | ||
| } | ||
|
|
||
| // check user password by ldap server. | ||
| try { | ||
| if (!Env.getCurrentEnv().getAuth().getLdapManager().checkUserPasswd(qualifiedUser, password)) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] The phrase "because of current mode" is vague and doesn't help the user understand what to do. Consider a more specific message:
"Access with empty password is prohibited for LDAP user '%s'. Set ldap_allow_empty_pass=true to allow."This tells the user both what happened and how to resolve it.