Port default configuration values

This commit is contained in:
Max Dor
2018-12-25 20:25:56 +01:00
parent 05493da27c
commit d160a44509
22 changed files with 297 additions and 444 deletions

View File

@@ -64,7 +64,7 @@ String gitVersion() {
commandLine = ['git', 'describe', '--tags', '--always', '--dirty']
standardOutput = out
}
return out.toString().replace(System.lineSeparator(), '');
return out.toString().replace(System.lineSeparator(), '')
}
buildscript {
@@ -84,6 +84,9 @@ repositories {
}
dependencies {
// Logging
compile 'org.slf4j:slf4j-simple:1.7.25'
// Easy file management
compile 'commons-io:commons-io:2.5'
@@ -93,6 +96,9 @@ dependencies {
// Matrix Java SDK
compile 'io.kamax:matrix-java-sdk:0.0.14-8-g0e57ec6'
// ORMLite
compile 'com.j256.ormlite:ormlite-jdbc:5.0'
// ed25519 handling
compile 'net.i2p.crypto:eddsa:0.1.0'
@@ -115,9 +121,6 @@ dependencies {
// Google Firebase Authentication backend
compile 'com.google.firebase:firebase-admin:5.3.0'
// ORMLite
compile 'com.j256.ormlite:ormlite-jdbc:5.0'
// Connection Pool
compile 'com.mchange:c3p0:0.9.5.2'
@@ -153,21 +156,10 @@ shadowJar {
version = null
}
processResources {
task debBuild(dependsOn: shadowJar) {
doLast {
copy {
from('build/resources/main/application.yaml') {
rename 'application.yaml', 'mxisd.yaml'
}
into 'build/resources/main'
}
}
}
task buildDeb(dependsOn: build) {
doLast {
def v = mxisdVersion()
println "Version for package: ${v}"
String debVersion = mxisdVersion()
println "Version for package: ${debVersion}"
mkdir distDir
mkdir debBuildBasePath
mkdir "${debBuildBasePath}/DEBIAN"
@@ -193,13 +185,13 @@ task buildDeb(dependsOn: build) {
into debBuildConfPath
}
ant.replaceregexp(
ant.replaceregexp( // FIXME adapt to new config format
file: "${debBuildConfPath}/${debConfFileName}",
match: "key.path:(.*)",
replace: "key.path: '${debDataPath}/signing.key'"
)
ant.replaceregexp(
ant.replaceregexp( // FIXME adapt to new config format
file: "${debBuildConfPath}/${debConfFileName}",
match: "storage.provider.sqlite.database:(.*)",
replace: "storage.provider.sqlite.database: '${debDataPath}/mxisd.db'"
@@ -213,7 +205,7 @@ task buildDeb(dependsOn: build) {
ant.replace(
file: "${debBuildDebianPath}/control",
token: 'Version: 0',
value: "Version: ${v}"
value: "Version: ${debVersion}"
)
ant.replace(
@@ -249,7 +241,7 @@ task buildDeb(dependsOn: build) {
}
}
task dockerBuild(type: Exec, dependsOn: build) {
task dockerBuild(type: Exec, dependsOn: shadowJar) {
commandLine 'docker', 'build', '-t', dockerImageTag, project.rootDir
doLast {

View File

@@ -22,4 +22,4 @@ if [[ -n "$CONF_FILE_PATH" ]] && [ ! -f "$CONF_FILE_PATH" ]; then
echo
fi
exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -Dspring.config.location=/etc/mxisd/ -Dspring.config.name=mxisd -jar /mxisd.jar
exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /mxisd.jar

View File

@@ -32,8 +32,8 @@ public class InvitationConfig {
public static class Resolution {
private boolean recursive;
private long timer;
private boolean recursive = true;
private long timer = 1;
public boolean isRecursive() {
return recursive;

View File

@@ -20,13 +20,14 @@
package io.kamax.mxisd.config;
import com.google.gson.Gson;
import io.kamax.matrix.json.GsonUtil;
import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -34,8 +35,13 @@ import java.util.Map;
public class MatrixConfig {
public static class Identity {
private Map<String, List<String>> servers = new HashMap<>();
public Identity() {
servers.put("matrix-org", Collections.singletonList("https://matrix.org"));
}
public Map<String, List<String>> getServers() {
return servers;
}
@@ -51,6 +57,7 @@ public class MatrixConfig {
return servers.get(label);
}
}
private transient final Logger log = LoggerFactory.getLogger(MatrixConfig.class);
@@ -93,7 +100,7 @@ public class MatrixConfig {
log.info("Domain: {}", getDomain());
log.info("Identity:");
log.info("\tServers: {}", new Gson().toJson(identity.getServers()));
log.info("\tServers: {}", GsonUtil.get().toJson(identity.getServers()));
}
}

View File

@@ -20,22 +20,19 @@
package io.kamax.mxisd.config;
import com.google.gson.JsonObject;
import io.kamax.mxisd.config.ldap.generic.GenericLdapConfig;
import io.kamax.mxisd.config.ldap.netiq.NetIqLdapConfig;
import io.kamax.mxisd.config.memory.MemoryStoreConfig;
import io.kamax.mxisd.config.rest.RestBackendConfig;
import io.kamax.mxisd.config.sql.generic.GenericSqlProviderConfig;
import io.kamax.mxisd.config.sql.synapse.SynapseSqlProviderConfig;
import io.kamax.mxisd.config.threepid.ThreePidConfig;
import io.kamax.mxisd.config.threepid.notification.NotificationConfig;
import io.kamax.mxisd.config.wordpress.WordpressConfig;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
public class MxisdConfig {
private static final Logger log = LoggerFactory.getLogger(MxisdConfig.class);
@@ -52,6 +49,10 @@ public class MxisdConfig {
this.overwrite = overwrite;
}
public void build() {
overwrite.build();
}
}
public static class Lookup {
@@ -82,20 +83,6 @@ public class MxisdConfig {
}
public static class Threepid {
private Map<String, JsonObject> medium = new HashMap<>();
public Map<String, JsonObject> getMedium() {
return medium;
}
public void setMedium(Map<String, JsonObject> medium) {
this.medium = medium;
}
}
private AuthenticationConfig auth = new AuthenticationConfig();
private DirectoryConfig directory = new DirectoryConfig();
private Dns dns = new Dns();
@@ -116,6 +103,7 @@ public class MxisdConfig {
private RestBackendConfig rest = new RestBackendConfig();
private GenericSqlProviderConfig sql = new GenericSqlProviderConfig();
private SynapseSqlProviderConfig synapseSql = new SynapseSqlProviderConfig();
private ThreePidConfig threepid = new ThreePidConfig();
private ViewConfig view = new ViewConfig();
private WordpressConfig wordpress = new WordpressConfig();
@@ -279,6 +267,14 @@ public class MxisdConfig {
this.synapseSql = synapseSql;
}
public ThreePidConfig getThreepid() {
return threepid;
}
public void setThreepid(ThreePidConfig threepid) {
this.threepid = threepid;
}
public ViewConfig getView() {
return view;
}
@@ -320,6 +316,7 @@ public class MxisdConfig {
getSql().build();
getStorage().build();
getSynapseSql().build();
getThreepid().build();
getView().build();
getWordpress().build();

View File

@@ -32,7 +32,7 @@ public class RecursiveLookupBridgeConfig {
private transient final Logger log = LoggerFactory.getLogger(RecursiveLookupBridgeConfig.class);
private boolean enabled;
private boolean recursiveOnly;
private boolean recursiveOnly = true;
private String server;
private Map<String, String> mappings = new HashMap<>();

View File

@@ -25,10 +25,18 @@ import java.util.List;
public class RecursiveLookupConfig {
private boolean enabled;
private boolean enabled = true;
private List<String> allowedCidr = new ArrayList<>();
private RecursiveLookupBridgeConfig bridge = new RecursiveLookupBridgeConfig();
public RecursiveLookupConfig() {
allowedCidr.add("127.0.0.0/8");
allowedCidr.add("10.0.0.0/8");
allowedCidr.add("172.16.0.0/12");
allowedCidr.add("192.168.0.0/16");
allowedCidr.add("::1/128");
}
public boolean isEnabled() {
return enabled;
}
@@ -54,7 +62,7 @@ public class RecursiveLookupConfig {
}
public void build() {
// no-op
bridge.build();
}
}

View File

@@ -20,7 +20,7 @@
package io.kamax.mxisd.config;
import com.google.gson.Gson;
import io.kamax.matrix.json.GsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -127,6 +127,19 @@ public class SessionConfig {
}
public Policy() {
validation.enabled = true;
validation.forLocal.enabled = true;
validation.forLocal.toLocal = true;
validation.forLocal.toRemote.enabled = true;
validation.forLocal.toRemote.server = "matrix-org";
validation.forRemote.enabled = true;
validation.forRemote.toLocal = false;
validation.forRemote.toRemote.enabled = true;
validation.forRemote.toRemote.server = "matrix-org";
}
private PolicyTemplate validation = new PolicyTemplate();
public PolicyTemplate getValidation() {
@@ -152,7 +165,7 @@ public class SessionConfig {
@PostConstruct
public void build() {
log.info("--- Session config ---");
log.info("Global Policy: {}", new Gson().toJson(policy));
log.info("Global Policy: {}", GsonUtil.get().toJson(policy));
}
}

View File

@@ -96,6 +96,20 @@ public class ViewConfig {
private Local localRemote = new Local();
private Remote remote = new Remote();
public Session() {
local.onTokenSubmit.success = "session/local/tokenSubmitSuccess";
local.onTokenSubmit.failure = "session/local/tokenSubmitFailure";
localRemote.onTokenSubmit.success = "session/localRemote/tokenSubmitSuccess";
localRemote.onTokenSubmit.failure = "session/local/tokenSubmitFailure";
remote.onRequest.success = "session/remote/requestSuccess";
remote.onRequest.failure = "session/remote/requestFailure";
remote.onCheck.success = "session/remote/checkSuccess";
remote.onCheck.failure = "session/remote/checkFailure";
}
public Local getLocal() {
return local;
}

View File

@@ -59,9 +59,30 @@ public abstract class LdapConfig {
public static class Attribute {
private UID uid;
private String name;
private String name = "displayName";
private Map<String, List<String>> threepid = new HashMap<>();
public Attribute() {
uid = new UID();
uid.setType("uid");
uid.setValue("saMAccountName");
threepid.put("email", Arrays.asList(
"mailPrimaryAddress",
"mail",
"otherMailbox"
));
threepid.put("msisdn", Arrays.asList(
"telephoneNumber",
"mobile",
"homePhone",
"otherTelephone",
"otherMobile",
"otherHomePhone"
));
}
public UID getUid() {
return uid;
}
@@ -104,9 +125,9 @@ public abstract class LdapConfig {
public static class Connection {
private boolean tls;
private boolean tls = false;
private String host;
private int port;
private int port = 389;
private String bindDn;
private String bindPassword;
private String baseDn;
@@ -212,7 +233,7 @@ public abstract class LdapConfig {
public static class Identity {
private String filter;
private String token;
private String token = "%3pid";
private Map<String, String> medium = new HashMap<>();
public String getFilter() {

View File

@@ -35,8 +35,8 @@ public class RestBackendConfig {
public static class IdentityEndpoints {
private String single;
private String bulk;
private String single = "/_mxisd/backend/api/v1/identity/lookup/single";
private String bulk = "/_mxisd/backend/api/v1/identity/lookup/bulk";
public String getSingle() {
return single;
@@ -58,9 +58,9 @@ public class RestBackendConfig {
public static class ProfileEndpoints {
private String displayName;
private String threepids;
private String roles;
private String displayName = "/_mxisd/backend/api/v1/profile/displayName";
private String threepids = "/_mxisd/backend/api/v1/profile/threepids";
private String roles = "/_mxisd/backend/api/v1/profile/roles";
public String getDisplayName() {
return displayName;
@@ -90,8 +90,8 @@ public class RestBackendConfig {
public static class Endpoints {
private String auth;
private String directory;
private String auth = "/_mxisd/backend/api/v1/auth/login";
private String directory = "/_mxisd/backend/api/v1/directory/user/search";
private IdentityEndpoints identity = new IdentityEndpoints();
private ProfileEndpoints profile;

View File

@@ -97,6 +97,14 @@ public abstract class SqlConfig {
private Boolean enabled;
private Type query = new Type();
public Directory() {
query.getName().setType("localpart");
query.getName().setType("SELECT 1");
query.getThreepid().setType("localpart");
query.getThreepid().setType("SELECT 1");
}
public Boolean isEnabled() {
return enabled;
}
@@ -118,8 +126,8 @@ public abstract class SqlConfig {
public static class Identity {
private Boolean enabled;
private String type;
private String query;
private String type = "mxid";
private String query = "SELECT user_id AS uid FROM user_threepids WHERE medium = ? AND address = ?";
private Map<String, String> medium = new HashMap<>();
public Boolean isEnabled() {
@@ -172,7 +180,7 @@ public abstract class SqlConfig {
public static class ProfileThreepids {
private String query;
private String query = "SELECT medium, address FROM user_threepids WHERE user_id = ?";
public String getQuery() {
return query;
@@ -217,7 +225,7 @@ public abstract class SqlConfig {
}
private boolean enabled;
private String type;
private String type = "sqlite";
private String connection;
private Auth auth = new Auth();
private Directory directory = new Directory();

View File

@@ -0,0 +1,49 @@
/*
* mxisd - Matrix Identity Server Daemon
* Copyright (C) 2018 Kamax Sàrl
*
* https://www.kamax.io/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.kamax.mxisd.config.threepid;
import com.google.gson.JsonObject;
import io.kamax.mxisd.config.threepid.medium.EmailConfig;
import java.util.HashMap;
import java.util.Map;
public class ThreePidConfig {
private Map<String, JsonObject> medium = new HashMap<>();
public ThreePidConfig() {
EmailConfig emailCfg = new EmailConfig();
}
public Map<String, JsonObject> getMedium() {
return medium;
}
public void setMedium(Map<String, JsonObject> medium) {
this.medium = medium;
}
public void build() {
// no-op
}
}

View File

@@ -31,8 +31,8 @@ public class EmailSmtpConfig {
private transient final Logger log = LoggerFactory.getLogger(EmailSmtpConfig.class);
private String host;
private int port;
private int tls;
private int port = 587;
private int tls = 1;
private String login;
private String password;

View File

@@ -20,18 +20,17 @@
package io.kamax.mxisd.config.threepid.medium;
import io.kamax.mxisd.config.MatrixConfig;
import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
public class EmailConfig {
public class EmailConfig extends MediumConfig {
public static class Identity {
private String from;
private String name;
@@ -55,36 +54,17 @@ public class EmailConfig {
private transient final Logger log = LoggerFactory.getLogger(EmailConfig.class);
private String generator;
private String connector;
private MatrixConfig mxCfg;
private Identity identity = new Identity();
public EmailConfig(MatrixConfig mxCfg) {
this.mxCfg = mxCfg;
public EmailConfig() {
setConnector("smtp");
setGenerator("template");
}
public Identity getIdentity() {
return identity;
}
public String getGenerator() {
return generator;
}
public void setGenerator(String generator) {
this.generator = generator;
}
public String getConnector() {
return connector;
}
public void setConnector(String connector) {
this.connector = connector;
}
@PostConstruct
public void build() {
log.info("--- E-mail config ---");
@@ -97,12 +77,8 @@ public class EmailConfig {
throw new ConfigurationException("connector");
}
log.info("From: {}", identity.getFrom());
if (StringUtils.isBlank(identity.getName())) {
identity.setName(WordUtils.capitalize(mxCfg.getDomain()) + " Identity Server");
}
log.info("Name: {}", identity.getName());
log.info("From: {}", getIdentity().getFrom());
log.info("Name: {}", getIdentity().getName());
log.info("Generator: {}", getGenerator());
log.info("Connector: {}", getConnector());
}

View File

@@ -29,6 +29,13 @@ public class EmailTemplateConfig extends GenericTemplateConfig {
private transient final Logger log = LoggerFactory.getLogger(EmailTemplateConfig.class);
public EmailTemplateConfig() {
setInvite("classpath:threepids/email/invite-template.eml");
getGeneric().put("matrixId", "classpath:threepids/email/mxid-template.eml");
getSession().getValidation().setLocal("classpath:threepids/email/validate-local-template.eml");
getSession().getValidation().setRemote("classpath:threepids/email/validate-remote-template.eml");
}
@PostConstruct
public void build() {
log.info("--- E-mail Generator templates config ---");

View File

@@ -0,0 +1,67 @@
/*
* mxisd - Matrix Identity Server Daemon
* Copyright (C) 2018 Kamax Sàrl
*
* https://www.kamax.io/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.kamax.mxisd.config.threepid.medium;
import com.google.gson.JsonObject;
import java.util.HashMap;
import java.util.Map;
public class MediumConfig {
private String connector;
private Map<String, JsonObject> connectors = new HashMap<>();
private String generator;
private Map<String, JsonObject> generators = new HashMap<>();
public String getConnector() {
return connector;
}
public void setConnector(String connector) {
this.connector = connector;
}
public Map<String, JsonObject> getConnectors() {
return connectors;
}
public void setConnectors(Map<String, JsonObject> connectors) {
this.connectors = connectors;
}
public String getGenerator() {
return generator;
}
public void setGenerator(String generator) {
this.generator = generator;
}
public Map<String, JsonObject> getGenerators() {
return generators;
}
public void setGenerators(Map<String, JsonObject> generators) {
this.generators = generators;
}
}

View File

@@ -20,50 +20,16 @@
package io.kamax.mxisd.config.threepid.medium;
import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
public class PhoneConfig {
public class PhoneConfig extends MediumConfig {
private transient final Logger log = LoggerFactory.getLogger(PhoneConfig.class);
private String generator;
private String connector;
public String getGenerator() {
return generator;
}
public void setGenerator(String generator) {
this.generator = generator;
}
public String getConnector() {
return connector;
}
public void setConnector(String connector) {
this.connector = connector;
}
@PostConstruct
public void build() {
log.info("--- Phone config ---");
if (StringUtils.isBlank(getGenerator())) {
throw new ConfigurationException("generator");
}
if (StringUtils.isBlank(getConnector())) {
throw new ConfigurationException("connector");
}
log.info("Generator: {}", getGenerator());
log.info("Connector: {}", getConnector());
public PhoneConfig() {
setConnector("twilio");
setGenerator("template");
}
}

View File

@@ -29,6 +29,13 @@ public class PhoneSmsTemplateConfig extends GenericTemplateConfig {
private transient final Logger log = LoggerFactory.getLogger(EmailTemplateConfig.class);
public PhoneSmsTemplateConfig() {
setInvite("classpath:threepids/sms/invite-template.txt");
getGeneric().put("matrixId", "classpath:threepids/email/mxid-template.eml");
getSession().getValidation().setLocal("classpath:threepids/sms/validate-local-template.txt");
getSession().getValidation().setRemote("classpath:threepids/sms/validate-remote-template.txt");
}
@PostConstruct
public void build() {
log.info("--- SMS Generator templates config ---");

View File

@@ -24,6 +24,7 @@ import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
public class WordpressConfig {
@@ -76,8 +77,14 @@ public class WordpressConfig {
public static class Query {
private Map<String, String> threepid;
private Map<String, String> directory;
private Map<String, String> threepid = new HashMap<>();
private Map<String, String> directory = new HashMap<>();
public Query() {
threepid.put("email", "SELECT user_login as uid FROM %TABLE_PREFIX%users WHERE user_email = ?");
directory.put("name", "SELECT DISTINCT user_login, display_name FROM %TABLE_PREFIX%users u LEFT JOIN %TABLE_PREFIX%usermeta m ON m.user_id = u.id WHERE u.display_name LIKE ? OR (m.meta_key = 'nickname' AND m.meta_value = ?) OR (m.meta_key = 'first_name' AND m.meta_value = ?) OR (m.meta_key = 'last_name' AND m.meta_value = ?)");
directory.put("threepid", "SELECT DISTINCT user_login, display_name FROM %TABLE_PREFIX%users WHERE user_email LIKE ?");
}
public Map<String, String> getThreepid() {
return threepid;
@@ -95,13 +102,17 @@ public class WordpressConfig {
this.directory = directory;
}
public void build() {
// FIXME replace table prefix
}
}
public static class Sql {
private String type;
private String type = "mysql";
private String connection;
private String tablePrefix;
private String tablePrefix = "wp_";
private Query query;
public String getType() {

View File

@@ -20,11 +20,11 @@
package io.kamax.mxisd.invitation;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import io.kamax.matrix.MatrixID;
import io.kamax.matrix.crypto.SignatureManager;
import io.kamax.matrix.json.GsonUtil;
import io.kamax.mxisd.config.InvitationConfig;
import io.kamax.mxisd.dns.FederationDnsOverwrite;
import io.kamax.mxisd.exception.BadRequestException;
@@ -51,8 +51,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xbill.DNS.*;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import java.io.IOException;
@@ -76,28 +74,29 @@ public class InvitationManager {
private NotificationManager notifMgr;
private CloseableHttpClient client;
private Gson gson;
private Timer refreshTimer;
private Map<String, IThreePidInviteReply> invitations = new ConcurrentHashMap<>();
public InvitationManager(InvitationConfig cfg, IStorage storage, LookupStrategy lookupMgr, SignatureManager signMgr, FederationDnsOverwrite dns, NotificationManager notifMgr) {
public InvitationManager(
InvitationConfig cfg,
IStorage storage,
LookupStrategy lookupMgr,
SignatureManager signMgr,
FederationDnsOverwrite dns,
NotificationManager notifMgr
) {
this.cfg = cfg;
this.storage = storage;
this.lookupMgr = lookupMgr;
this.signMgr = signMgr;
this.dns = dns;
this.notifMgr = notifMgr;
}
@PostConstruct
private void postConstruct() {
gson = new Gson();
log.info("Loading saved invites");
Collection<ThreePidInviteIO> ioList = storage.getInvites();
ioList.forEach(io -> {
log.info("Processing invite {}", gson.toJson(io));
log.info("Processing invite {}", GsonUtil.get().toJson(io));
ThreePidInvite invite = new ThreePidInvite(
MatrixID.asAcceptable(io.getSender()),
io.getMedium(),
@@ -133,12 +132,11 @@ public class InvitationManager {
}
}
}, 5000L, TimeUnit.MILLISECONDS.convert(cfg.getResolution().getTimer(), TimeUnit.MINUTES));
}
@PreDestroy
private void preDestroy() {
refreshTimer.cancel();
ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
refreshTimer.cancel();
ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES);
}));
}
private String getId(IThreePidInvite invite) {

View File

@@ -1,12 +1,3 @@
# DO NOT USE THIS FILE AS-IS FOR YOUR INITIAL CONFIGURATION
# ONLY TAKE THE SPECIFIC SECTION YOU WANT TO CONFIGURE
#
# For more information about configuration, visit https://github.com/kamax-matrix/mxisd/blob/master/docs/configure.md
spring:
main:
banner-mode: 'off'
logging:
level:
org:
@@ -19,285 +10,6 @@ logging:
pattern:
console: '%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:%5p} [%15.15t] %35.35logger{34} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}'
server:
port: 8090
matrix:
domain: ''
identity:
servers:
matrix-org:
- 'https://matrix.org'
listener:
url: ''
localpart: ''
token:
as: ''
hs: ''
lookup:
recursive:
enabled: true
allowedCidr:
- '127.0.0.0/8'
- '10.0.0.0/8'
- '172.16.0.0/12'
- '192.168.0.0/16'
- '::1/128'
bridge:
enabled: false
recursiveOnly: true
rest:
endpoints:
auth: '/_mxisd/backend/api/v1/auth/login'
directory: '/_mxisd/backend/api/v1/directory/user/search'
identity:
single: '/_mxisd/backend/api/v1/identity/lookup/single'
bulk: '/_mxisd/backend/api/v1/identity/lookup/bulk'
profile:
displayName: '/_mxisd/backend/api/v1/profile/displayName'
threepids: '/_mxisd/backend/api/v1/profile/threepids'
roles: '/_mxisd/backend/api/v1/profile/roles'
ldap:
enabled: false
filter: ''
connection:
host: ''
tls: false
port: 389
bindDn: ''
bindPassword: ''
baseDn: ''
attribute:
uid:
type: 'uid'
value: 'userPrincipalName'
name: 'displayName'
threepid:
email:
- 'mailPrimaryAddress'
- 'mail'
- 'otherMailbox'
msisdn:
- 'telephoneNumber'
- 'mobile'
- 'homePhone'
- 'otherTelephone'
- 'otherMobile'
- 'otherHomePhone'
auth:
filter: ''
directory:
attribute:
other: []
filter: ''
identity:
filter: ''
token: '%3pid'
medium:
email: ''
msisdn: ''
netiq:
enabled: false
filter: ''
connection:
host: ''
tls: false
port: 389
bindDn: ''
bindPassword: ''
baseDn: ''
attribute:
uid:
type: 'uid'
value: 'userPrincipalName'
name: 'displayName'
threepid:
email:
- 'mailPrimaryAddress'
- 'mail'
- 'otherMailbox'
msisdn:
- 'telephoneNumber'
- 'mobile'
- 'homePhone'
- 'otherTelephone'
- 'otherMobile'
- 'otherHomePhone'
auth:
filter: ''
directory:
attribute:
other: []
filter: ''
identity:
filter: ''
token: '%3pid'
medium:
email: ''
msisdn: ''
firebase:
enabled: false
sql:
enabled: false
type: 'sqlite'
connection: ''
auth:
enabled: false
directory:
enabled: false
query:
name:
type: 'localpart'
value: 'SELECT 1'
threepid:
type: 'localpart'
value: 'SELECT 1'
identity:
type: 'mxid'
query: 'SELECT user_id AS uid FROM user_threepids WHERE medium = ? AND address = ?'
profile:
threepid:
query: 'SELECT medium, address FROM user_threepids WHERE user_id = ?'
wordpress:
enabled: false
sql:
type: 'mysql'
tablePrefix: 'wp_'
query:
threepid:
email: 'SELECT user_login as uid FROM ${wordpress.sql.tablePrefix}users WHERE user_email = ?'
directory:
name: "SELECT DISTINCT user_login, display_name FROM ${wordpress.sql.tablePrefix}users u LEFT JOIN ${wordpress.sql.tablePrefix}usermeta m ON m.user_id = u.id WHERE u.display_name LIKE ? OR (m.meta_key = 'nickname' AND m.meta_value = ?) OR (m.meta_key = 'first_name' AND m.meta_value = ?) OR (m.meta_key = 'last_name' AND m.meta_value = ?);"
threepid: 'SELECT DISTINCT user_login, display_name FROM ${wordpress.sql.tablePrefix}users WHERE user_email LIKE ?'
forward:
servers: []
threepid:
medium:
email:
identity:
from: ''
name: ''
connector: 'smtp'
generator: 'template'
connectors:
smtp:
host: ''
port: 587
tls: 1
login: ''
password: ''
generators:
template:
invite: 'classpath:threepids/email/invite-template.eml'
generic:
matrixId: 'classpath:threepids/email/mxid-template.eml'
session:
validation:
local: 'classpath:threepids/email/validate-local-template.eml'
remote: 'classpath:threepids/email/validate-remote-template.eml'
msisdn:
connector: 'twilio'
generator: 'template'
connectors:
twilio:
accountSid: ''
authToken: ''
number: ''
generators:
template:
invite: 'classpath:threepids/sms/invite-template.txt'
session:
validation:
local: 'classpath:threepids/sms/validate-local-template.txt'
remote: 'classpath:threepids/sms/validate-remote-template.txt'
session:
policy:
validation:
enabled: true
forLocal:
enabled: true
toLocal: true
toRemote:
enabled: true
server: 'matrix-org'
forRemote:
enabled: true
toLocal: false
toRemote:
enabled: true
server: 'matrix-org'
notification:
# handler:
# 3PID-medium: 'handlerId'
handlers:
sendgrid:
api:
key: ''
identity:
from: ''
name: ''
templates:
invite:
subject: ''
body:
text: ''
html: ''
session:
validation:
local:
subject: ''
body:
text: ''
html: ''
remote:
subject: ''
body:
text: ''
html: ''
view:
session:
local:
onTokenSubmit:
success: 'session/local/tokenSubmitSuccess'
failure: 'session/local/tokenSubmitFailure'
localRemote:
onTokenSubmit:
success: 'session/localRemote/tokenSubmitSuccess'
failure: 'session/local/tokenSubmitFailure'
remote:
onRequest:
success: 'session/remote/requestSuccess'
failure: 'session/remote/requestFailure'
onCheck:
success: 'session/remote/checkSuccess'
failure: 'session/remote/checkFailure'
invite:
resolution:
recursive: true
timer: 1
storage:
backend: 'sqlite'
directory:
exclude:
homeserver: false
---
spring:
profiles: systemd