This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch dev-2.1.3
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev-2.1.3 by this push:
     new 5bc030bd0 cp pr 3237 (#3399)
5bc030bd0 is described below

commit 5bc030bd038b60fb66bc1ecfa36754d6ac4d6d3d
Author: xiangzihao <[email protected]>
AuthorDate: Fri Dec 15 13:12:06 2023 +0800

    cp pr 3237 (#3399)
---
 .../console/system/security/impl/AuthenticatorImpl.java  |  4 ++--
 .../console/system/security/impl/LdapService.java        | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java
index 916f4ae27..9e1975687 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java
@@ -67,8 +67,8 @@ public class AuthenticatorImpl implements Authenticator {
   }
 
   private User ldapAuthenticate(String username, String password) throws 
Exception {
-    String ldapEmail = ldapService.ldapLogin(username, password);
-    if (ldapEmail == null) {
+    boolean ldapLoginStatus = ldapService.ldapLogin(username, password);
+    if (!ldapLoginStatus) {
       return null;
     }
     // check if user exist
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/LdapService.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/LdapService.java
index 2eb0043a4..2931e43b1 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/LdapService.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/LdapService.java
@@ -70,9 +70,9 @@ public class LdapService {
    *
    * @param userId user identity id
    * @param userPwd user login password
-   * @return user email
+   * @return boolean ldapLoginStatus
    */
-  public String ldapLogin(String userId, String userPwd) {
+  public boolean ldapLogin(String userId, String userPwd) {
     if (!enable) {
       throw new ApiAlertException(
           "ldap is not enabled, Please check the configuration: ldap.enable");
@@ -91,7 +91,7 @@ public class LdapService {
     try {
       LdapContext ctx = new InitialLdapContext(ldapEnv, null);
       SearchControls sc = new SearchControls();
-      sc.setReturningAttributes(new String[] {ldapEmailAttribute});
+      sc.setReturningAttributes(new String[] {ldapUserIdentifyingAttribute});
       sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
       EqualsFilter filter = new EqualsFilter(ldapUserIdentifyingAttribute, 
userId);
       NamingEnumeration<SearchResult> results = ctx.search(ldapBaseDn, 
filter.toString(), sc);
@@ -105,18 +105,18 @@ public class LdapService {
             new InitialDirContext(ldapEnv);
           } catch (Exception e) {
             log.warn("invalid ldap credentials or ldap search error", e);
-            return null;
+            return false;
           }
           Attribute attr = attrs.next();
-          if (attr.getID().equals(ldapEmailAttribute)) {
-            return (String) attr.get();
+          if (attr.getID().equals(ldapUserIdentifyingAttribute)) {
+            return true;
           }
         }
       }
     } catch (NamingException e) {
       log.error("ldap search error", e);
-      return null;
+      return false;
     }
-    return null;
+    return false;
   }
 }

Reply via email to