From 6e516c6df8c5008a69eb603d84ea92ef42fdbc95 Mon Sep 17 00:00:00 2001 From: Felipe Cecagno Date: Wed, 6 May 2015 00:11:02 -0300 Subject: [PATCH 1/3] promote bbb-webhooks to a well-supported module (removed from labs) --- {labs/bbb-webhooks => bbb-webhooks}/.gitignore | 0 {labs/bbb-webhooks => bbb-webhooks}/.nvmrc | 0 {labs/bbb-webhooks => bbb-webhooks}/README.md | 0 {labs/bbb-webhooks => bbb-webhooks}/app.js | 0 {labs/bbb-webhooks => bbb-webhooks}/application.coffee | 0 {labs/bbb-webhooks => bbb-webhooks}/callback_emitter.coffee | 0 {labs/bbb-webhooks => bbb-webhooks}/config.coffee | 0 {labs/bbb-webhooks => bbb-webhooks}/config/bbb-webhooks.logrotate | 0 {labs/bbb-webhooks => bbb-webhooks}/config/monit-bbb-webhooks | 0 .../config/upstart-bbb-webhooks.conf | 0 {labs/bbb-webhooks => bbb-webhooks}/config/webhooks.nginx | 0 {labs/bbb-webhooks => bbb-webhooks}/config_local.coffee.example | 0 {labs/bbb-webhooks => bbb-webhooks}/extra/events.js | 0 {labs/bbb-webhooks => bbb-webhooks}/extra/post_catcher.js | 0 {labs/bbb-webhooks => bbb-webhooks}/hook.coffee | 0 {labs/bbb-webhooks => bbb-webhooks}/id_mapping.coffee | 0 {labs/bbb-webhooks => bbb-webhooks}/log/.gitkeep | 0 {labs/bbb-webhooks => bbb-webhooks}/logger.coffee | 0 {labs/bbb-webhooks => bbb-webhooks}/package.json | 0 {labs/bbb-webhooks => bbb-webhooks}/utils.coffee | 0 {labs/bbb-webhooks => bbb-webhooks}/web_hooks.coffee | 0 {labs/bbb-webhooks => bbb-webhooks}/web_server.coffee | 0 22 files changed, 0 insertions(+), 0 deletions(-) rename {labs/bbb-webhooks => bbb-webhooks}/.gitignore (100%) rename {labs/bbb-webhooks => bbb-webhooks}/.nvmrc (100%) rename {labs/bbb-webhooks => bbb-webhooks}/README.md (100%) rename {labs/bbb-webhooks => bbb-webhooks}/app.js (100%) rename {labs/bbb-webhooks => bbb-webhooks}/application.coffee (100%) rename {labs/bbb-webhooks => bbb-webhooks}/callback_emitter.coffee (100%) rename {labs/bbb-webhooks => bbb-webhooks}/config.coffee (100%) rename {labs/bbb-webhooks => bbb-webhooks}/config/bbb-webhooks.logrotate (100%) rename {labs/bbb-webhooks => bbb-webhooks}/config/monit-bbb-webhooks (100%) rename {labs/bbb-webhooks => bbb-webhooks}/config/upstart-bbb-webhooks.conf (100%) rename {labs/bbb-webhooks => bbb-webhooks}/config/webhooks.nginx (100%) rename {labs/bbb-webhooks => bbb-webhooks}/config_local.coffee.example (100%) rename {labs/bbb-webhooks => bbb-webhooks}/extra/events.js (100%) rename {labs/bbb-webhooks => bbb-webhooks}/extra/post_catcher.js (100%) rename {labs/bbb-webhooks => bbb-webhooks}/hook.coffee (100%) rename {labs/bbb-webhooks => bbb-webhooks}/id_mapping.coffee (100%) rename {labs/bbb-webhooks => bbb-webhooks}/log/.gitkeep (100%) rename {labs/bbb-webhooks => bbb-webhooks}/logger.coffee (100%) rename {labs/bbb-webhooks => bbb-webhooks}/package.json (100%) rename {labs/bbb-webhooks => bbb-webhooks}/utils.coffee (100%) rename {labs/bbb-webhooks => bbb-webhooks}/web_hooks.coffee (100%) rename {labs/bbb-webhooks => bbb-webhooks}/web_server.coffee (100%) diff --git a/labs/bbb-webhooks/.gitignore b/bbb-webhooks/.gitignore similarity index 100% rename from labs/bbb-webhooks/.gitignore rename to bbb-webhooks/.gitignore diff --git a/labs/bbb-webhooks/.nvmrc b/bbb-webhooks/.nvmrc similarity index 100% rename from labs/bbb-webhooks/.nvmrc rename to bbb-webhooks/.nvmrc diff --git a/labs/bbb-webhooks/README.md b/bbb-webhooks/README.md similarity index 100% rename from labs/bbb-webhooks/README.md rename to bbb-webhooks/README.md diff --git a/labs/bbb-webhooks/app.js b/bbb-webhooks/app.js similarity index 100% rename from labs/bbb-webhooks/app.js rename to bbb-webhooks/app.js diff --git a/labs/bbb-webhooks/application.coffee b/bbb-webhooks/application.coffee similarity index 100% rename from labs/bbb-webhooks/application.coffee rename to bbb-webhooks/application.coffee diff --git a/labs/bbb-webhooks/callback_emitter.coffee b/bbb-webhooks/callback_emitter.coffee similarity index 100% rename from labs/bbb-webhooks/callback_emitter.coffee rename to bbb-webhooks/callback_emitter.coffee diff --git a/labs/bbb-webhooks/config.coffee b/bbb-webhooks/config.coffee similarity index 100% rename from labs/bbb-webhooks/config.coffee rename to bbb-webhooks/config.coffee diff --git a/labs/bbb-webhooks/config/bbb-webhooks.logrotate b/bbb-webhooks/config/bbb-webhooks.logrotate similarity index 100% rename from labs/bbb-webhooks/config/bbb-webhooks.logrotate rename to bbb-webhooks/config/bbb-webhooks.logrotate diff --git a/labs/bbb-webhooks/config/monit-bbb-webhooks b/bbb-webhooks/config/monit-bbb-webhooks similarity index 100% rename from labs/bbb-webhooks/config/monit-bbb-webhooks rename to bbb-webhooks/config/monit-bbb-webhooks diff --git a/labs/bbb-webhooks/config/upstart-bbb-webhooks.conf b/bbb-webhooks/config/upstart-bbb-webhooks.conf similarity index 100% rename from labs/bbb-webhooks/config/upstart-bbb-webhooks.conf rename to bbb-webhooks/config/upstart-bbb-webhooks.conf diff --git a/labs/bbb-webhooks/config/webhooks.nginx b/bbb-webhooks/config/webhooks.nginx similarity index 100% rename from labs/bbb-webhooks/config/webhooks.nginx rename to bbb-webhooks/config/webhooks.nginx diff --git a/labs/bbb-webhooks/config_local.coffee.example b/bbb-webhooks/config_local.coffee.example similarity index 100% rename from labs/bbb-webhooks/config_local.coffee.example rename to bbb-webhooks/config_local.coffee.example diff --git a/labs/bbb-webhooks/extra/events.js b/bbb-webhooks/extra/events.js similarity index 100% rename from labs/bbb-webhooks/extra/events.js rename to bbb-webhooks/extra/events.js diff --git a/labs/bbb-webhooks/extra/post_catcher.js b/bbb-webhooks/extra/post_catcher.js similarity index 100% rename from labs/bbb-webhooks/extra/post_catcher.js rename to bbb-webhooks/extra/post_catcher.js diff --git a/labs/bbb-webhooks/hook.coffee b/bbb-webhooks/hook.coffee similarity index 100% rename from labs/bbb-webhooks/hook.coffee rename to bbb-webhooks/hook.coffee diff --git a/labs/bbb-webhooks/id_mapping.coffee b/bbb-webhooks/id_mapping.coffee similarity index 100% rename from labs/bbb-webhooks/id_mapping.coffee rename to bbb-webhooks/id_mapping.coffee diff --git a/labs/bbb-webhooks/log/.gitkeep b/bbb-webhooks/log/.gitkeep similarity index 100% rename from labs/bbb-webhooks/log/.gitkeep rename to bbb-webhooks/log/.gitkeep diff --git a/labs/bbb-webhooks/logger.coffee b/bbb-webhooks/logger.coffee similarity index 100% rename from labs/bbb-webhooks/logger.coffee rename to bbb-webhooks/logger.coffee diff --git a/labs/bbb-webhooks/package.json b/bbb-webhooks/package.json similarity index 100% rename from labs/bbb-webhooks/package.json rename to bbb-webhooks/package.json diff --git a/labs/bbb-webhooks/utils.coffee b/bbb-webhooks/utils.coffee similarity index 100% rename from labs/bbb-webhooks/utils.coffee rename to bbb-webhooks/utils.coffee diff --git a/labs/bbb-webhooks/web_hooks.coffee b/bbb-webhooks/web_hooks.coffee similarity index 100% rename from labs/bbb-webhooks/web_hooks.coffee rename to bbb-webhooks/web_hooks.coffee diff --git a/labs/bbb-webhooks/web_server.coffee b/bbb-webhooks/web_server.coffee similarity index 100% rename from labs/bbb-webhooks/web_server.coffee rename to bbb-webhooks/web_server.coffee From 4051c97a9d6b8e7ed8c6ad6841b431e784c01d46 Mon Sep 17 00:00:00 2001 From: Felipe Cecagno Date: Wed, 6 May 2015 11:24:50 -0300 Subject: [PATCH 2/3] added some code to bbb-conf in order to check the webhooks app is well configured, and also to update the security key --- bigbluebutton-config/bin/bbb-conf | 35 ++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/bigbluebutton-config/bin/bbb-conf b/bigbluebutton-config/bin/bbb-conf index e3fa599a9a..8173d667ad 100644 --- a/bigbluebutton-config/bin/bbb-conf +++ b/bigbluebutton-config/bin/bbb-conf @@ -549,6 +549,16 @@ fi if [ $SALT ]; then need_root + change_var_salt ${SERVLET_DIR}/bigbluebutton/WEB-INF/classes/bigbluebutton.properties securitySalt $SALT + + if [ -f /usr/local/bigbluebutton/bbb-webhooks/config_local.coffee ]; then + sed -i "s|\(^[ \t]*config.bbb.sharedSecret[ =]*\).*|\1\"$SALT\"|g" /usr/local/bigbluebutton/bbb-webhooks/config_local.coffee + fi + + if [ -f /usr/local/bigbluebutton/bbb-webhooks/extra/post_catcher.js ]; then + sed -i "s|\(^[ \t]*var shared_secret[ =]*\)[^;]*|\1\"$SALT\"|g" /usr/local/bigbluebutton/bbb-webhooks/extra/post_catcher.js + fi + change_var_salt ${SERVLET_DIR}/bigbluebutton/WEB-INF/classes/bigbluebutton.properties securitySalt $SALT echo "Changed BigBlueButton's shared secret to $SALT" echo @@ -731,6 +741,30 @@ check_configuration() { fi fi + BBB_SALT=$(cat ${SERVLET_DIR}/bigbluebutton/WEB-INF/classes/bigbluebutton.properties | tr -d '\r' | sed -n '/securitySalt/{s/.*=//;p}') + NGINX_IP=$(cat /etc/nginx/sites-available/bigbluebutton | sed -n '/server_name/{s/.*name[ ]*//;s/;//;p}') + + if [ -f /usr/local/bigbluebutton/bbb-webhooks/config_local.coffee ]; then + WEBHOOKS_SALT=$(cat /usr/local/bigbluebutton/bbb-webhooks/config_local.coffee | grep '^[ \t]*config.bbb.sharedSecret[ =]*' | cut -d '"' -f2) + + if [ "$BBB_SALT" != "$WEBHOOKS_SALT" ]; then + echo "# Warning: Webhooks API Salt mismatch: " + echo "# ${SERVLET_DIR}/bigbluebutton/WEB-INF/classes/bigbluebutton.properties = $BBB_SALT" + echo "# /usr/local/bigbluebutton/bbb-webhooks/config_local.coffee = $WEBHOOKS_SALT" + echo + fi + + WEBHOOKS_PROXY_PORT=$(cat /etc/bigbluebutton/nginx/webhooks.nginx | grep '^[ \t]*proxy_pass[ \t]*' | sed 's|.*http[s]\?://[^:]*:\([^;]*\);.*|\1|g') + WEBHOOKS_APP_PORT=$(cat /usr/local/bigbluebutton/bbb-webhooks/config_local.coffee | grep '^[ \t]*config.server.port[ =]*' | cut -d '=' -f2 | xargs) + + if [ "$WEBHOOKS_PROXY_PORT" != "$WEBHOOKS_APP_PORT" ]; then + echo "# Warning: Webhooks port mismatch: " + echo "# /etc/bigbluebutton/nginx/webhooks.nginx = $WEBHOOKS_PROXY_PORT" + echo "# /usr/local/bigbluebutton/bbb-webhooks/config_local.coffee = $WEBHOOKS_APP_PORT" + echo + fi + fi + if [ -f ${SERVLET_DIR}/lti/WEB-INF/classes/lti.properties ]; then LTI_SALT=$(cat ${SERVLET_DIR}/lti/WEB-INF/classes/lti.properties | tr -d '\r' | sed -n '/^bigbluebuttonSalt/{s/.*=//;p}') BBB_SALT=$(cat ${SERVLET_DIR}/bigbluebutton/WEB-INF/classes/bigbluebutton.properties | tr -d '\r' | sed -n '/securitySalt/{s/.*=//;p}') @@ -1574,4 +1608,3 @@ if [ $WATCH ]; then need_root watch -n 2 "top -n 1 -b | head -n 5; echo; bbb-conf --network; bbb-conf --debug" fi - From 6ad7ce3318c0503790049cfe5e444cbe7843fed0 Mon Sep 17 00:00:00 2001 From: Felipe Cecagno Date: Wed, 6 May 2015 11:25:42 -0300 Subject: [PATCH 3/3] updating post_catcher in order to listen on localhost --- bbb-webhooks/extra/post_catcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bbb-webhooks/extra/post_catcher.js b/bbb-webhooks/extra/post_catcher.js index 2760ded1bc..2ea9fa701c 100644 --- a/bbb-webhooks/extra/post_catcher.js +++ b/bbb-webhooks/extra/post_catcher.js @@ -11,8 +11,8 @@ var bodyParser = require('body-parser'); // server configs var port = 3006; // port in which to run this app var shared_secret = "33e06642a13942004fd83b3ba6e4104a"; // shared secret of your server -var domain = "10.0.3.36"; // address of your server -var target_domain = "10.0.3.36:3005"; // address of the webhooks app +var domain = "127.0.0.1"; // address of your server +var target_domain = "127.0.0.1:3005"; // address of the webhooks app var encodeForUrl = function(value) { return encodeURIComponent(value)