Commit 48e90540 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Open/close LDAP in ApplicationController

By opening the LDAP connection at the controller level we can reuse it
for all LDAP queries during the request.
parent 56df3dbf
...@@ -17,6 +17,7 @@ v 6.7.0 ...@@ -17,6 +17,7 @@ v 6.7.0
- Add GFM autocompletion for MergeRequests (Robert Speicher) - Add GFM autocompletion for MergeRequests (Robert Speicher)
- Add webhook when a new tag is pushed (Jeroen van Baarsen) - Add webhook when a new tag is pushed (Jeroen van Baarsen)
- Add button for toggling inline comments in diff view - Add button for toggling inline comments in diff view
- Reuse the GitLab LDAP connection within each request
v 6.6.2 v 6.6.2
- Fix 500 error on branch/tag create or remove via UI - Fix 500 error on branch/tag create or remove via UI
......
...@@ -182,13 +182,15 @@ class ApplicationController < ActionController::Base ...@@ -182,13 +182,15 @@ class ApplicationController < ActionController::Base
def ldap_security_check def ldap_security_check
if current_user && current_user.requires_ldap_check? if current_user && current_user.requires_ldap_check?
if gitlab_ldap_access.allowed?(current_user) gitlab_ldap_access do |access|
current_user.last_credential_check_at = Time.now if access.allowed?(current_user)
current_user.save current_user.last_credential_check_at = Time.now
else current_user.save
sign_out current_user else
flash[:alert] = "Access denied for your LDAP account." sign_out current_user
redirect_to new_user_session_path flash[:alert] = "Access denied for your LDAP account."
redirect_to new_user_session_path
end
end end
end end
end end
...@@ -198,8 +200,8 @@ class ApplicationController < ActionController::Base ...@@ -198,8 +200,8 @@ class ApplicationController < ActionController::Base
@event_filter ||= EventFilter.new(filters) @event_filter ||= EventFilter.new(filters)
end end
def gitlab_ldap_access def gitlab_ldap_access(&block)
Gitlab::LDAP::Access.new Gitlab::LDAP::Access.open { |access| block.call(access) }
end end
# JSON for infinite scroll via Pager object # JSON for infinite scroll via Pager object
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment