Class: CASino::LDAPAuthenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/casino/ldap_authenticator/version.rb,
lib/casino/ldap_authenticator.rb

Constant Summary collapse

VERSION =
'2.0.1'
DEFAULT_USERNAME_ATTRIBUTE =
'uid'

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ LDAPAuthenticator

Returns a new instance of LDAPAuthenticator.

Parameters:

  • options (Hash)


8
9
10
# File 'lib/casino/ldap_authenticator.rb', line 8

def initialize(options)
  @options = options
end

Instance Method Details

#validate(username, password) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/casino/ldap_authenticator.rb', line 12

def validate(username, password)
  @username = username
  @password = password
  begin
    connect
    authenticate
    if !@user_plain
      false
    else
      generate_user
      @user
    end
  rescue Net::LDAP::LdapError => e
    raise CASino::Authenticator::AuthenticatorError,
      "LDAP authentication failed with '#{e}'. Check your authenticator configuration."
  end
end