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

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

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

#find_userObject


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/auth/saml/user.rb', line 14

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

#protocol_nameObject


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

def protocol_name
  'SAML'
end

#should_save?Boolean

Returns:

  • (Boolean)

29
30
31
32
33
# File 'lib/gitlab/auth/saml/user.rb', line 29

def should_save?
  return true unless gl_user

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