diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/routes/user.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/config/routes/user.rb b/config/routes/user.rb index 57fb37530bb..f8677693fab 100644 --- a/config/routes/user.rb +++ b/config/routes/user.rb @@ -1,3 +1,21 @@ +# Allows individual providers to be directed to a chosen controller +# Call from inside devise_scope +def override_omniauth(provider, controller, path_prefix = '/users/auth') + match "#{path_prefix}/#{provider}/callback", + to: "#{controller}##{provider}", + as: "#{provider}_omniauth_callback", + via: [:get, :post] +end + +# Use custom controller for LDAP omniauth callback +if Gitlab::Auth::LDAP::Config.enabled? + devise_scope :user do + Gitlab::Auth::LDAP::Config.available_servers.each do |server| + override_omniauth(server['provider_name'], 'ldap/omniauth_callbacks') + end + end +end + devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations, passwords: :passwords, |