diff --git a/application.example.yaml b/application.example.yaml index 62c9471..68bb563 100644 --- a/application.example.yaml +++ b/application.example.yaml @@ -53,6 +53,43 @@ lookup: - '192.168.0.0/16' - '::1/128' + # In case no binding is found, query an application server which implements the single lookup end-point + # to return bridge virtual user that would allow the user to be contacted directly by the said bridge. + # + # IMPORTANT: This bypass the regular Invite system of the Homeserver. It will be up to the Application Server + # to handle such invite. Also, if the bridged user were to actually join Matrix later, or if a 3PID binding is found + # room rights and history would not be transferred, as it would appear as a regular Matrix user to the Homeserver. + # + # This configuration is only helpful for Application Services that want to overwrite bridging for 3PID that are + # handled by the Homeserver. Do not enable unless the Application Server specifically supports it! + bridge: + + # Enable unknown 3PID bridging globally + enabled: false + + # Enable unknown 3PID bridging for hosts that are allowed to perform recursive lookups. + # Leaving this setting to true is highly recommended in a standard setup, unless this Identity Server + # is meant to always return a virtual user MXID even for the outside world. + recursiveOnly: true + + # This mechanism can handle the following scenarios: + # + # - Single Application Server for all 3PID types: only configure the server value, comment out the rest. + # + # - Specific Application Server for some 3PID types, default server for the rest: configure the server value and + # each specific 3PID type. + # + # - Only specific 3PID types: do not configure the server value or leave it empty/blank, configure each specific + # 3PID type. + + # Default application server to use for all 3PID types. Remove config item or leave empty/blank to disable. + server: '' + + # Configure each 3PID type with a specific application server. Remove config item or leave empty/blank to disable. + mappings: + email: 'http://localhost:8091' + msisdn: '' + ldap: diff --git a/src/main/groovy/io/kamax/mxisd/config/RecursiveLookupBridgeConfig.groovy b/src/main/groovy/io/kamax/mxisd/config/RecursiveLookupBridgeConfig.groovy new file mode 100644 index 0000000..8c06956 --- /dev/null +++ b/src/main/groovy/io/kamax/mxisd/config/RecursiveLookupBridgeConfig.groovy @@ -0,0 +1,60 @@ +package io.kamax.mxisd.config + +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.InitializingBean +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.context.annotation.Configuration + +@Configuration +@ConfigurationProperties(prefix = "lookup.recursive.bridge") +class RecursiveLookupBridgeConfig implements InitializingBean { + + private Logger log = LoggerFactory.getLogger(RecursiveLookupBridgeConfig.class) + + private boolean enabled + private boolean recursiveOnly + private String server + private Map mappings + + boolean getEnabled() { + return enabled + } + + void setEnabled(boolean enabled) { + this.enabled = enabled + } + + boolean getRecursiveOnly() { + return recursiveOnly + } + + void setRecursiveOnly(boolean recursiveOnly) { + this.recursiveOnly = recursiveOnly + } + + String getServer() { + return server + } + + void setServer(String server) { + this.server = server + } + + Map getMappings() { + return mappings + } + + void setMappings(Map mappings) { + this.mappings = mappings + } + + @Override + void afterPropertiesSet() throws Exception { + log.info("Enabled: {}", getEnabled()) + log.info("Recursive only: {}", getRecursiveOnly()) + log.info("Server: {}", getServer()) + log.info("Mappings: {}", mappings.size()) + } + +} diff --git a/src/main/groovy/io/kamax/mxisd/config/RecursiveLookupConfig.groovy b/src/main/groovy/io/kamax/mxisd/config/RecursiveLookupConfig.groovy index 33c5ec3..5c6a878 100644 --- a/src/main/groovy/io/kamax/mxisd/config/RecursiveLookupConfig.groovy +++ b/src/main/groovy/io/kamax/mxisd/config/RecursiveLookupConfig.groovy @@ -29,6 +29,7 @@ class RecursiveLookupConfig { private boolean enabled private List allowedCidr + private RecursiveLookupBridgeConfig bridge boolean isEnabled() { return enabled @@ -46,4 +47,12 @@ class RecursiveLookupConfig { this.allowedCidr = allowedCidr } + RecursiveLookupBridgeConfig getBridge() { + return bridge + } + + void setBridge(RecursiveLookupBridgeConfig bridge) { + this.bridge = bridge + } + }