Commit 97cf5d73 authored by James Edwards-Jones's avatar James Edwards-Jones

Omniauth callbacks moved to methods

parent da2191af
......@@ -27,9 +27,33 @@ module Gitlab
# An Array from the configuration will be expanded.
provider_arguments.concat provider['args']
when Hash
set_provider_specific_defaults(provider)
# A Hash from the configuration will be passed as is.
provider_arguments << provider['args'].symbolize_keys
end
config.omniauth provider['name'].to_sym, *provider_arguments
end
end
def set_provider_specific_defaults(provider)
# Add procs for handling SLO
if provider['name'] == 'cas3'
provider['args'][:on_single_sign_out] = lambda do |request|
provider['args'][:on_single_sign_out] = cas3_signout_handler
end
if provider['name'] == 'authentiq'
provider['args'][:remote_sign_out_handler] = authentiq_signout_handler
end
if provider['name'] == 'shibboleth'
provider['args'][:fail_with_empty_uid] = true
end
end
def cas3_signout_handler
lambda do |request|
ticket = request.params[:session_index]
raise "Service Ticket not found." unless Gitlab::Auth::OAuth::Session.valid?(:cas3, ticket)
......@@ -38,8 +62,8 @@ module Gitlab
end
end
if provider['name'] == 'authentiq'
provider['args'][:remote_sign_out_handler] = lambda do |request|
def authentiq_signout_handler
lambda do |request|
authentiq_session = request.params['sid']
if Gitlab::Auth::OAuth::Session.valid?(:authentiq, authentiq_session)
Gitlab::Auth::OAuth::Session.destroy(:authentiq, authentiq_session)
......@@ -49,17 +73,5 @@ module Gitlab
end
end
end
if provider['name'] == 'shibboleth'
provider['args'][:fail_with_empty_uid] = true
end
# A Hash from the configuration will be passed as is.
provider_arguments << provider['args'].symbolize_keys
end
config.omniauth provider['name'].to_sym, *provider_arguments
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment