From 87cc109bf1753d4a10ca7b9143b6a655cd4d1baa Mon Sep 17 00:00:00 2001 From: Evilham Date: Thu, 21 Apr 2022 13:20:30 +0200 Subject: [PATCH] [__jitsi_meet*] Make rooms on different domains not equivalent This is a backwards-compatible change. We switch the approach from "treat all domains as if they were the main domain" to: "each domain has its own prosody settings". This works perfectly fine, even with secured domains. There is a caveat with secured domains, in that they use the main domain to log in; this means that users are shared across all domains (as they were before this commit). This is due to jicofo refusing to start meetings from a domain that is not configured, and it only accepting one domain. Right now, this is acceptable, however we could want to authenticate against e.g. different LDAP / IMAP servers in the future, so this would need addressing at that stage. Probably the best way to solve it is by patching jicofo, so it accepts starting conferences from multiple domains and getting that patch upstream. Sponsored by: camilion.eu, eXO.cat --- type/__jitsi_meet/files/prosody.cfg.lua.sh | 1 + type/__jitsi_meet/gencode-remote | 3 +- type/__jitsi_meet/manifest | 24 ++- .../files/_update_jitsi_configurations.sh | 1 + type/__jitsi_meet_domain/files/config.js.sh | 19 +- type/__jitsi_meet_domain/files/nginx.sh | 4 +- .../files/prosody.cfg.lua.sh | 199 ++++++++++++++++++ .../files/prosody.cfg.lua.sh.orig | 129 ++++++++++++ type/__jitsi_meet_domain/man.rst | 18 +- type/__jitsi_meet_domain/manifest | 35 +++ 10 files changed, 403 insertions(+), 30 deletions(-) create mode 120000 type/__jitsi_meet/files/prosody.cfg.lua.sh create mode 100644 type/__jitsi_meet_domain/files/prosody.cfg.lua.sh create mode 100644 type/__jitsi_meet_domain/files/prosody.cfg.lua.sh.orig diff --git a/type/__jitsi_meet/files/prosody.cfg.lua.sh b/type/__jitsi_meet/files/prosody.cfg.lua.sh new file mode 120000 index 0000000..93678b9 --- /dev/null +++ b/type/__jitsi_meet/files/prosody.cfg.lua.sh @@ -0,0 +1 @@ +../../__jitsi_meet_domain/files/prosody.cfg.lua.sh \ No newline at end of file diff --git a/type/__jitsi_meet/gencode-remote b/type/__jitsi_meet/gencode-remote index 7d181b7..670c7be 100755 --- a/type/__jitsi_meet/gencode-remote +++ b/type/__jitsi_meet/gencode-remote @@ -4,8 +4,7 @@ if grep -qE "^__file/etc/nginx" "${__messages_in}"; then echo "service nginx reload" fi -JITSI_HOST="${__object_id}" -if grep -qE "^(__line/jitsi_jicofo_secured_domains|__file/etc/prosody/conf.d/${JITSI_HOST}.zauth.cfg.lua|__file/etc/jitsi/jicofo/jicofo.conf)" "${__messages_in}"; then +if grep -qE "^(__line/jitsi_jicofo_secured_domains|(__file|__link)/etc/prosody/conf.d/|__file/etc/jitsi/jicofo/jicofo.conf)" "${__messages_in}"; then echo "systemctl restart prosody" echo "systemctl restart jicofo" echo "systemctl restart jitsi-videobridge2" diff --git a/type/__jitsi_meet/manifest b/type/__jitsi_meet/manifest index e9ed5c6..02716a0 100755 --- a/type/__jitsi_meet/manifest +++ b/type/__jitsi_meet/manifest @@ -161,18 +161,22 @@ else SECURED_DOMAINS_STATE='absent' fi -__file "/etc/prosody/conf.d/${JITSI_HOST}.zauth.cfg.lua" \ - --owner prosody --group prosody --mode 0440 \ - --state ${SECURED_DOMAINS_STATE} \ - --source - <. - // authdomain: '${JITSI_HOST}', + // NOTE [cdist]: if we use '${DOMAIN}', jicofo won't start the meeting + authdomain: '${JITSI_HOST}', // Focus component domain. Defaults to focus.. - // focus: 'focus.${JITSI_HOST}', + focus: 'focus.${JITSI_HOST}', // XMPP MUC domain. FIXME: use XEP-0030 to discover it. - muc: 'conference.${JITSI_HOST}' + muc: 'conference.${DOMAIN}' }, // BOSH URL. FIXME: use XEP-0156 to discover it. @@ -31,12 +32,12 @@ var config = { bosh: '///http-bind', // Websocket URL - // websocket: 'wss://${JITSI_HOST}/xmpp-websocket', + // websocket: 'wss://${DOMAIN}/xmpp-websocket', // The real JID of focus participant - can be overridden here // Do not change username - FIXME: Make focus username configurable // https://github.com/jitsi/jitsi-meet/issues/7376 - // focusUserJid: 'focus@auth.${JITSI_HOST}', + focusUserJid: 'focus@auth.${JITSI_HOST}', // Testing / experimental features. @@ -270,9 +271,9 @@ $(if [ -n "${VIDEO_CONSTRAINTS}" ]; then echo "${VIDEO_CONSTRAINTS},"; fi) // appKey: '' // Specify your app key here. // // A URL to redirect the user to, after authenticating // // by default uses: - // // 'https://${JITSI_HOST}/static/oauth.html' + // // 'https://${DOMAIN}/static/oauth.html' // redirectURI: - // 'https://${JITSI_HOST}/subfolder/static/oauth.html' + // 'https://${DOMAIN}/subfolder/static/oauth.html' // }, // When integrations like dropbox are enabled only that will be shown, // by enabling fileRecordingsServiceEnabled, we show both the integrations diff --git a/type/__jitsi_meet_domain/files/nginx.sh b/type/__jitsi_meet_domain/files/nginx.sh index 6e874c1..e678dce 100644 --- a/type/__jitsi_meet_domain/files/nginx.sh +++ b/type/__jitsi_meet_domain/files/nginx.sh @@ -100,7 +100,7 @@ server { proxy_set_header X-Forwarded-For \$remote_addr; # Prevision for 'multi-domain' jitsi instances # https://community.jitsi.org/t/same-jitsi-meet-instance-with-multiple-domain-names/17391 - proxy_set_header Host ${JITSI_HOST}; + proxy_set_header Host ${DOMAIN}; } # xmpp websockets @@ -111,7 +111,7 @@ server { proxy_set_header Connection "upgrade"; # Prevision for 'multi-domain' jitsi instances # https://community.jitsi.org/t/same-jitsi-meet-instance-with-multiple-domain-names/17391 - proxy_set_header Host ${JITSI_HOST}; + proxy_set_header Host ${DOMAIN}; tcp_nodelay on; } diff --git a/type/__jitsi_meet_domain/files/prosody.cfg.lua.sh b/type/__jitsi_meet_domain/files/prosody.cfg.lua.sh new file mode 100644 index 0000000..928ce32 --- /dev/null +++ b/type/__jitsi_meet_domain/files/prosody.cfg.lua.sh @@ -0,0 +1,199 @@ +#!/bin/sh -eu + +# Source: +# https://github.com/jitsi/jitsi-meet/blob/master/doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example +FOCUS_USER="focus" +JITSI_DOMAIN="${JITSI_DOMAIN:-${JITSI_HOST:?}}" +# PROSODY_MAIN_CONFIG: defined in __jitsi_meet, empty in __jitsi_meet_domain +PROSODY_SECUREDOMAIN_START="--[[" +PROSODY_SECUREDOMAIN_END="--]]" +if [ -n "${PROSODY_MAIN_CONFIG}" ]; then + PROSODY_MAIN_START="" + PROSODY_MAIN_END="" + PROSODY_DOMAIN_START="--[[" + PROSODY_DOMAIN_END="--]]" +else + PROSODY_MAIN_START="--[[" + PROSODY_MAIN_END="--]]" + PROSODY_DOMAIN_START="" + PROSODY_DOMAIN_END="" + if [ -n "${SECURED_DOMAINS}" ]; then + PROSODY_SECUREDOMAIN_START="" + PROSODY_SECUREDOMAIN_END="" + fi +fi +# Websockets haven't been fully tested in this type and don't work reliably +PROSODY_WEBSOCKET="-- " + +# shellcheck disable=SC2034 # This is intended to be included +PROSODY_CONFIG="$(cat <