Sha256: c8e01542217a77dadfbf9887d54706461032fd989696c16ff077708e0fb1effa

Contents?: true

Size: 844 Bytes

Versions: 2

Compression:

Stored size: 844 Bytes

Contents

require 'devise/strategies/authenticatable'

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 < Authenticatable
      # 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!
        resource = valid_password? && mapping.to.authenticate_with_ldap(params[scope])
        return fail(:invalid) if resource.nil?

        if validate(resource)
          success!(resource)
        else
          fail(:invalid)
        end
      end
    end
  end
end

Warden::Strategies.add(:ldap_authenticatable, Devise::Strategies::LdapAuthenticatable)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise_ldap_authenticatable-0.8.0.pre lib/devise_ldap_authenticatable/strategy.rb
devise_ldap_authenticatable-0.7.0 lib/devise_ldap_authenticatable/strategy.rb