module Devise::Models::LdapAuthenticatable
LDAP
Module, responsible for validating the user credentials via LDAP
.
Examples:
User.authenticate('email@test.com', 'password123') # returns authenticated user or nil User.find(1).valid_password?('password123') # returns true/false
Public Instance Methods
after_ldap_authentication()
click to toggle source
Called after a successful LDAP
authentication
# File lib/devise_ldap_authenticatable/model.rb, line 84 def after_ldap_authentication end
change_password!(current_password)
click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 25 def change_password!(current_password) raise "Need to set new password first" if @password.blank? Devise::LDAP::Adapter.update_own_password(login_with, @password, current_password) end
in_ldap_group?(group_name, group_attribute = LDAP::DEFAULT_GROUP_UNIQUE_MEMBER_LIST_KEY)
click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 59 def in_ldap_group?(group_name, group_attribute = LDAP::DEFAULT_GROUP_UNIQUE_MEMBER_LIST_KEY) Devise::LDAP::Adapter.in_ldap_group?(login_with, group_name, group_attribute) end
ldap_dn()
click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 63 def ldap_dn ldap_entry ? ldap_entry.dn : nil end
ldap_entry()
click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 51 def ldap_entry @ldap_entry ||= Devise::LDAP::Adapter.get_ldap_entry(login_with) end
ldap_get_param(param)
click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 67 def ldap_get_param(param) if ldap_entry && !ldap_entry[param].empty? value = ldap_entry.send(param) else nil end end
ldap_groups()
click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 55 def ldap_groups @ldap_groups ||= Devise::LDAP::Adapter.get_groups(login_with) end
login_with()
click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 20 def login_with @login_with ||= Devise.mappings.find {|k,v| v.class_name == self.class.name}.last.to.authentication_keys.first self[@login_with] end
password=(new_password)
click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 39 def password=(new_password) @password = new_password if defined?(password_digest) && @password.present? && respond_to?(:encrypted_password=) self.encrypted_password = password_digest(@password) end end
reset_password!(new_password, new_password_confirmation)
click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 31 def reset_password!(new_password, new_password_confirmation) if new_password == new_password_confirmation && ::Devise.ldap_update_password Devise::LDAP::Adapter.update_password(login_with, new_password) end clear_reset_password_token if valid? save end
valid_ldap_authentication?(password)
click to toggle source
Checks if a resource is valid upon authentication.
# File lib/devise_ldap_authenticatable/model.rb, line 47 def valid_ldap_authentication?(password) Devise::LDAP::Adapter.valid_credentials?(login_with, password) end