summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-04-24 10:18:10 +0000
committerDouwe Maan <douwe@gitlab.com>2018-04-24 10:18:10 +0000
commit1e624f3401fd426f8fff7064184061d71d36f5bf (patch)
tree72f7fb98cdf52541a7c434fd042deb5880495608 /config
parentd210c6b6d9251d4e002ed05285975d498c5faee4 (diff)
parentdd09a19ad6f9daf36cd26c749be2b90d4f968b92 (diff)
downloadgitlab-ce-1e624f3401fd426f8fff7064184061d71d36f5bf.tar.gz
Merge branch 'jej/refactor-omniauth-controller' into 'master'
Refactor OmniauthCallbacksController to remove duplication Closes #26559 See merge request gitlab-org/gitlab-ce!16694
Diffstat (limited to 'config')
-rw-r--r--config/routes/user.rb18
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,