adding checksum. using customer name as the provider

This commit is contained in:
bruckwubete 2018-07-10 12:11:00 -04:00
parent 0d2a5a4c90
commit 137b8450a8
4 changed files with 10 additions and 3 deletions

View File

@ -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)

View File

@ -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

View File

@ -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/"

View File

@ -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