Stable implementation of Directory integration
- Documentation - Allow to specific other attributes in LDAP to include in the search
This commit is contained in:
@@ -40,7 +40,6 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@@ -73,6 +72,7 @@ public class LdapDirectoryProvider extends LdapGenericBackend implements IDirect
|
||||
attributes.toArray(attArray);
|
||||
|
||||
String searchQuery = buildOrQueryWithFilter(getCfg().getDirectory().getFilter(), "*" + query + "*", attArray);
|
||||
log.debug("Query: {}", searchQuery);
|
||||
try (EntryCursor cursor = conn.search(getBaseDn(), searchQuery, SearchScope.SUBTREE, attArray)) {
|
||||
while (cursor.next()) {
|
||||
Entry entry = cursor.get();
|
||||
@@ -102,13 +102,17 @@ public class LdapDirectoryProvider extends LdapGenericBackend implements IDirect
|
||||
@Override
|
||||
public UserDirectorySearchResult searchByDisplayName(String query) {
|
||||
log.info("Performing LDAP directory search on display name using '{}'", query);
|
||||
return search(query, Collections.singletonList(getCfg().getAttribute().getName()));
|
||||
List<String> attributes = new ArrayList<>();
|
||||
attributes.add(getAt().getName());
|
||||
attributes.addAll(getCfg().getDirectory().getAttribute().getOther());
|
||||
return search(query, attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDirectorySearchResult searchBy3pid(String query) {
|
||||
log.info("Performing LDAP directory search on 3PIDs using '{}'", query);
|
||||
List<String> attributes = new ArrayList<>();
|
||||
attributes.add(getAt().getName());
|
||||
getCfg().getAttribute().getThreepid().forEach((k, v) -> attributes.addAll(v));
|
||||
return search(query, attributes);
|
||||
}
|
||||
|
@@ -32,6 +32,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "ldap")
|
||||
@@ -45,8 +47,31 @@ public class LdapConfig {
|
||||
|
||||
public static class Directory {
|
||||
|
||||
public static class Attribute {
|
||||
|
||||
private List<String> other = new ArrayList<>();
|
||||
|
||||
public List<String> getOther() {
|
||||
return other;
|
||||
}
|
||||
|
||||
public void setOther(List<String> other) {
|
||||
this.other = other;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Attribute attribute = new Attribute();
|
||||
private String filter;
|
||||
|
||||
public Attribute getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package io.kamax.mxisd.config.sql;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.kamax.mxisd.util.GsonUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -212,8 +212,9 @@ public abstract class SqlConfig {
|
||||
log.info("Type: {}", getType());
|
||||
log.info("Connection: {}", getConnection());
|
||||
log.info("Auth enabled: {}", getAuth().isEnabled());
|
||||
log.info("Directory queries: {}", GsonUtil.build().toJson(getDirectory().getQuery()));
|
||||
log.info("Identity type: {}", getIdentity().getType());
|
||||
log.info("Identity medium queries: {}", new Gson().toJson(getIdentity().getMedium()));
|
||||
log.info("Identity medium queries: {}", GsonUtil.build().toJson(getIdentity().getMedium()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user