forked from External/greenlight
adding checksum. using customer name as the provider
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user