Class: Kennedy::Backends::LDAP
- Inherits:
-
Object
- Object
- Kennedy::Backends::LDAP
- Defined in:
- lib/kennedy/backends/ldap.rb
Instance Attribute Summary collapse
-
#filter ⇒ Object
writeonly
Sets the attribute filter.
Instance Method Summary collapse
-
#authenticate(identifier, password) ⇒ true, false
Authenticates the given credentials against LDAP.
-
#initialize(args = {}) ⇒ LDAP
constructor
Creates a new LDAP auth backend with the given arguments.
Constructor Details
#initialize(args = {}) ⇒ LDAP
Creates a new LDAP auth backend with the given arguments
11 12 13 14 15 16 |
# File 'lib/kennedy/backends/ldap.rb', line 11 def initialize(args = {}) @host = args[:host] || raise(ArgumentError, "Host must be given as :host") @auth = args[:auth] || raise(ArgumentError, "Auth must be given as :auth") @base = args[:base] || raise(ArgumentError, "Base must be given as :base") @filter = lambda { raise(ArgumentError, "Set a filter block on this object using the 'filter' writer") } end |
Instance Attribute Details
#filter=(value) ⇒ Object (writeonly)
Sets the attribute filter
4 5 6 |
# File 'lib/kennedy/backends/ldap.rb', line 4 def filter=(value) @filter = value end |
Instance Method Details
#authenticate(identifier, password) ⇒ true, false
Authenticates the given credentials against LDAP
22 23 24 25 |
# File 'lib/kennedy/backends/ldap.rb', line 22 def authenticate(identifier, password) filter_string = @filter.call(identifier) !!ldap_conn.bind_as(:filter => filter_string, :password => password) end |