Class: Gitlab::Auth::Ldap::User

Inherits:
OAuth::User show all
Extended by:
Utils::Override
Defined in:
lib/gitlab/auth/ldap/user.rb

Constant Summary

Constants inherited from OAuth::User

OAuth::User::SigninDisabledForProviderError, OAuth::User::SignupDisabledError

Instance Attribute Summary

Attributes inherited from OAuth::User

#auth_hash

Instance Method Summary collapse

Methods included from Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods inherited from OAuth::User

#bypass_two_factor?, #find_and_update!, find_by_uid_and_provider, #gl_user, #initialize, #new?, #persisted?, #save, #valid?

Constructor Details

This class inherits a constructor from Gitlab::Auth::OAuth::User

Instance Method Details

#allowed?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/gitlab/auth/ldap/user.rb', line 29

def allowed?
  Gitlab::Auth::Ldap::Access.allowed?(gl_user)
end

#auth_hash=(auth_hash) ⇒ Object



45
46
47
# File 'lib/gitlab/auth/ldap/user.rb', line 45

def auth_hash=(auth_hash)
  @auth_hash = Gitlab::Auth::Ldap::AuthHash.new(auth_hash)
end

#block_after_signup?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/gitlab/auth/ldap/user.rb', line 25

def block_after_signup?
  ldap_config.block_auto_created_users
end

#find_userObject

instance methods



16
17
18
# File 'lib/gitlab/auth/ldap/user.rb', line 16

def find_user
  find_by_uid_and_provider || find_by_email || build_new_user
end

#ldap_configObject



41
42
43
# File 'lib/gitlab/auth/ldap/user.rb', line 41

def ldap_config
  Gitlab::Auth::Ldap::Config.new(auth_hash.provider)
end

#protocol_nameObject



49
50
51
# File 'lib/gitlab/auth/ldap/user.rb', line 49

def protocol_name
  'LDAP'
end

#should_save?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/gitlab/auth/ldap/user.rb', line 21

def should_save?
  gl_user.changed? || gl_user.identities.any?(&:changed?)
end

#valid_sign_in?Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
# File 'lib/gitlab/auth/ldap/user.rb', line 33

def valid_sign_in?
  # The order is important here: we need to ensure the
  # associated GitLab user entry is valid and persisted in the
  # database. Otherwise, the LDAP access check will fail since
  # the user doesn't have an associated LDAP identity.
  super && allowed?
end