BigW Consortium Gitlab

omniauth.rb 1.06 KB
Newer Older
1 2 3
if Gitlab::LDAP::Config.enabled?
  module OmniAuth::Strategies
    server = Gitlab.config.ldap.servers.values.first
4 5
    klass = server['provider_class']
    const_set(klass, Class.new(LDAP)) unless klass == 'LDAP'
6
  end
7

8 9 10 11
  OmniauthCallbacksController.class_eval do
    server = Gitlab.config.ldap.servers.values.first
    alias_method server['provider_name'], :ldap
  end
12
end
13

14
OmniAuth.config.full_host = Settings.gitlab['base_url']
15
OmniAuth.config.allowed_request_methods = [:post]
16
# In case of auto sign-in, the GET method is used (users don't get to click on a button)
17
OmniAuth.config.allowed_request_methods << :get if Gitlab.config.omniauth.auto_sign_in_with_provider.present?
18
OmniAuth.config.before_request_phase do |env|
19
  OmniAuth::RequestForgeryProtection.call(env)
20
end
21 22

if Gitlab.config.omniauth.enabled
23 24
  provider_names = Gitlab.config.omniauth.providers.map(&:name)
  require 'omniauth-kerberos' if provider_names.include?('kerberos')
25
end
26 27 28

module OmniAuth
  module Strategies
29
    autoload :Bitbucket, Rails.root.join('lib', 'omni_auth', 'strategies', 'bitbucket')
30 31
  end
end