Skip to content

simple_authenticate still requires a query user #57

Description

@hmspider

As I understand the purpose of simple_authenticate is authenticating a user against the domain without requiring a query user. This is not happening, as per sequence below:

  1. Adauth::AdObjects::User.simple_authenticate(usr, pwd)
  2. allowed_to_login
  3. usr.cn_goups_nested
  4. Adauth::AdObjects::Group.where('name', group)
  5. filter
  6. Adauth.connection
  7. _connect_
  8. Adauth::Connection.new(connection_hash(_@config.query_user, @config.query_password_))

This happens because Adauth.connection doesn't return a connection, despite there's an existing one
created by Adauth::AdObjects::User.authenticate to authenticate the user against the AD; Adauth.connect therefore tries to establish a new connection with the query user credentials, which will be empty, resulting in a <Net::LDAP::LdapError: invalid binding information> error.

The tests themselves simple_authenticate the query user, which kind of defeats the whole purpose of it.

Imho the simplest approach to solve this would be to change Adauth.connection_hash in order to use provided credentials if no query user is configured:

  • accept empty user and password arguments by default (user = "", password = "")

  • use those values as fallback when no query user is configured, in the likes of

    :username => @config.query_user.blank? ? user : @config.query_user,
    :password => @config.query_user.blank? ? password : @config.password

In this line, would also need to change:

  • Adauth.connection, in order to accept empty user and password arguments by default (user = "", password = "")
  • ditto for Adauth.connect

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions