From 2a96269d44c2b80830efe9f563e5427c15d35f02 Mon Sep 17 00:00:00 2001 From: shawn-higgins1 <23224097+shawn-higgins1@users.noreply.github.com> Date: Tue, 9 Jul 2019 16:46:25 -0400 Subject: [PATCH] GRN2-175: Update Greenlight to work with the new launcher (#614) * Update greenlight to support the new launcher * Update comments to indicate that checksum should eventually be removed * Fix spelling mistake * Fix rubocop * Missed variable name change * Support old environment variable --- app/helpers/sessions_helper.rb | 12 ++++++++---- config/initializers/omniauth.rb | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index b95dd302..d21573f5 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -79,13 +79,17 @@ module SessionsHelper def omniauth_options(env) if env['omniauth.strategy'].options[:name] == "bn-launcher" - gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" + - env["SERVER_PORT"] + protocol = Rails.env.production? ? "https" : env["rack.url_scheme"] + + customer_redirect_url = protocol + "://" + env["SERVER_NAME"] + ":" + + env["SERVER_PORT"] user_domain = parse_user_domain(env["SERVER_NAME"]) env['omniauth.strategy'].options[:customer] = user_domain - env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url + env['omniauth.strategy'].options[:customer_redirect_url] = customer_redirect_url env['omniauth.strategy'].options[:default_callback_url] = Rails.configuration.gl_callback_url - env['omniauth.strategy'].options[:checksum] = generate_checksum(user_domain, gl_redirect_url, + + # This is only used in the old launcher and should eventually be removed + env['omniauth.strategy'].options[:checksum] = generate_checksum(user_domain, customer_redirect_url, Rails.configuration.launcher_secret) elsif env['omniauth.strategy'].options[:name] == "google" set_hd(env, ENV['GOOGLE_OAUTH2_HD']) diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 4d4ae321..d601fb3f 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -27,7 +27,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do 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_URI'] || ENV['BN_LAUNCHER_REDIRECT_URI'] }, setup: SETUP_PROC elsif Rails.configuration.omniauth_ldap Rails.application.config.providers << :ldap