forked from External/greenlight
		
	passing params to the launcher gem
This commit is contained in:
		
							
								
								
									
										2
									
								
								Gemfile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								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
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,11 @@
 | 
			
		||||
						</div>
 | 
			
		||||
					</div>
 | 
			
		||||
				<% 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" %>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								bin/start
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								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
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
 
 | 
			
		||||
@@ -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')
 | 
			
		||||
 
 | 
			
		||||
@@ -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']
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user