From ea5c78db4730151fdb66396b8d7d9697f864700b Mon Sep 17 00:00:00 2001 From: jfederico Date: Mon, 14 Aug 2017 20:26:43 +0000 Subject: [PATCH] Updated unified sample.env and setup default values to some variables --- app/controllers/bbb_controller.rb | 10 +-- app/lib/bbb_api.rb | 4 +- config/application.rb | 14 +-- config/initializers/slack.rb | 17 ++-- env | 124 -------------------------- sample.env | 142 ++++++++++++++++++++++++------ 6 files changed, 140 insertions(+), 171 deletions(-) delete mode 100644 env diff --git a/app/controllers/bbb_controller.rb b/app/controllers/bbb_controller.rb index e8c21be0..6134e320 100644 --- a/app/controllers/bbb_controller.rb +++ b/app/controllers/bbb_controller.rb @@ -205,7 +205,7 @@ class BbbController < ApplicationController if Rails.configuration.enable_youtube_uploading == false then uploadable = 'uploading_disabled' elsif current_user.provider != 'google' - uploadable = 'invalid_provider' + uploadable = 'invalid_provider' else uploadable = (Faraday.head(get_webcams_url(params[:rec_id])).status == 200 && current_user.provider == 'google').to_s end @@ -213,7 +213,7 @@ class BbbController < ApplicationController end def get_webcams_url(recording_id) - uri = URI.parse(ENV['BIGBLUEBUTTON_ENDPOINT']) + uri = URI.parse(Rails.configuration.bigbluebutton_endpoint) uri.scheme + '://' + uri.host + '/presentation/' + recording_id + '/video/webcams.webm' end @@ -291,10 +291,10 @@ class BbbController < ApplicationController actioncable_event('create', params[:id], params[:room_id]) elsif eventName == "meeting_destroyed_event" actioncable_event('destroy', params[:id], params[:room_id]) - + # Since the meeting is destroyed we have no way get the callback url to remove the meeting, so we must build it. remove_url = build_callback_url(params[:id], params[:room_id]) - + # Remove webhook for the meeting. webhook_remove(remove_url) elsif eventName == "user_joined_message" @@ -307,7 +307,7 @@ class BbbController < ApplicationController render head(:ok) && return end - + def build_callback_url(id, room_id) "#{request.base_url}#{relative_root}/rooms/#{room_id}/#{URI.encode(id)}/callback" end diff --git a/app/lib/bbb_api.rb b/app/lib/bbb_api.rb index 6c1ac21d..4f279e1c 100644 --- a/app/lib/bbb_api.rb +++ b/app/lib/bbb_api.rb @@ -20,11 +20,11 @@ module BbbApi META_HOOK_URL = "gl-webhooks-callback-url" def bbb_endpoint - Rails.configuration.bigbluebutton_endpoint || '' + Rails.configuration.bigbluebutton_endpoint end def bbb_secret - Rails.configuration.bigbluebutton_secret || '' + Rails.configuration.bigbluebutton_secret end def bbb diff --git a/config/application.rb b/config/application.rb index 506b8928..e44fd8b8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -37,13 +37,13 @@ module Greenlight config.i18n.fallbacks = {'en' => 'en-US'} # BigBlueButton - config.bigbluebutton_endpoint = ENV['BIGBLUEBUTTON_ENDPOINT'] - config.bigbluebutton_secret = ENV['BIGBLUEBUTTON_SECRET'] + config.bigbluebutton_endpoint = ENV['BIGBLUEBUTTON_ENDPOINT'] || 'http://test-install.blindsidenetworks.com/bigbluebutton/' + config.bigbluebutton_secret = ENV['BIGBLUEBUTTON_SECRET'] || '8cd8ef52e8e101574e400365b55e11a6' - config.use_webhooks = ENV['GREENLIGHT_USE_WEBHOOKS'] == "true" - config.mail_notifications = ENV['GREENLIGHT_MAIL_NOTIFICATIONS'] == "true" - config.disable_guest_access = ENV['DISABLE_GUEST_ACCESS'] == "true" - config.enable_youtube_uploading = ENV['ENABLE_YOUTUBE_UPLOADING'] == "true" + config.use_webhooks = ENV['GREENLIGHT_USE_WEBHOOKS'] && ENV['GREENLIGHT_USE_WEBHOOKS'] == "true" + config.mail_notifications = ENV['GREENLIGHT_MAIL_NOTIFICATIONS'] && ENV['GREENLIGHT_MAIL_NOTIFICATIONS'] == "true" + config.disable_guest_access = ENV['DISABLE_GUEST_ACCESS'] && ENV['DISABLE_GUEST_ACCESS'] == "true" + config.enable_youtube_uploading = ENV['ENABLE_YOUTUBE_UPLOADING'] && ENV['ENABLE_YOUTUBE_UPLOADING'] == "true" # SMTP and action mailer if config.mail_notifications @@ -57,7 +57,7 @@ module Greenlight config.smtp_starttls_auto = ENV['SMTP_STARTTLS_AUTO'].nil? ? true : ENV['SMTP_STARTTLS_AUTO'] config.smtp_tls = ENV['SMTP_TLS'].nil? ? false : ENV['SMTP_TLS'] - config.action_mailer.default_url_options = { host: ENV['GREENLIGHT_DOMAIN'] } + config.action_mailer.default_url_options = { host: ENV['GREENLIGHT_DOMAIN'] || 'localhost' } config.action_mailer.delivery_method = :smtp config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true diff --git a/config/initializers/slack.rb b/config/initializers/slack.rb index 886933f6..057a3e65 100644 --- a/config/initializers/slack.rb +++ b/config/initializers/slack.rb @@ -23,14 +23,15 @@ rescue URI::InvalidURIError false end -if !ENV['SLACK_WEBHOOK'].nil? && !ENV['SLACK_WEBHOOK'].empty? && uri?(ENV['SLACK_WEBHOOK']) then - # Initialize the slack notifier. - Rails.application.config.slack_notifier = Slack::Notifier.new ENV['SLACK_WEBHOOK'] do - defaults channel: ENV['SLACK_CHANNEL'], - username: "BigBlueButton", - icon_url: 'https://avatars3.githubusercontent.com/u/230228?v=3&s=200' - end -else +if !ENV['SLACK_WEBHOOK'] || !ENV['SLACK_CHANNEL'] || !uri?(ENV['SLACK_WEBHOOK']) then # Initialize it to nil (slack not configured) Rails.application.config.slack_notifier = nil + return +end + +# Initialize the slack notifier. +Rails.application.config.slack_notifier = Slack::Notifier.new ENV['SLACK_WEBHOOK'] do + defaults channel: ENV['SLACK_CHANNEL'], + username: "BigBlueButton", + icon_url: 'https://avatars3.githubusercontent.com/u/230228?v=3&s=200' end diff --git a/env b/env deleted file mode 100644 index af1e2ef6..00000000 --- a/env +++ /dev/null @@ -1,124 +0,0 @@ -# Step 1 - Create a secret key for rails -# -# You can generate a secure one through the Greenlight docker image -# with with the command -# -# docker run --rm bigbluebutton/greenlight rake secret -# -SECRET_KEY_BASE= -# Step 2 - Enter credentials for your BigBlueButton Server -# -# The endpoint and secret from your bigbluebutton server. To get these values, run -# the following command on your BigBlueButton server -# -# bbb-conf --secret -# -# and uncomment the following two variables -#BIGBLUEBUTTON_ENDPOINT= -#BIGBLUEBUTTON_SECRET= - -# Twitter Login Provider (optional) -# -# You will need to register the app at https://apps.twitter.com/ -# For the callback URL use 'http:///auth/twitter/callback' -# Once registered copy the ID and Secret here -# -TWITTER_ID= -TWITTER_SECRET= - -# Google Login Provider (optional) -# -# You will need to register for at https://console.developers.google.com/apis/credentials -# Select Oauth client ID -> web application -# For the callback URL use 'http:///auth/google/callback' -# Once registered copy the ID and Secret here -# -# The GOOGLE_OAUTH2_HD variable is used to limit sign-in to a particular Google Apps hosted domain. This -# can be a string such as, 'domain.com'. If left blank, GreenLight will allow sign-in from all Google Apps hosted -# domains. -# -GOOGLE_OAUTH2_ID= -GOOGLE_OAUTH2_SECRET= -GOOGLE_OAUTH2_HD= - -# LDAP Login Provider (optional) -# -# You can enable LDAP authentication by providing values for the variables below. -# For information about setting up LDAP, see: -# http://docs.bigbluebutton.org/install/green-light.html#ldap-oauth -# -LDAP_SERVER= -LDAP_PORT= -LDAP_METHOD= -LDAP_UID= -LDAP_BASE= -LDAP_BIND_DN= -LDAP_PASSWORD= - -# If "true", GreenLight will register a webhook callback for each meeting -# created. This callback is called for all events that happen in the meeting, -# including the processing of its recording. These events are used to update -# the web page dynamically as things happen in the server. -# If not "true", the application will add a metadata to the meetings with this same -# callback URL. Scripts can then be added to BigBlueButton to call this callback -# URL and send specific events to GreenLight (e.g. a post publish script to warn -# the application when recordings are done). -GREENLIGHT_USE_WEBHOOKS=false - -# Enable uploading to Youtube (optional) -# -# When this is enabled, users will be able to directly upload their recordings -# to Youtube. If you plan to enable this, you should follow the steps outlined -# in our docs for setting up the Youtube data API. -# -# http://docs.bigbluebutton.org/install/green-light.html#8-enabling-uploading-to-youtube-optional -# -ENABLE_YOUTUBE_UPLOADING=false - -# Slack Integration (optional) -# -# You will need to register an incoming-webhook for your slack channel -# in order for GreenLight to post to it. You can do this by going -# to https://slack.com/apps/A0F7XDUAZ-incoming-webhooks, selecting your -# team and then selecting "Add Incoming WebHooks integration" on the -# desired channel. You will then need to paste the webhook below. -# -SLACK_WEBHOOK= -SLACK_CHANNEL= - -# Landing Background (optional) -# -# Supply a URL to an image to change the landing background. If no -# URL is provided GreenLight will use a default image. If you -# supply a path that does not lead to an image, no landing image -# will appear. -# -LANDING_BACKGROUND= - -# SMTP Mailer -# -GREENLIGHT_MAIL_NOTIFICATIONS=true -GREENLIGHT_DOMAIN=localhost-lxc.org -SMTP_FROM=youremail@gmail.com -SMTP_SERVER=smtp.gmail.com -SMTP_PORT=587 -SMTP_DOMAIN=gmail.com -SMTP_USERNAME=youremail@gmail.com -SMTP_PASSWORD=yourpassword -# SMTP_TLS=false -# SMTP_AUTH=login -# SMTP_STARTTLS_AUTO=true - -# Prefix for the application's root URL -# Useful for deploying the application to a subdirectory -# -# default is '/b' (recommended) -# -#RELATIVE_URL_ROOT=/b - -# Uncomment and set to 'true' to only allow users to create meetings when authenticated. -# Unauthenticated users are still able to join meetings through invites. -#DISABLE_GUEST_ACCESS=false - -# Comment this out to send logs to STDOUT in production instead of log/production.log . -DISABLE_RAILS_LOG_TO_STDOUT=true diff --git a/sample.env b/sample.env index 5d905b7b..b2afa132 100644 --- a/sample.env +++ b/sample.env @@ -1,11 +1,71 @@ -# This is a sample of the environment variables you will need for development +# This is a sample of the environment variables you will need # To use, copy this file to .env `cp sample.env .env` -RAILS_ENV=development -# BigBlueButton -BIGBLUEBUTTON_ENDPOINT= -BIGBLUEBUTTON_SECRET= +# For production only + +# RAILS_ENV=production + +# Create a secret key for rails +# +# You can generate a secure one through the Greenlight docker image +# with with the command +# +# docker run --rm bigbluebutton/greenlight rake secret +# +# SECRET_KEY_BASE= + + +# For either developent or production + +# Enter credentials for your BigBlueButton Server +# +# The endpoint and secret from your bigbluebutton server. To get these values, run +# the following command on your BigBlueButton server +# +# bbb-conf --secret +# +# and uncomment the following two variables +# BIGBLUEBUTTON_ENDPOINT=http://test-install.blindsidenetworks.com/bigbluebutton/ +# BIGBLUEBUTTON_SECRET=8cd8ef52e8e101574e400365b55e11a6 + +# Twitter Login Provider (optional) +# +# You will need to register the app at https://apps.twitter.com/ +# For the callback URL use 'http:///auth/twitter/callback' +# Once registered copy the ID and Secret here +# +# TWITTER_ID= +# TWITTER_SECRET= + +# Google Login Provider (optional) +# +# You will need to register for at https://console.developers.google.com/apis/credentials +# Select Oauth client ID -> web application +# For the callback URL use 'http:///auth/google/callback' +# Once registered copy the ID and Secret here +# +# The GOOGLE_OAUTH2_HD variable is used to limit sign-in to a particular Google Apps hosted domain. This +# can be a string such as, 'domain.com'. If left blank, GreenLight will allow sign-in from all Google Apps hosted +# domains. +# +# GOOGLE_OAUTH2_ID= +# GOOGLE_OAUTH2_SECRET= +# GOOGLE_OAUTH2_HD= + +# LDAP Login Provider (optional) +# +# You can enable LDAP authentication by providing values for the variables below. +# For information about setting up LDAP, see: +# http://docs.bigbluebutton.org/install/green-light.html#ldap-oauth +# +# LDAP_SERVER= +# LDAP_PORT= +# LDAP_METHOD= +# LDAP_UID= +# LDAP_BASE= +# LDAP_BIND_DN= +# LDAP_PASSWORD= # If "true", GreenLight will register a webhook callback for each meeting # created. This callback is called for all events that happen in the meeting, @@ -15,31 +75,63 @@ BIGBLUEBUTTON_SECRET= # callback URL. Scripts can then be added to BigBlueButton to call this callback # URL and send specific events to GreenLight (e.g. a post publish script to warn # the application when recordings are done). -GREENLIGHT_USE_WEBHOOKS=false +# GREENLIGHT_USE_WEBHOOKS=true -# The web site domain, needed for emails mostly -GREENLIGHT_DOMAIN=localhost +# Enable uploading to Youtube (optional) +# +# When this is enabled, users will be able to directly upload their recordings +# to Youtube. If you plan to enable this, you should follow the steps outlined +# in our docs for setting up the Youtube data API. +# +# http://docs.bigbluebutton.org/install/green-light.html#8-enabling-uploading-to-youtube-optional +# +# ENABLE_YOUTUBE_UPLOADING=false -# Enable email notifications -GREENLIGHT_MAIL_NOTIFICATIONS=true +# Slack Integration (optional) +# +# You will need to register an incoming-webhook for your slack channel +# in order for GreenLight to post to it. You can do this by going +# to https://slack.com/apps/A0F7XDUAZ-incoming-webhooks, selecting your +# team and then selecting "Add Incoming WebHooks integration" on the +# desired channel. You will then need to paste the webhook below. +# +# SLACK_WEBHOOK= +# SLACK_CHANNEL= -# Email configurations -SMTP_FROM=email@gmail.com -SMTP_SERVER=smtp.gmail.com -SMTP_DOMAIN=gmail.com -SMTP_PORT=587 -SMTP_USERNAME=email@gmail.com -SMTP_PASSWORD=my-secret-password +# Landing Background (optional) +# +# Supply a URL to an image to change the landing background. If no +# URL is provided GreenLight will use a default image. If you +# supply a path that does not lead to an image, no landing image +# will appear. +# +# LANDING_BACKGROUND= + +# SMTP Mailer (optional) +# +# GREENLIGHT_MAIL_NOTIFICATIONS=true +# In the format [localhost.localdomain] +# GREENLIGHT_DOMAIN=localhost +# SMTP_FROM=youremail@gmail.com +# SMTP_SERVER=smtp.gmail.com +# SMTP_PORT=587 +# SMTP_DOMAIN=gmail.com +# SMTP_USERNAME=youremail@gmail.com +# SMTP_PASSWORD=yourpassword # SMTP_TLS=false # SMTP_AUTH=login # SMTP_STARTTLS_AUTO=true -# OmniAuth -TWITTER_ID= -TWITTER_SECRET= -GOOGLE_OAUTH2_ID= -GOOGLE_OAUTH2_SECRET= +# Prefix for the application's root URL +# Useful for deploying the application to a subdirectory +# +# default is '/b' (recommended) +# +# RELATIVE_URL_ROOT=/b -# For production -SECRET_KEY_BASE= -HOSTNAME= +# Uncomment and set to 'true' to only allow users to create meetings when authenticated. +# Unauthenticated users are still able to join meetings through invites. +# DISABLE_GUEST_ACCESS=false + +# Comment this out to send logs to STDOUT in production instead of log/production.log . +DISABLE_RAILS_LOG_TO_STDOUT=true