AuthnProviderAlias ldap可以与Apache2.4.x一起使用吗?

Von*_*onC 11 c apache configuration ldap

这在Apache2.2中完美运行,但在2.4中没有(我现在需要使用2.4):

<AuthnProviderAlias ldap myldap>
  AuthLDAPBindDN cn=Manager,dc=example,dc=com
  AuthLDAPBindPassword xxxx
  AuthLDAPURL ldap://localhost:9011/dc=example,dc=com?uid?sub?(objectClass=*)
</AuthnProviderAlias>

Listen 48443
<VirtualHost myserver:48443>
 <Directory /path/to/a/folder>
        Options +ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
        AllowOverride All
        order allow,deny
        Allow from all

        AuthBasicProvider myldap mySecondLdap myThirdLdap ...

        AuthType Basic
        AuthName "LDAP authentication for folder"
        Require valid-user
        ...
  </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

直接使用Apache 2.4中的指令mod_authnz_ldap在以下<Directory >部分中使用:

AuthLDAPBindDN cn=Manager,dc=example,dc=com
AuthLDAPBindPassword xxx
AuthLDAPURL ldap://localhost:9011/dc=example,dc=com?uid?sub?(objectClass=*)
AuthBasicProvider ldap
Run Code Online (Sandbox Code Playgroud)

但是,这允许仅针对一个 LDAP服务器进行身份验证,并且我必须针对至少两个进行身份验证.
因此,使用AuthnProviderAlias现在(2.4)mod_authn_core核心认证模块的一部分,而不是旧的2.2 LDAP认证模块mod_authn_alias.


我已经编译了所有2.4.x版本(从2.4.1到2.4.6,甚至是当前版本),APR 1.4.8和APR-util 1.5.2,在调试模式下(-g -O0)

我尝试的是一个调试会话(gdb --command=debug使用' debug'gdb参数文件如下):

file /home/vonc/usr/local/apps/apache/bin/httpd
set logging file /home/vonc/gdb.txt
set logging on
set args -X
show args
set breakpoint pending on

# authn_alias_check_password
b mod_authn_core.c:115
# authaliassection
b mod_authn_core.c:203
b mod_authn_core.c:255

run
wh
fs next
where
Run Code Online (Sandbox Code Playgroud)

我看到的是:

那个功能得到了authcfg

authn_alias_srv_conf *authcfg =
    (authn_alias_srv_conf *)ap_get_module_config(r->server->module_config,
                                                 &authn_core_module);
Run Code Online (Sandbox Code Playgroud)

为提供商设置正确的名称' ldap'和右别名' myldap'

apr_hash_set(authcfg->alias_rec, provider_alias, APR_HASH_KEY_STRING, prvdraliasrec);
Run Code Online (Sandbox Code Playgroud)

但是:当需要检查密码时(在authn_alias_check_password,它authcfg再次获取,并获取提供者:

    provider_alias_rec *prvdraliasrec = apr_hash_get(authcfg->alias_rec,
                                                     provider_name, APR_HASH_KEY_STRING);
Run Code Online (Sandbox Code Playgroud)

它使用正确的provider_name' myldap',......并且总是返回null.
这意味着prvdraliasrec->provider->check_password永远不会被召唤.

http-dev邮件列表中的一个类似问题(2013年8月23日"AuturnProviderAlias在2.4中巧妙地破解了吗?")是......没有答案.

你会如何解决这个错误?

cov*_*ner 4

该错误是由于提供程序及其在不同服务器上下文中的使用造成的。

  • mod_authn_core 提供 AuthType,这会导致为 VH 中的 authn_core 创建每服务器配置
  • 该模块没有实现合并功能
  • server->module_config 始终为空。

解决方法:在 VH 上下文之外定义您的身份验证,或者如果可以轻松重建,请尝试此补丁:http ://people.apache.org/~covener/patches/authprovider.diff

Index: modules/aaa/mod_authn_core.c
===================================================================
--- modules/aaa/mod_authn_core.c    (revision 40703)
+++ modules/aaa/mod_authn_core.c    (working copy)
@@ -179,6 +179,12 @@
     return (void *) authcfg;
 }

+/* Only per-server directive we have is GLOBAL_ONLY */
+static void *merge_authn_alias_svr_config(apr_pool_t *p, void *basev, void *overridesv)
+{
+    return basev;
+}
+
 static const authn_provider authn_alias_provider =
 {
     &authn_alias_check_password,
@@ -373,7 +379,7 @@
     create_authn_core_dir_config,   /* dir config creater */
     merge_authn_core_dir_config,    /* dir merger --- default is to override */
     create_authn_alias_svr_config,  /* server config */
-    NULL,                           /* merge server config */
+    merge_authn_alias_svr_config,   /* merge server config */
     authn_cmds,
     register_hooks                  /* register hooks */
 };
Run Code Online (Sandbox Code Playgroud)