Sha256: 1fc3aa5fe31f5b43517965d3e2916981467873390b76bef4dc4014bec8eefe15
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require 'devise/strategies/base' module Devise module Strategies # Strategy for signing in a user based on his login and password using LDAP. # Redirects to sign_in page if it's not authenticated class LdapAuthenticatable < Base def valid? valid_controller? && valid_params? && mapping.to.respond_to?(:authenticate_with_ldap) end # Authenticate a user based on login and password params, returning to warden # success and the authenticated user if everything is okay. Otherwise redirect # to sign in page. def authenticate! if resource = mapping.to.authenticate_with_ldap(params[scope]) success!(resource) else fail(:invalid) end end protected def valid_controller? params[:controller] == 'sessions' end def valid_params? params[scope] && params[scope][:password].present? end end end end Warden::Strategies.add(:ldap_authenticatable, Devise::Strategies::LdapAuthenticatable)
Version data entries
3 entries across 3 versions & 1 rubygems