Class: LdapQuery::Authenticate
- Inherits:
-
Object
- Object
- LdapQuery::Authenticate
- Defined in:
- lib/ldap_query/authenticate.rb
Overview
Used to authenticate a users LDAP credentials to a user in LDAP
Constant Summary collapse
- REQUIRED_CONNECTION_KEYS =
%i[host username password base].freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#connection ⇒ Object
Returns the value of attribute connection.
Instance Method Summary collapse
-
#auth_user(username, password) ⇒ Boolean, ...
Authenticate the user again ldap with the supplied username/password.
-
#initialize(credentials = {}) ⇒ Authenticate
constructor
Initialzile an ldap connection for authenticating a user.
Constructor Details
#initialize(credentials = {}) ⇒ Authenticate
Initialzile an ldap connection for authenticating a user
13 14 15 |
# File 'lib/ldap_query/authenticate.rb', line 13 def initialize(credentials = {}) establish_connection(credentials) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/ldap_query/authenticate.rb', line 6 def config @config end |
#connection ⇒ Object
Returns the value of attribute connection.
6 7 8 |
# File 'lib/ldap_query/authenticate.rb', line 6 def connection @connection end |
Instance Method Details
#auth_user(username, password) ⇒ Boolean, ...
Authenticate the user again ldap with the supplied username/password
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ldap_query/authenticate.rb', line 22 def auth_user(username, password) return false if username.nil? || password.nil? response = @connection.link.bind_as(base: @config.base, size: 1, filter: LdapQuery::Filter.auth(username), password: password) # if no user was found return false, otherwise return the user (response && response[0]) ? response : false end |