Class: Devise::Strategies::HolmanAuthenticatable
- Inherits:
-
Authenticatable
- Object
- Authenticatable
- Devise::Strategies::HolmanAuthenticatable
- Defined in:
- lib/holman_active_directory/authenticatable.rb
Instance Attribute Summary collapse
-
#http_pass ⇒ Object
Returns the value of attribute http_pass.
-
#http_user ⇒ Object
Returns the value of attribute http_user.
Instance Method Summary collapse
- #active_directory_password?(user, password) ⇒ Boolean
- #authenticate! ⇒ Object
- #email ⇒ Object
- #password ⇒ Object
- #use_http_authenticate ⇒ Object
- #user ⇒ Object
Instance Attribute Details
#http_pass ⇒ Object
Returns the value of attribute http_pass.
36 37 38 |
# File 'lib/holman_active_directory/authenticatable.rb', line 36 def http_pass @http_pass end |
#http_user ⇒ Object
Returns the value of attribute http_user.
36 37 38 |
# File 'lib/holman_active_directory/authenticatable.rb', line 36 def http_user @http_user end |
Instance Method Details
#active_directory_password?(user, password) ⇒ Boolean
43 44 45 46 47 |
# File 'lib/holman_active_directory/authenticatable.rb', line 43 def active_directory_password?(user, password) dn = user.active_directory_distinguished_name return false unless dn HolmanActiveDirectory.valid_password?(dn, password) end |
#authenticate! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/holman_active_directory/authenticatable.rb', line 6 def authenticate! use_http_authenticate if defined?(ActionController) return fail(:invalid) unless user.present? && password.present? if user.valid_password?(password) # invited users may create their own password and login without AD success!(user) elsif active_directory_password?(user, password) session[:ldap_session] = true session[:expires_at] = HolmanActiveDirectory::AccessControl.ldap_session_timeout success!(user) else fail(:invalid) end rescue Net::LDAP::Error fail(:no_ad) end |
#email ⇒ Object
28 29 30 |
# File 'lib/holman_active_directory/authenticatable.rb', line 28 def email http_user || params[:user][:email] end |
#password ⇒ Object
32 33 34 |
# File 'lib/holman_active_directory/authenticatable.rb', line 32 def password http_pass || super end |
#use_http_authenticate ⇒ Object
38 39 40 41 |
# File 'lib/holman_active_directory/authenticatable.rb', line 38 def use_http_authenticate return unless request. @http_user, @http_pass = ActionController::HttpAuthentication::Basic::user_name_and_password(request) end |
#user ⇒ Object
24 25 26 |
# File 'lib/holman_active_directory/authenticatable.rb', line 24 def user @cached_user ||= User.find_for_authentication(email) end |