Check if LDAP user was removed or blocked when use git over ssh
This commit is contained in:
parent
2db9410945
commit
baa65e89b9
2 changed files with 11 additions and 0 deletions
|
@ -35,6 +35,7 @@ module API
|
|||
user = key.user
|
||||
|
||||
return false if user.blocked?
|
||||
return false if user.ldap_user? && Gitlab::LDAP::User.blocked?(user.extern_uid)
|
||||
|
||||
action = case git_cmd
|
||||
when *DOWNLOAD_COMMANDS
|
||||
|
|
|
@ -71,6 +71,16 @@ module Gitlab
|
|||
find_by_uid(ldap_user.dn) if ldap_user
|
||||
end
|
||||
|
||||
# Check LDAP user existance by dn. User in git over ssh check
|
||||
#
|
||||
# It covers 2 cases:
|
||||
# * when ldap account was removed
|
||||
# * when ldap account was deactivated by change of OU membership in 'dn'
|
||||
def blocked?(dn)
|
||||
ldap = OmniAuth::LDAP::Adaptor.new(ldap_conf)
|
||||
ldap.connection.search(base: dn, size: 1).blank?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_by_uid(uid)
|
||||
|
|
Loading…
Reference in a new issue