JWuCines commented on code in PR #19432:
URL: https://github.com/apache/druid/pull/19432#discussion_r3894690631
##########
extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/validator/LDAPCredentialsValidator.java:
##########
@@ -237,22 +247,90 @@ SearchResult getLdapUserObject(BasicAuthLDAPConfig
ldapConfig, DirContext contex
ldapConfig.getBaseDn(),
StringUtils.format(ldapConfig.getUserSearch(), encodedUsername),
sc);
+ final SearchResult userResult;
try {
if (!results.hasMore()) {
return null;
}
- return results.next();
+ userResult = results.next();
}
finally {
results.close();
}
+ return userResult;
}
catch (NamingException e) {
LOG.debug(e, "Unable to find user '%s'", username);
return null;
}
}
+ private static boolean hasMemberOfAttribute(SearchResult userResult)
+ {
+ return userResult.getAttributes() != null
+ && userResult.getAttributes().get("memberOf") != null;
+ }
+
+ @SuppressWarnings("BanJNDI")
+ private void enrichWithGroupSearch(SearchResult userResult)
+ {
+ final ClassLoader currentClassLoader =
Thread.currentThread().getContextClassLoader();
+ InitialDirContext dirContext = null;
+ try {
+
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ dirContext = new InitialDirContext(bindProperties(this.ldapConfig));
+
+ final String userDn = userResult.getNameInNamespace();
+ final SearchControls sc = new SearchControls();
+ sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ sc.setReturningAttributes(new String[]{"1.1"});
+
+ final String filter =
StringUtils.format(this.ldapConfig.getGroupSearch(), encodeForLDAP(userDn,
true));
Review Comment:
Added a fix to enforce "%s" placeholder in groupSearch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]