Skip to content

Commit adf2ffa

Browse files
committed
fix: import "ldap.filter" to fix FAB regression when ldap auth class is used
1 parent d354774 commit adf2ffa

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

rust/operator-binary/src/controller/build/properties/webserver_config.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,28 @@ pub fn build(
8686

8787
let temp_file_footer: Option<String> = config.remove(CONFIG_OVERRIDE_FILE_FOOTER_KEY);
8888

89+
// Workaround for apache-airflow-providers-fab 3.6.x: `_search_ldap` calls
90+
// `ldap.filter.escape_filter_chars` without ever importing `ldap.filter`, so every LDAP
91+
// login fails with `AttributeError: module 'ldap' has no attribute 'filter'` (the
92+
// `filter` submodule is not auto-loaded by `import ldap`). Importing it here registers
93+
// the submodule on the `ldap` package for the whole webserver process, which makes the
94+
// FAB code resolve it. Fixed upstream in FAB 3.7.0 (apache/airflow#68226); this import
95+
// is a harmless no-op there and on any python-ldap version.
96+
let mut imports = PYTHON_IMPORTS.to_vec();
97+
let has_ldap = validated_cluster
98+
.cluster_config
99+
.authentication_config
100+
.authentication_classes_resolved
101+
.iter()
102+
.any(|auth_class| matches!(auth_class, AirflowAuthenticationClassResolved::Ldap { .. }));
103+
if has_ldap {
104+
imports.push("import ldap.filter");
105+
}
106+
89107
flask_config_writer::write::<AirflowConfigOptions, _, _>(
90108
&mut config_file,
91109
config.iter(),
92-
PYTHON_IMPORTS,
110+
&imports,
93111
)
94112
.context(WriteConfigFileSnafu)?;
95113

0 commit comments

Comments
 (0)