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

标签 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>

直接使用来自 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

但这只允许针对一个 LDAP 服务器进行身份验证,而我必须针对至少两个服务器进行身份验证。
因此使用 AuthnProviderAlias ,现在是 mod_authn_core core authentication module 的 (2.4) 部分, 而不是旧的 2.2 LDAP authentication module mod_authn_alias .


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

我尝试的是一个调试 session ( 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

我看到的是:

那个函数gets the authcfg

authn_alias_srv_conf *authcfg =
    (authn_alias_srv_conf *)ap_get_module_config(r->server->module_config,
                                                 &authn_core_module);

sets the provider使用正确的名称' ldap ' 和右别名 ' myldap '

apr_hash_set(authcfg->alias_rec, provider_alias, APR_HASH_KEY_STRING, prvdraliasrec);

但是:当需要检查密码时(在 authn_alias_check_password 中,它再次获得 authcfgfetch the provider :

    provider_alias_rec *prvdraliasrec = apr_hash_get(authcfg->alias_rec,
                                                     provider_name, APR_HASH_KEY_STRING);

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

http-dev mailing list 中的类似问题( August 23, 2013 "Is AuthnProviderAlias subtly broken in 2.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 */
 };

关于AuthnProviderAlias ldap 可以与 Apache2.4.x 一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18874062/

相关文章:

c - 文件输出不正确

java - 在 Live 服务器上托管 java webservice

elasticsearch - 日志文件不会出现在elasticsearch中

javascript - 无法连接 Node-mysql

testing - 如何配置 TeamCity 以动态构建项目而不是导出项目?

c - 使用路由表查找目标地址的接口(interface)名称

c - 具有全局值的回溯的递归差异?

c - 在 C 程序中为 double 加上 f 后缀

php - Laravel 文件下载响应内容类型为 text/html in localhost

macos - 在本地主机上使用 https xampp 在 mac 上