diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-04-18 15:03:27 +0100 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-04-22 23:50:55 +0100 |
commit | f10c999bca2b5b37b068ff3680a6e35a6707828d (patch) | |
tree | a517f86544c1544ee25d174652a003fff9b199a0 /config/routes | |
parent | c212908aad9b32352653dfe9ca966f148c8dfc1a (diff) | |
download | gitlab-ce-f10c999bca2b5b37b068ff3680a6e35a6707828d.tar.gz |
Refactor OmniauthCallbacksController to remove duplication
Moves LDAP to its own controller with tests
Provides path forward for implementing GroupSaml
Diffstat (limited to 'config/routes')
-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, |