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

Class Method Summary collapse

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!, #gl_user, #initialize, #new?, #persisted?, #valid?

Constructor Details

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

Class Method Details

.find_by_uid_and_provider(uid, provider) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


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

def find_by_uid_and_provider(uid, provider)
  identity = ::Identity.with_extern_uid(provider, uid).take

  identity && identity.user
end

Instance Method Details

#allowed?Boolean

Returns:

  • (Boolean)

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

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

#auth_hash=(auth_hash) ⇒ Object


58
59
60
# File 'lib/gitlab/auth/ldap/user.rb', line 58

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

#block_after_signup?Boolean

Returns:

  • (Boolean)

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

def block_after_signup?
  ldap_config.block_auto_created_users
end

#find_by_uid_and_providerObject


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

def find_by_uid_and_provider
  self.class.find_by_uid_and_provider(auth_hash.uid, auth_hash.provider)
end

#find_userObject

instance methods


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

def find_user
  find_by_uid_and_provider || find_by_email || build_new_user
end

#ldap_configObject


54
55
56
# File 'lib/gitlab/auth/ldap/user.rb', line 54

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

#saveObject


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

def save
  super('LDAP')
end

#should_save?Boolean

Returns:

  • (Boolean)

38
39
40
# File 'lib/gitlab/auth/ldap/user.rb', line 38

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

#valid_sign_in?Boolean

Returns:

  • (Boolean)

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

def valid_sign_in?
  allowed? && super
end