Class: Gitlab::Auth::Saml::User

Inherits:
OAuth::User show all
Extended by:
Utils::Override
Defined in:
lib/gitlab/auth/saml/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

#find_and_update!, #gl_user, #initialize, #new?, #persisted?, #valid?, #valid_sign_in?

Constructor Details

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

Instance Method Details

#bypass_two_factor?Boolean

Returns:

  • (Boolean)

39
40
41
# File 'lib/gitlab/auth/saml/user.rb', line 39

def bypass_two_factor?
  saml_config.upstream_two_factor_authn_contexts&.include?(auth_hash.authn_context)
end

#find_userObject


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/auth/saml/user.rb', line 18

def find_user
  user = find_by_uid_and_provider

  user ||= find_by_email if auto_link_saml_user?
  user ||= find_or_build_ldap_user if auto_link_ldap_user?
  user ||= build_new_user if 

  if user
    user.external = !(auth_hash.groups & saml_config.external_groups).empty? if external_users_enabled?
  end

  user
end

#saveObject


14
15
16
# File 'lib/gitlab/auth/saml/user.rb', line 14

def save
  super('SAML')
end

#should_save?Boolean

Returns:

  • (Boolean)

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

def should_save?
  return true unless gl_user

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