Module: Devise::Models::SamlAuthenticatable::ClassMethods

Includes:
DeviseSamlAuthenticatable::SamlConfig
Defined in:
lib/devise_saml_authenticatable/model.rb

Instance Method Summary collapse

Methods included from DeviseSamlAuthenticatable::SamlConfig

#get_saml_config

Instance Method Details

#attribute_mapObject



62
63
64
# File 'lib/devise_saml_authenticatable/model.rb', line 62

def attribute_map
  @attribute_map ||= attribute_map_for_environment
end

#authenticate_with_saml(saml_response) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/devise_saml_authenticatable/model.rb', line 29

def authenticate_with_saml(saml_response)
  key = Devise.saml_default_user_key
  attributes = saml_response.attributes
  if (Devise.saml_use_subject)
    auth_value = saml_response.name_id
  else
    inv_attr = attribute_map.invert
    auth_value = attributes[inv_attr[key.to_s]]
    auth_value.try(:downcase!) if Devise.case_insensitive_keys.include?(key)
  end
  resource = where(key => auth_value).first
  if (resource.nil? && !Devise.saml_create_user)
    logger.info("User(#{auth_value}) not found.  Not configured to create the user.")
    return nil 
  end

  if (resource.nil? && Devise.saml_create_user)
    logger.info("Creating user(#{auth_value}).")
    resource = new
    set_user_saml_attributes(resource,attributes)
    if (Devise.saml_use_subject)
      resource.send "#{key}=", auth_value
    end
    resource.save!
  end

  resource
end

#find_for_shibb_authentication(conditions) ⇒ Object



58
59
60
# File 'lib/devise_saml_authenticatable/model.rb', line 58

def find_for_shibb_authentication(conditions)
  find_for_authentication(conditions)
end