【问题标题】:Can AuthnProviderAlias ldap work with Apache2.4.x?AuthnProviderAlias ldap 可以与 Apache2.4.x 一起使用吗?
【发布时间】:2013-09-23 07:42:04
【问题描述】:

这在 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 的指令在&lt;Directory &gt; 部分有效:

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,在调试模式下 (-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

我看到的是:

那个函数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中,它再次得到authcfg,然后fetch the provider

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

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

http-dev mailing list (August 23, 2013 "Is AuthnProviderAlias subtly broken in 2.4?") 中的一个类似问题......没有得到解答。

您将如何解决此错误?

【问题讨论】:

  • 我唯一的建议是使用 gdb 跟踪具有工作 ldap 配置的服务器的身份验证序列,希望这会暴露配置行为之间的差异
  • @GearoidMurphy 这意味着在 Apache 2.2 中进行跟踪。并且在 2.2 和 2.4 之间进行了一些大规模的重构......在移动的代码中找出错误并不容易。

标签: c apache configuration ldap


【解决方案1】:

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

  • 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 */
 };

【讨论】:

  • 2.2 有效,因为 AuthType 和 不在同一个模块中
  • 提前+1。我将在下周一上班时测试一下。我可以重建任何我想要的版本并应用任何补丁。这就是我过去几个月在pre (pre-make) 步骤中所做的事情:raw.github.com/VonC/compileEverything/master/.cpl/params/apache
  • 是的!!!最后。使用其中的补丁重新编译的 Apache 2.4.7 似乎可以正常工作。我想知道该补丁是否会在 2.4.8 或 2.5 中发布。
  • 有没有人为此向 Apache 项目提交过错误?
【解决方案2】:

我找到的唯一可行的解​​决方案是修补 mod_authn_core.c,添加 2 个全局变量,一个用于我想要使用的每个 LDAP 别名。

这看起来很难看:两个 LDAP 别名在代码中是硬编码的。

commit 2f691a6

provider_alias_rec *prvdraliasrec_myldap;
provider_alias_rec *prvdraliasrec_companyldap;

这样,merge_authn_core_dir_config() 会专门查找这两个别名来注册它们。

if (!prvdraliasrec && strcmp(provider_name,"myldap")==0) {
  prvdraliasrec=prvdraliasrec_myldap; 
}
if (!prvdraliasrec && strcmp(provider_name,"companyldap")==0) {
  prvdraliasrec=prvdraliasrec_companyldap;
}

然后authaliassection() 取回这些别名定义

if ( strcmp(provider_alias,"myldap") == 0 ) { 
  prvdraliasrec_myldap = prvdraliasrec;
}
if ( strcmp(provider_alias,"companyldap") == 0 ) {
  prvdraliasrec_companyldap = prvdraliasrec;
}

它有效,但它肯定不是“正确”的解决方案。

【讨论】:

    猜你喜欢
    • 2011-11-25
    • 1970-01-01
    • 2013-06-11
    • 1970-01-01
    • 2011-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-22
    相关资源
    最近更新 更多