From e3e32365d0aa7a0da95df79ddb1f298dccc27ef1 Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Fri, 29 Jun 2018 10:07:06 -0400 Subject: [PATCH 01/14] able to handle launcher login --- .gitignore | 4 +++ Dockerfile | 1 + Gemfile | 3 ++- Gemfile.lock | 28 +++++++++++++++----- app/controllers/application_controller.rb | 1 + app/controllers/main_controller.rb | 8 ++++++ app/models/user.rb | 16 ++++++++++++ config/application.rb | 31 ++++++++--------------- config/initializers/omniauth.rb | 6 ++++- 9 files changed, 69 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 51f1d350..d4eff4a2 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ # Ignore environment configuration. .env + +# IDEs +.idea +.idea/** diff --git a/Dockerfile b/Dockerfile index 1155f08e..1d3cc9dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs # Set an environment variable for the install location. ENV RAILS_ROOT /usr/src/app +RUN bundle config github.com 0e54e86c4228294d867a0831bff53f95a31d4af2:x-oauth-basic # Make the directory and set as working. RUN mkdir -p $RAILS_ROOT diff --git a/Gemfile b/Gemfile index 97df7455..95d85691 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.2' # See https://github.com/rails/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby +gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' @@ -47,6 +47,7 @@ gem 'bcrypt', '~> 3.1.7' gem 'omniauth' gem 'omniauth-twitter' gem 'omniauth-google-oauth2' +gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git" # BigBlueButton API wrapper. gem 'bigbluebutton-api-ruby' diff --git a/Gemfile.lock b/Gemfile.lock index fe663602..14e4fa5b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,10 @@ +GIT + remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git + revision: 52fbc3ff40c64ad5eef51f7e6c0beba2c666356f + specs: + omniauth-bn-launcher (0.1.0) + omniauth (~> 1.3, >= 1.3.2) + GEM remote: https://rubygems.org/ specs: @@ -42,7 +49,7 @@ GEM tzinfo (~> 1.1) arel (7.1.4) ast (2.4.0) - autoprefixer-rails (8.6.2) + autoprefixer-rails (8.6.4) execjs bcrypt (3.1.12) bigbluebutton-api-ruby (1.6.0) @@ -64,9 +71,9 @@ GEM concurrent-ruby (1.0.5) crass (1.0.4) diff-lcs (1.3) - dotenv (2.4.0) - dotenv-rails (2.4.0) - dotenv (= 2.4.0) + dotenv (2.5.0) + dotenv-rails (2.5.0) + dotenv (= 2.5.0) railties (>= 3.2, < 6.0) erubis (2.7.0) execjs (2.7.0) @@ -94,6 +101,7 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) jwt (1.5.6) + libv8 (3.16.14.19) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -110,7 +118,7 @@ GEM multi_xml (0.6.0) multipart-post (2.0.0) nio4r (2.3.1) - nokogiri (1.8.2) + nokogiri (1.8.3) mini_portile2 (~> 2.3.0) oauth (0.5.4) oauth2 (1.4.0) @@ -178,6 +186,7 @@ GEM rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) redis (3.3.5) + ref (2.0.0) rspec-core (3.7.1) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) @@ -222,7 +231,7 @@ GEM spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (3.7.1) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) @@ -232,6 +241,9 @@ GEM sqlite3 (1.3.13) tabler-rubygem (0.1.2) autoprefixer-rails (>= 6.0.3) + therubyracer (0.12.3) + libv8 (~> 3.16.14.15) + ref thor (0.20.0) thread_safe (0.3.6) tilt (2.0.8) @@ -240,7 +252,7 @@ GEM turbolinks-source (5.1.0) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.11) + uglifier (4.1.12) execjs (>= 0.3.0, < 3) unicode-display_width (1.4.0) web-console (3.6.2) @@ -270,6 +282,7 @@ DEPENDENCIES jquery-rails listen (~> 3.0.5) omniauth + omniauth-bn-launcher! omniauth-google-oauth2 omniauth-twitter pg (~> 0.18) @@ -285,6 +298,7 @@ DEPENDENCIES spring-watcher-listen (~> 2.0.0) sqlite3 tabler-rubygem + therubyracer turbolinks (~> 5) tzinfo-data uglifier (>= 1.3.0) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0f07f83b..1b90905b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base include SessionsHelper protect_from_forgery with: :exception + skip_before_filter :verify_authenticity_token MEETING_NAME_LIMIT = 90 USER_NAME_LIMIT = 30 diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index b7f7ff97..9bdb2e59 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -5,6 +5,14 @@ class MainController < ApplicationController # GET / def index + if current_user + # Redirect authenticated users to their room. + redirect_to room_path(current_user.room) + else + # Redirect unauthenticated users to root. + #TODO use env? for launcher login endpoint + redirect_to "#{Rails.configuration.relative_url_root}/auth/bn_launcher" + end end private diff --git a/app/models/user.rb b/app/models/user.rb index a89becb2..b45fe32a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -65,6 +65,22 @@ class User < ApplicationRecord def google_image(auth) auth['info']['image'] end + + def bn_launcher_name(auth) + auth['user_info']['username'] + end + + def bn_launcher_username(auth) + auth['user_info']['username'] + end + + def bn_launcher_email(auth) + auth['user_info']['email'] + end + + def bn_launcher_image(auth) + "" + end end # Retrives a list of all a users rooms that are not the main room, sorted by last session date. diff --git a/config/application.rb b/config/application.rb index ae323d4d..a7548614 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,29 +19,20 @@ module Greenlight config.loadbalanced_configuration = (ENV["USE_LOADBALANCED_CONFIGURATION"] == "true") - # Setup BigBlueButton configuration. - if config.loadbalanced_configuration - # Fetch credentials from a loadbalancer based on provider. - config.loadbalancer_endpoint = ENV["LOADBALANCER_ENDPOINT"] - config.loadbalancer_secret = ENV["LOADBALANCER_SECRET"] - else - # Default credentials (test-install.blindsidenetworks.com/bigbluebutton). - config.bigbluebutton_endpoint_default = "http://test-install.blindsidenetworks.com/bigbluebutton/api/" - config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6" - # Use standalone BigBlueButton server. - config.bigbluebutton_endpoint = ENV["BIGBLUEBUTTON_ENDPOINT"] - config.bigbluebutton_secret = ENV["BIGBLUEBUTTON_SECRET"] + # Default credentials (test-install.blindsidenetworks.com/bigbluebutton). + config.bigbluebutton_endpoint_default = "http://test-install.blindsidenetworks.com/bigbluebutton/api" + config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6" - # Fallback to testing credentails. - if config.bigbluebutton_endpoint.blank? - config.bigbluebutton_endpoint = config.bigbluebutton_endpoint_default - config.bigbluebutton_secret = config.bigbluebutton_secret_default - end - # Fix endpoint format if required. - config.bigbluebutton_endpoint += "api/" unless config.bigbluebutton_endpoint.ends_with?('api/') - end + # Fetch credentials from a loadbalancer based on provider. + config.loadbalancer_endpoint = ENV["LOADBALANCER_ENDPOINT"] + config.loadbalancer_secret = ENV["LOADBALANCER_SECRET"] + + # Use standalone BigBlueButton server. + config.bigbluebutton_endpoint = ENV["BIGBLUEBUTTON_ENDPOINT"] || config.bigbluebutton_endpoint_default + config.bigbluebutton_endpoint += "api" unless config.bigbluebutton_endpoint.ends_with?('api') + config.bigbluebutton_secret = ENV["BIGBLUEBUTTON_SECRET"] || config.bigbluebutton_secret_default # Determine if GreenLight should allow non-omniauth signup/login. config.allow_user_signup = (ENV['ALLOW_GREENLIGHT_ACCOUNTS'] == "true") diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 16f154ad..9b0ff26e 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,14 +1,18 @@ # frozen_string_literal: true # List of supported Omniauth providers. -Rails.application.config.providers = [:google, :twitter] +Rails.application.config.providers = [:google, :twitter, :bn_launcher] # Set which providers are configured. Rails.application.config.omniauth_google = ENV['GOOGLE_OAUTH2_ID'].present? && ENV['GOOGLE_OAUTH2_SECRET'].present? Rails.application.config.omniauth_twitter = ENV['TWITTER_ID'].present? && ENV['TWITTER_SECRET'].present? +Rails.application.config.omniauth_bn_launcher = (ENV["USE_LOADBALANCED_CONFIGURATION"] == "true") # Setup the Omniauth middleware. Rails.application.config.middleware.use OmniAuth::Builder do + + provider :bn_launcher, ENV['LAUNCHER_SECRET'], (ENV['LAUNCHER_RELATIVE_URL_ROOT'] || '' + '/login') + provider :twitter, ENV['TWITTER_ID'], ENV['TWITTER_SECRET'] provider :google_oauth2, ENV['GOOGLE_OAUTH2_ID'], ENV['GOOGLE_OAUTH2_SECRET'], From 3c11aca1aa7f41468084ac314ce7c408df1722da Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Wed, 4 Jul 2018 14:48:22 -0400 Subject: [PATCH 02/14] able to handle launcher login with gem --- Gemfile | 2 +- Gemfile.lock | 4 +++- app/controllers/main_controller.rb | 2 +- app/models/user.rb | 8 ++++---- bin/start | 5 +++++ config/initializers/omniauth.rb | 7 ++++++- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index f279f3d3..41da0368 100644 --- a/Gemfile +++ b/Gemfile @@ -47,7 +47,6 @@ gem 'bcrypt', '~> 3.1.7' gem 'omniauth' gem 'omniauth-twitter' gem 'omniauth-google-oauth2' -gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git" # BigBlueButton API wrapper. gem 'bigbluebutton-api-ruby' @@ -65,6 +64,7 @@ gem 'rubocop', require: false group :production do # Use a postgres database in production. gem 'pg', '~> 0.18' + gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git", branch: "oauth2" end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 14e4fa5b..3646df04 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,11 @@ GIT remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git - revision: 52fbc3ff40c64ad5eef51f7e6c0beba2c666356f + revision: d93b9fa51f920c733618ec4040c93458ff19951f + branch: oauth2 specs: omniauth-bn-launcher (0.1.0) omniauth (~> 1.3, >= 1.3.2) + omniauth-oauth2 (= 1.5.0) GEM remote: https://rubygems.org/ diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 9bdb2e59..b34b6f70 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -7,7 +7,7 @@ class MainController < ApplicationController def index if current_user # Redirect authenticated users to their room. - redirect_to room_path(current_user.room) + redirect_to room_path(current_user.main_room) else # Redirect unauthenticated users to root. #TODO use env? for launcher login endpoint diff --git a/app/models/user.rb b/app/models/user.rb index b45fe32a..019c4d74 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -67,19 +67,19 @@ class User < ApplicationRecord end def bn_launcher_name(auth) - auth['user_info']['username'] + auth['info']['name'] end def bn_launcher_username(auth) - auth['user_info']['username'] + auth['info']['username'] end def bn_launcher_email(auth) - auth['user_info']['email'] + auth['info']['email'] end def bn_launcher_image(auth) - "" + auth['info']['image'] end end diff --git a/bin/start b/bin/start index 93c2bb22..c9f53fa0 100755 --- a/bin/start +++ b/bin/start @@ -1,4 +1,9 @@ #!/bin/bash +while [ "$RAILS_ENV" = "production" ] && ! curl http://$DB_HOST:5432/ 2>&1 | grep '52' +do + echo "Waiting for postgres to start up ..." + sleep 1 +done bundle exec rake db:create bundle exec rake db:migrate diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 9b0ff26e..2f720226 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -10,8 +10,13 @@ Rails.application.config.omniauth_bn_launcher = (ENV["USE_LOADBALANCED_CONFIGURA # Setup the Omniauth middleware. Rails.application.config.middleware.use OmniAuth::Builder do + if Rails.env.production? + provider :bn_launcher, + client_id: ENV['BN_LAUNCHER_CLIENT_ID'], + client_secret: ENV['BN_LAUNCHER_CLIENT_SECRET'], + client_options: {site: ENV['BN_LAUNCHER_REDIRECT_URI']} + end - provider :bn_launcher, ENV['LAUNCHER_SECRET'], (ENV['LAUNCHER_RELATIVE_URL_ROOT'] || '' + '/login') provider :twitter, ENV['TWITTER_ID'], ENV['TWITTER_SECRET'] From 3bb0c26f33a527043514a74ee6919f815ed94474 Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Wed, 4 Jul 2018 15:20:21 -0400 Subject: [PATCH 03/14] clean up for PR --- Dockerfile | 3 ++- Gemfile | 2 +- Gemfile.lock | 3 +-- app/controllers/application_controller.rb | 1 - app/controllers/main_controller.rb | 7 +------ 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1d3cc9dc..65f890de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,8 @@ RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs # Set an environment variable for the install location. ENV RAILS_ROOT /usr/src/app -RUN bundle config github.com 0e54e86c4228294d867a0831bff53f95a31d4af2:x-oauth-basic +#Add token for private gems +RUN bundle config github.com ENV['GITHUB_TOKEN'] # Make the directory and set as working. RUN mkdir -p $RAILS_ROOT diff --git a/Gemfile b/Gemfile index 41da0368..b70263a9 100644 --- a/Gemfile +++ b/Gemfile @@ -64,7 +64,7 @@ gem 'rubocop', require: false group :production do # Use a postgres database in production. gem 'pg', '~> 0.18' - gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git", branch: "oauth2" + gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git" end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 3646df04..70b54cc4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,6 @@ GIT remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git - revision: d93b9fa51f920c733618ec4040c93458ff19951f - branch: oauth2 + revision: c272a928c41966ec3f43d841e372838be0465a8d specs: omniauth-bn-launcher (0.1.0) omniauth (~> 1.3, >= 1.3.2) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1b90905b..0f07f83b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,7 +6,6 @@ class ApplicationController < ActionController::Base include SessionsHelper protect_from_forgery with: :exception - skip_before_filter :verify_authenticity_token MEETING_NAME_LIMIT = 90 USER_NAME_LIMIT = 30 diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index b34b6f70..2fd4ff33 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -5,12 +5,7 @@ class MainController < ApplicationController # GET / def index - if current_user - # Redirect authenticated users to their room. - redirect_to room_path(current_user.main_room) - else - # Redirect unauthenticated users to root. - #TODO use env? for launcher login endpoint + if Rails.env.production? && !current_user redirect_to "#{Rails.configuration.relative_url_root}/auth/bn_launcher" end end From b51ac6aa7c13a98473fb28dadcc87185c5ac65f8 Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Wed, 4 Jul 2018 15:24:01 -0400 Subject: [PATCH 04/14] reverting unnecessary changes --- config/application.rb | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/config/application.rb b/config/application.rb index 3eb027a3..ada6e8d1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,20 +19,29 @@ module Greenlight config.loadbalanced_configuration = ENV["LOADBALANCER_ENDPOINT"].present? && ENV["LOADBALANCER_SECRET"].present? + # Setup BigBlueButton configuration. + if config.loadbalanced_configuration + # Fetch credentials from a loadbalancer based on provider. + config.loadbalancer_endpoint = ENV["LOADBALANCER_ENDPOINT"] + config.loadbalancer_secret = ENV["LOADBALANCER_SECRET"] + else + # Default credentials (test-install.blindsidenetworks.com/bigbluebutton). + config.bigbluebutton_endpoint_default = "http://test-install.blindsidenetworks.com/bigbluebutton/api/" + config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6" - # Default credentials (test-install.blindsidenetworks.com/bigbluebutton). - config.bigbluebutton_endpoint_default = "http://test-install.blindsidenetworks.com/bigbluebutton/api" - config.bigbluebutton_secret_default = "8cd8ef52e8e101574e400365b55e11a6" + # Use standalone BigBlueButton server. + config.bigbluebutton_endpoint = ENV["BIGBLUEBUTTON_ENDPOINT"] + config.bigbluebutton_secret = ENV["BIGBLUEBUTTON_SECRET"] + # Fallback to testing credentails. + if config.bigbluebutton_endpoint.blank? + config.bigbluebutton_endpoint = config.bigbluebutton_endpoint_default + config.bigbluebutton_secret = config.bigbluebutton_secret_default + end - # Fetch credentials from a loadbalancer based on provider. - config.loadbalancer_endpoint = ENV["LOADBALANCER_ENDPOINT"] - config.loadbalancer_secret = ENV["LOADBALANCER_SECRET"] - - # Use standalone BigBlueButton server. - config.bigbluebutton_endpoint = ENV["BIGBLUEBUTTON_ENDPOINT"] || config.bigbluebutton_endpoint_default - config.bigbluebutton_endpoint += "api" unless config.bigbluebutton_endpoint.ends_with?('api') - config.bigbluebutton_secret = ENV["BIGBLUEBUTTON_SECRET"] || config.bigbluebutton_secret_default + # Fix endpoint format if required. + config.bigbluebutton_endpoint += "api/" unless config.bigbluebutton_endpoint.ends_with?('api/') + end # Determine if GreenLight should allow non-omniauth signup/login. config.allow_user_signup = (ENV['ALLOW_GREENLIGHT_ACCOUNTS'] == "true") @@ -40,4 +49,4 @@ module Greenlight # Configure custom banner message. config.banner_message = ENV['BANNER_MESSAGE'] end -end +end \ No newline at end of file From 930ed809f5163b51d64acd3b17b974c66c85e4db Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Wed, 4 Jul 2018 17:06:52 -0400 Subject: [PATCH 05/14] pass github token as runtime arg --- Dockerfile | 3 ++- config/initializers/omniauth.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 65f890de..ec1e7bc1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,8 @@ RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs # Set an environment variable for the install location. ENV RAILS_ROOT /usr/src/app #Add token for private gems -RUN bundle config github.com ENV['GITHUB_TOKEN'] +ARG GITHUB_TOKEN +RUN bundle config github.com $GITHUB_TOKEN # Make the directory and set as working. RUN mkdir -p $RAILS_ROOT diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 2f720226..d22d9d50 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -12,8 +12,8 @@ Rails.application.config.omniauth_bn_launcher = (ENV["USE_LOADBALANCED_CONFIGURA Rails.application.config.middleware.use OmniAuth::Builder do if Rails.env.production? provider :bn_launcher, - client_id: ENV['BN_LAUNCHER_CLIENT_ID'], - client_secret: ENV['BN_LAUNCHER_CLIENT_SECRET'], + client_id: ENV['CLIENT_ID'], + client_secret: ENV['CLIENT_SECRET'], client_options: {site: ENV['BN_LAUNCHER_REDIRECT_URI']} end From 67c32a396f47a05738f3ca75079ffbe212926cbb Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Mon, 9 Jul 2018 13:17:23 -0400 Subject: [PATCH 06/14] passing params to the launcher gem --- Gemfile | 2 +- Gemfile.lock | 2 +- app/controllers/main_controller.rb | 3 --- app/helpers/sessions_helper.rb | 11 +++++++++++ app/views/shared/_header.html.erb | 6 +++++- bin/start | 12 +++++++----- config/application.rb | 3 ++- config/environments/production.rb | 3 +++ config/initializers/omniauth.rb | 19 +++++++++++++++---- 9 files changed, 45 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index b70263a9..f279f3d3 100644 --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,7 @@ gem 'bcrypt', '~> 3.1.7' gem 'omniauth' gem 'omniauth-twitter' gem 'omniauth-google-oauth2' +gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git" # BigBlueButton API wrapper. gem 'bigbluebutton-api-ruby' @@ -64,7 +65,6 @@ gem 'rubocop', require: false group :production do # Use a postgres database in production. gem 'pg', '~> 0.18' - gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git" end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 70b54cc4..fb18a666 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git - revision: c272a928c41966ec3f43d841e372838be0465a8d + revision: 6b79f38114a1c9e2dde4958ad5a4f02443c9c023 specs: omniauth-bn-launcher (0.1.0) omniauth (~> 1.3, >= 1.3.2) diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 2fd4ff33..b7f7ff97 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -5,9 +5,6 @@ class MainController < ApplicationController # GET / def index - if Rails.env.production? && !current_user - redirect_to "#{Rails.configuration.relative_url_root}/auth/bn_launcher" - end end private diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index d5f11bdb..fa27728c 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -22,4 +22,15 @@ module SessionsHelper def current_user @current_user ||= User.find_by(id: session[:user_id]) end + + def parse_customer_name(hostname) + provider = hostname.split('.') + provider.first == 'www' ? provider.second : provider.first + end + + def set_omniauth_options(env) + env['omniauth.strategy'].options[:customer] = parse_customer_name env["SERVER_NAME"] + env['omniauth.strategy'].options[:gl_redirect_url] = env["rack.url_scheme"] + "://" + env["SERVER_NAME"] + ":" + env["SERVER_PORT"] + env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url + end end diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index 78e5217c..0f2666ab 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -44,7 +44,11 @@ <% else %> - <%= link_to "Login", "#loginModal", :class => "btn btn-pill btn-outline-primary mx-2", "data-toggle": "modal" %> + <% if Rails.configuration.omniauth_bn_launcher && !current_user %> + <%= link_to "Login", "#{Rails.configuration.relative_url_root}/auth/bn_launcher", :class => "btn btn-pill btn-outline-primary mx-2" %> + <% else %> + <%= link_to "Login", "#loginModal", :class => "btn btn-pill btn-outline-primary mx-2", "data-toggle": "modal" %> + <% end %> <% if allow_user_signup? %> <%= link_to "Signup", signup_path, :class => "btn btn-pill btn-outline-primary mx-2" %> diff --git a/bin/start b/bin/start index c9f53fa0..718486e6 100755 --- a/bin/start +++ b/bin/start @@ -1,9 +1,11 @@ #!/bin/bash -while [ "$RAILS_ENV" = "production" ] && ! curl http://$DB_HOST:5432/ 2>&1 | grep '52' -do - echo "Waiting for postgres to start up ..." - sleep 1 -done +if [ "$RAILS_ENV" = "production" ]; then + while ! curl http://$DB_HOST:${DB_PORT:-5432}/ 2>&1 | grep '52' + do + echo "Waiting for postgres to start up ..." + sleep 1 + done +fi bundle exec rake db:create bundle exec rake db:migrate diff --git a/config/application.rb b/config/application.rb index ada6e8d1..0bb46127 100644 --- a/config/application.rb +++ b/config/application.rb @@ -18,7 +18,8 @@ module Greenlight config.exceptions_app = routes config.loadbalanced_configuration = ENV["LOADBALANCER_ENDPOINT"].present? && ENV["LOADBALANCER_SECRET"].present? - + # The default callback url that bn launcher will redirect to + config.gl_callback_url = ENV["GL_CALLBACK_URL"] # Setup BigBlueButton configuration. if config.loadbalanced_configuration # Fetch credentials from a loadbalancer based on provider. diff --git a/config/environments/production.rb b/config/environments/production.rb index 42d2e076..7a1874fd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -73,6 +73,9 @@ Rails.application.configure do # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # rails runs over http in production. Turning OpenSSL verify off to skip oauth2 verification of certs. This is done on nginx level + OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE + # Use a different logger for distributed setups. # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index d22d9d50..f3cdb6aa 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -6,17 +6,28 @@ Rails.application.config.providers = [:google, :twitter, :bn_launcher] # Set which providers are configured. Rails.application.config.omniauth_google = ENV['GOOGLE_OAUTH2_ID'].present? && ENV['GOOGLE_OAUTH2_SECRET'].present? Rails.application.config.omniauth_twitter = ENV['TWITTER_ID'].present? && ENV['TWITTER_SECRET'].present? -Rails.application.config.omniauth_bn_launcher = (ENV["USE_LOADBALANCED_CONFIGURATION"] == "true") +Rails.application.config.omniauth_bn_launcher = Rails.configuration.loadbalanced_configuration +Rails.application.config.omniauth_bn_launcher = ENV["LOADBALANCER_ENDPOINT"].present? && ENV["LOADBALANCER_SECRET"].present? + +SETUP_PROC = lambda do |env| + SessionsController.helpers.set_omniauth_options env +end + # Setup the Omniauth middleware. Rails.application.config.middleware.use OmniAuth::Builder do - if Rails.env.production? + if Rails.configuration.omniauth_bn_launcher provider :bn_launcher, client_id: ENV['CLIENT_ID'], client_secret: ENV['CLIENT_SECRET'], - client_options: {site: ENV['BN_LAUNCHER_REDIRECT_URI']} + client_options: {site: ENV['BN_LAUNCHER_REDIRECT_URI']}, + :setup => SETUP_PROC end - + # provider :bn_launcher, + # client_id: '123', + # client_secret: '456', + # client_options: {site: "http://demo.gl.greenlight.com:3000"}, + # :setup => SETUP_PROC provider :twitter, ENV['TWITTER_ID'], ENV['TWITTER_SECRET'] From 0d2a5a4c90b456cab7b27df67d69a67d143aceb0 Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Mon, 9 Jul 2018 16:00:10 -0400 Subject: [PATCH 07/14] small fixes --- Gemfile.lock | 2 +- app/models/user.rb | 4 +++- config/initializers/omniauth.rb | 7 +------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fb18a666..6b6b6a11 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git - revision: 6b79f38114a1c9e2dde4958ad5a4f02443c9c023 + revision: f7bb3dc68c418069b1f432b555ef6b35ced4ef87 specs: omniauth-bn-launcher (0.1.0) omniauth (~> 1.3, >= 1.3.2) diff --git a/app/models/user.rb b/app/models/user.rb index a087c47f..111bf161 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -22,7 +22,9 @@ class User < ApplicationRecord class << self # Generates a user from omniauth. def from_omniauth(auth) - find_or_initialize_by(social_uid: auth['uid'], provider: auth['provider']).tap do |u| + #Provider is the customer name if in loadbalanced config mode + provider = (auth['provider'] == "bn_launcher") ? auth['info']['customer'] : auth['provider'] + find_or_initialize_by(social_uid: auth['uid'], provider: provider).tap do |u| u.name = send("#{auth['provider']}_name", auth) unless u.name u.username = send("#{auth['provider']}_username", auth) unless u.username u.email = send("#{auth['provider']}_email", auth) diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index f3cdb6aa..b97b01c7 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # List of supported Omniauth providers. -Rails.application.config.providers = [:google, :twitter, :bn_launcher] +Rails.application.config.providers = [:google, :twitter] # Set which providers are configured. Rails.application.config.omniauth_google = ENV['GOOGLE_OAUTH2_ID'].present? && ENV['GOOGLE_OAUTH2_SECRET'].present? @@ -23,11 +23,6 @@ Rails.application.config.middleware.use OmniAuth::Builder do client_options: {site: ENV['BN_LAUNCHER_REDIRECT_URI']}, :setup => SETUP_PROC end - # provider :bn_launcher, - # client_id: '123', - # client_secret: '456', - # client_options: {site: "http://demo.gl.greenlight.com:3000"}, - # :setup => SETUP_PROC provider :twitter, ENV['TWITTER_ID'], ENV['TWITTER_SECRET'] From 137b8450a8c083798a69a162115be9de1844ac07 Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Tue, 10 Jul 2018 12:11:00 -0400 Subject: [PATCH 08/14] adding checksum. using customer name as the provider --- Gemfile.lock | 2 +- app/helpers/sessions_helper.rb | 9 ++++++++- config/application.rb | 1 + config/initializers/omniauth.rb | 1 - 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6b6b6a11..86d206c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git - revision: f7bb3dc68c418069b1f432b555ef6b35ced4ef87 + revision: 1ce59670e942e69752079772290e66cecba4f365 specs: omniauth-bn-launcher (0.1.0) omniauth (~> 1.3, >= 1.3.2) diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index fa27728c..704837a8 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -23,14 +23,21 @@ module SessionsHelper @current_user ||= User.find_by(id: session[:user_id]) end + def generate_checksum(customer_name, redirect_url, secret) + string = customer_name + redirect_url + secret + OpenSSL::Digest.digest('sha1', string).unpack("H*").first + end + def parse_customer_name(hostname) provider = hostname.split('.') provider.first == 'www' ? provider.second : provider.first end def set_omniauth_options(env) + gl_redirect_url = env["rack.url_scheme"] + "://" + env["SERVER_NAME"] + ":" + env["SERVER_PORT"] env['omniauth.strategy'].options[:customer] = parse_customer_name env["SERVER_NAME"] - env['omniauth.strategy'].options[:gl_redirect_url] = env["rack.url_scheme"] + "://" + env["SERVER_NAME"] + ":" + env["SERVER_PORT"] + env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url + env['omniauth.strategy'].options[:checksum] = generate_checksum parse_customer_name(env["SERVER_NAME"]), gl_redirect_url, Rails.configuration.launcher_secret end end diff --git a/config/application.rb b/config/application.rb index 0bb46127..8b8e363d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,6 +25,7 @@ module Greenlight # Fetch credentials from a loadbalancer based on provider. config.loadbalancer_endpoint = ENV["LOADBALANCER_ENDPOINT"] config.loadbalancer_secret = ENV["LOADBALANCER_SECRET"] + config.launcher_secret = ENV["LAUNCHER_SECRET"] else # Default credentials (test-install.blindsidenetworks.com/bigbluebutton). config.bigbluebutton_endpoint_default = "http://test-install.blindsidenetworks.com/bigbluebutton/api/" diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index b97b01c7..d9990423 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -7,7 +7,6 @@ Rails.application.config.providers = [:google, :twitter] Rails.application.config.omniauth_google = ENV['GOOGLE_OAUTH2_ID'].present? && ENV['GOOGLE_OAUTH2_SECRET'].present? Rails.application.config.omniauth_twitter = ENV['TWITTER_ID'].present? && ENV['TWITTER_SECRET'].present? Rails.application.config.omniauth_bn_launcher = Rails.configuration.loadbalanced_configuration -Rails.application.config.omniauth_bn_launcher = ENV["LOADBALANCER_ENDPOINT"].present? && ENV["LOADBALANCER_SECRET"].present? SETUP_PROC = lambda do |env| SessionsController.helpers.set_omniauth_options env From 407e8ee13ce1a57bacba934e4f4bbc0a8b7428bf Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Tue, 10 Jul 2018 13:54:45 -0400 Subject: [PATCH 09/14] made omniauth-bn-launcher public --- Dockerfile | 3 --- Gemfile | 2 +- Gemfile.lock | 13 ++++--------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1089cc6c..e31dc13c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,6 @@ RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs # Set an environment variable for the install location. ENV RAILS_ROOT /usr/src/app -#Add token for private gems -ARG GITHUB_TOKEN -RUN bundle config github.com $GITHUB_TOKEN # Make the directory and set as working. RUN mkdir -p $RAILS_ROOT diff --git a/Gemfile b/Gemfile index f279f3d3..0e48d8d6 100644 --- a/Gemfile +++ b/Gemfile @@ -47,7 +47,7 @@ gem 'bcrypt', '~> 3.1.7' gem 'omniauth' gem 'omniauth-twitter' gem 'omniauth-google-oauth2' -gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git" +gem 'omniauth-bn-launcher', '~> 0.1.0' # BigBlueButton API wrapper. gem 'bigbluebutton-api-ruby' diff --git a/Gemfile.lock b/Gemfile.lock index 86d206c6..9b2ec5b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,3 @@ -GIT - remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git - revision: 1ce59670e942e69752079772290e66cecba4f365 - specs: - omniauth-bn-launcher (0.1.0) - omniauth (~> 1.3, >= 1.3.2) - omniauth-oauth2 (= 1.5.0) - GEM remote: https://rubygems.org/ specs: @@ -131,6 +123,9 @@ GEM omniauth (1.8.1) hashie (>= 3.4.6, < 3.6.0) rack (>= 1.6.2, < 3) + omniauth-bn-launcher (0.1.0) + omniauth (~> 1.3, >= 1.3.2) + omniauth-oauth2 (= 1.5.0) omniauth-google-oauth2 (0.5.3) jwt (>= 1.5) omniauth (>= 1.1.1) @@ -283,7 +278,7 @@ DEPENDENCIES jquery-rails listen (~> 3.0.5) omniauth - omniauth-bn-launcher! + omniauth-bn-launcher (~> 0.1.0) omniauth-google-oauth2 omniauth-twitter pg (~> 0.18) From 91644281c446d49234d71ce8bf7c549c0068c94a Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Tue, 10 Jul 2018 15:05:50 -0400 Subject: [PATCH 10/14] fixing rubocop errors --- app/helpers/sessions_helper.rb | 5 +++-- app/models/user.rb | 4 ++-- config/application.rb | 2 +- config/environments/production.rb | 3 ++- config/initializers/omniauth.rb | 10 ++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index 704837a8..432084a4 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -33,11 +33,12 @@ module SessionsHelper provider.first == 'www' ? provider.second : provider.first end - def set_omniauth_options(env) + def omniauth_options(env) gl_redirect_url = env["rack.url_scheme"] + "://" + env["SERVER_NAME"] + ":" + env["SERVER_PORT"] env['omniauth.strategy'].options[:customer] = parse_customer_name env["SERVER_NAME"] env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url - env['omniauth.strategy'].options[:checksum] = generate_checksum parse_customer_name(env["SERVER_NAME"]), gl_redirect_url, Rails.configuration.launcher_secret + env['omniauth.strategy'].options[:checksum] = generate_checksum parse_customer_name(env["SERVER_NAME"]), + gl_redirect_url, Rails.configuration.launcher_secret end end diff --git a/app/models/user.rb b/app/models/user.rb index 111bf161..53413b23 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -22,8 +22,8 @@ class User < ApplicationRecord class << self # Generates a user from omniauth. def from_omniauth(auth) - #Provider is the customer name if in loadbalanced config mode - provider = (auth['provider'] == "bn_launcher") ? auth['info']['customer'] : auth['provider'] + # Provider is the customer name if in loadbalanced config mode + provider = auth['provider'] == "bn_launcher" ? auth['info']['customer'] : auth['provider'] find_or_initialize_by(social_uid: auth['uid'], provider: provider).tap do |u| u.name = send("#{auth['provider']}_name", auth) unless u.name u.username = send("#{auth['provider']}_username", auth) unless u.username diff --git a/config/application.rb b/config/application.rb index 8b8e363d..27fb26e0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -51,4 +51,4 @@ module Greenlight # Configure custom banner message. config.banner_message = ENV['BANNER_MESSAGE'] end -end \ No newline at end of file +end diff --git a/config/environments/production.rb b/config/environments/production.rb index 531d784e..ed1ada84 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -73,7 +73,8 @@ Rails.application.configure do # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new - # rails runs over http in production. Turning OpenSSL verify off to skip oauth2 verification of certs. This is done on nginx level + # rails runs over http in production. Turning OpenSSL verify off to skip oauth2 verification of certs. + # This is done on nginx level OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE # Use a different logger for distributed setups. diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index d9990423..0fa094ea 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -9,18 +9,16 @@ Rails.application.config.omniauth_twitter = ENV['TWITTER_ID'].present? && ENV['T Rails.application.config.omniauth_bn_launcher = Rails.configuration.loadbalanced_configuration SETUP_PROC = lambda do |env| - SessionsController.helpers.set_omniauth_options env + SessionsController.helpers.omniauth_options env end - # Setup the Omniauth middleware. Rails.application.config.middleware.use OmniAuth::Builder do if Rails.configuration.omniauth_bn_launcher - provider :bn_launcher, - client_id: ENV['CLIENT_ID'], + provider :bn_launcher, client_id: ENV['CLIENT_ID'], client_secret: ENV['CLIENT_SECRET'], - client_options: {site: ENV['BN_LAUNCHER_REDIRECT_URI']}, - :setup => SETUP_PROC + client_options: { site: ENV['BN_LAUNCHER_REDIRECT_URI'] }, + setup: SETUP_PROC end provider :twitter, ENV['TWITTER_ID'], ENV['TWITTER_SECRET'] From f36741f131d700ce153cb27d39d303af750b2f88 Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Tue, 10 Jul 2018 16:00:57 -0400 Subject: [PATCH 11/14] added specs for bn-launcher --- spec/controllers/sessions_controller_spec.rb | 32 ++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 8713b215..d074b4d7 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -61,12 +61,24 @@ describe SessionsController, type: :controller do }, ) + OmniAuth.config.mock_auth[:bn_launcher] = OmniAuth::AuthHash.new( + provider: "bn_launcher", + uid: "bn-launcher-user", + info: { + email: "user1@google.com", + name: "User1", + nickname: "nick", + image: "touch.png", + customer: 'ocps' + } + ) + OmniAuth.config.on_failure = proc { |env| OmniAuth::FailureEndpoint.new(env).redirect_to_failure } end - it "should create and login user with omniauth" do + it "should create and login user with omniauth twitter" do request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:twitter] get :omniauth, params: { provider: :twitter } @@ -76,6 +88,16 @@ describe SessionsController, type: :controller do expect(@request.session[:user_id]).to eql(u.id) end + it "should create and login user with omniauth bn launcher" do + request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:bn_launcher] + get :omniauth, params: { provider: 'bn_launcher' } + + u = User.last + expect(u.provider).to eql("ocps") + expect(u.email).to eql("user1@google.com") + expect(@request.session[:user_id]).to eql(u.id) + end + it "should redirect to root on invalid omniauth login" do request.env["omniauth.auth"] = :invalid_credentials get :omniauth, params: { provider: :twitter } @@ -83,10 +105,16 @@ describe SessionsController, type: :controller do expect(response).to redirect_to(root_path) end - it "should not create session without omniauth env set" do + it "should not create session without omniauth env set for google" do get :omniauth, params: { provider: 'google' } expect(response).to redirect_to(root_path) end + + it "should not create session without omniauth env set for bn_launcher" do + get :omniauth, params: { provider: 'bn_launcher' } + + expect(response).to redirect_to(root_path) + end end end From cec4393837598246146c3cf2d49f83afb1b57468 Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Tue, 10 Jul 2018 16:05:37 -0400 Subject: [PATCH 12/14] rubocop fixes --- spec/controllers/sessions_controller_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index d074b4d7..e6607510 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -62,15 +62,15 @@ describe SessionsController, type: :controller do ) OmniAuth.config.mock_auth[:bn_launcher] = OmniAuth::AuthHash.new( - provider: "bn_launcher", - uid: "bn-launcher-user", - info: { - email: "user1@google.com", - name: "User1", - nickname: "nick", - image: "touch.png", - customer: 'ocps' - } + provider: "bn_launcher", + uid: "bn-launcher-user", + info: { + email: "user1@google.com", + name: "User1", + nickname: "nick", + image: "touch.png", + customer: 'ocps', + } ) OmniAuth.config.on_failure = proc { |env| From b7801f9874cde218374e832374b2470b5eafb66b Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Wed, 11 Jul 2018 13:19:20 -0400 Subject: [PATCH 13/14] adding DB_ADAPTER check --- bin/start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/start b/bin/start index d7732ed8..c5c5a8e1 100755 --- a/bin/start +++ b/bin/start @@ -1,5 +1,5 @@ #!/bin/bash -if [ "$RAILS_ENV" = "production" ]; then +if [ "$RAILS_ENV" = "production" ] && [ "$DB_ADAPTER" = "postgresql" ]; then while ! curl http://$DB_HOST:${DB_PORT:-5432}/ 2>&1 | grep '52' do echo "Waiting for postgres to start up ..." From 01ea22ed6dfb2dbdc7562e2f2445507c28b0f263 Mon Sep 17 00:00:00 2001 From: bruckwubete Date: Wed, 11 Jul 2018 14:57:00 -0400 Subject: [PATCH 14/14] removed OpenSSL::SSL::VERIFY_PEER assignment --- config/environments/production.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index ed1ada84..42654597 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -73,10 +73,6 @@ Rails.application.configure do # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new - # rails runs over http in production. Turning OpenSSL verify off to skip oauth2 verification of certs. - # This is done on nginx level - OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE - # Use a different logger for distributed setups. # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')