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

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


The following commit(s) were added to refs/heads/dev by this push:
     new f37372feb [Fix-3226] If the user does not have any more attributes, 
they will not be able to log in. (#3237)
f37372feb is described below

commit f37372feb2cd113c40be7db664479524049b2fc8
Author: xiangzihao <[email protected]>
AuthorDate: Fri Oct 13 01:29:07 2023 -0500

    [Fix-3226] If the user does not have any more attributes, they will not be 
able to log in. (#3237)
    
    * fix issue 3226
    
    * fix spotless error
---
 .../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 a4a94a365..50c9616a3 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
@@ -76,8 +76,8 @@ public class AuthenticatorImpl implements Authenticator {
   }
 
   private User ldapAuthenticate(String username, String password) throws 
Exception {
-    String ldapEmail = ldapService.ldapLogin(username, password);
-    if (StringUtils.isBlank(ldapEmail)) {
+    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 b6a3d9b31..e8215a120 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) {
 
     ApiAlertException.throwIfFalse(
         enable, "ldap is not enabled, Please check the configuration: 
ldap.enable");
@@ -90,7 +90,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);
@@ -104,18 +104,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