summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-08-24 16:37:17 +0000
committerDouwe Maan <douwe@gitlab.com>2017-08-24 16:37:17 +0000
commit4428944d53232d7c9d620ae483e66fe46f414baf (patch)
tree5aa5d07c8b5d77886a926fbde22366cab12e848a
parentcabc593d39d778d326435c70ebd6243314bcd587 (diff)
parentf8865e9c1303be7302306bea9dd1057bf3b3f608 (diff)
downloadgitlab-ce-docs-36116-install-gitlab-on-azure.tar.gz
Merge branch 'bvl-alternative-fix-ldap-login' into 'master'docs-36116-install-gitlab-on-azure
Alternative fix for 422 when using standard login with ldap enabled See merge request !13103
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb8
-rw-r--r--app/controllers/sessions_controller.rb8
-rw-r--r--config/initializers/omniauth.rb6
3 files changed, 8 insertions, 14 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index 7444826a5d1..9612b8d8514 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -10,6 +10,14 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
end
+ if Gitlab::LDAP::Config.enabled?
+ Gitlab::LDAP::Config.available_servers.each do |server|
+ define_method server['provider_name'] do
+ ldap
+ end
+ end
+ end
+
# Extend the standard message generation to accept our custom exception
def failure_message
exception = env["omniauth.error"]
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 9e743685d60..be6491d042c 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -5,14 +5,6 @@ class SessionsController < Devise::SessionsController
skip_before_action :check_two_factor_requirement, only: [:destroy]
- # Explicitly call protect from forgery before anything else. Otherwise the
- # CSFR-token might be cleared before authentication is done. This was the case
- # when LDAP was enabled and the `OmniauthCallbacksController` is loaded
- #
- # *Note:* `prepend: true` is the default for rails4, but this will be changed
- # to `prepend: false` in rails5.
- protect_from_forgery prepend: true, with: :exception
-
prepend_before_action :check_initial_setup, only: [:new]
prepend_before_action :authenticate_with_two_factor,
if: :two_factor_enabled?, only: [:create]
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
index 56c279ffcf4..fddb018e948 100644
--- a/config/initializers/omniauth.rb
+++ b/config/initializers/omniauth.rb
@@ -6,12 +6,6 @@ if Gitlab::LDAP::Config.enabled?
const_set(server['provider_class'], Class.new(LDAP))
end
end
-
- OmniauthCallbacksController.class_eval do
- Gitlab::LDAP::Config.available_servers.each do |server|
- alias_method server['provider_name'], :ldap
- end
- end
end
OmniAuth.config.full_host = Settings.gitlab['base_url']