litesh1998 opened a new issue, #68224:
URL: https://github.com/apache/airflow/issues/68224

   ### Under which category would you file this issue?
   
   Providers
   
   ### Apache Airflow version
   
   3.2.2
   
   ### What happened and how to reproduce it?
   
   When configuring LDAP authentication in Airflow 3, login attempts failed 
with an exception indicating that the ldap.filter module could not be found. 
The LDAP provider code imports and uses ldap.filter.escape_filter_chars(), but 
the ldap.filter submodule is not automatically imported by the python-ldap 
package in some environments.
   
   As a result, LDAP authentication fails even though the python-ldap package 
is installed and functional.
   
   ### How to reproduce it?
   
   1. Install Airflow 3 with LDAP authentication enabled.
   2. Install python-ldap (e.g. version 3.4.7).
   3. Configure LDAP authentication according to the Airflow documentation.
   4. Start the Airflow webserver.
   5. Attempt to log in using an LDAP user.
   6. Observe that authentication fails with:
   `AttributeError: module 'ldap' has no attribute 'filter'`
   
   
   The issue is resolved by explicitly importing ldap.filter before LDAP 
authentication code is executed. This suggests the provider should explicitly 
import ldap.filter rather than assuming it is available as an attribute of the 
ldap module.
   
   ### What you think should happen instead?
   
   LDAP authentication should work successfully when the supported python-ldap 
package is installed and configured correctly.
   
   The LDAP provider should explicitly import any required submodules (such as 
ldap.filter) instead of assuming they are automatically available as attributes 
of the top-level ldap package.
   
   If a required dependency is missing, Airflow should fail gracefully with a 
clear error message indicating the missing module, rather than raising:
   
   AttributeError: module 'ldap' has no attribute 'filter'
   
   Users should be able to configure and use LDAP authentication following the 
documented setup steps without needing to manually modify provider code or add 
additional imports.
   
   ### Operating System
   
   Rocky linux
   
   ### Deployment
   
   Virtualenv installation
   
   ### Apache Airflow Provider(s)
   
   fab
   
   ### Versions of Apache Airflow Providers
   
   3.6.5
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   # webserver.py (redacted)
   
   from airflow.providers.fab.auth_manager.auth_manager import FabAuthManager
   
   AUTH_TYPE = AUTH_LDAP
   
   AUTH_LDAP_SERVER = "ldaps://ldap.example.com"
   AUTH_LDAP_SEARCH = "OU=Users,DC=example,DC=com"
   AUTH_LDAP_BIND_USER = "CN=svc_airflow,OU=ServiceAccounts,DC=example,DC=com"
   AUTH_LDAP_BIND_PASSWORD = "***REDACTED***"
   
   SECURITY_MANAGER_CLASS = "CustomSecurityManager"
   
   # Login fails with:
   # AttributeError: module 'ldap' has no attribute 'filter'
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to