Class: Warden::Ldap::Strategy

Inherits:
Strategies::Base
  • Object
show all
Defined in:
lib/warden/ldap/strategy.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/warden/ldap/strategy.rb', line 11

def authenticate!
  username, password = credentials
  connection = Warden::Ldap::Connection.new({ :username => username, :password => password })
  response = connection.authenticate!

  if response
    user = OpenStruct.new({ :username => username,
                            :name => connection.ldap_param_value('cn') })
    success!(user)
  else
    fail!("Could not log in")
  end
rescue Net::LDAP::LdapError
  fail!("Could not log in")
end

#valid?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/warden/ldap/strategy.rb', line 7

def valid?
  credentials.all?{|c| c.to_s !~ /^\s*$/}
end