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

2023-12-27

这在 Apache2.2 中完美运行,但在 2.4 中则不然(我need现在使用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 http://httpd.apache.org/docs/current/mod/mod_authnz_ldap.html工作于<Directory >部分:

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

但这允许身份验证仅反对oneLDAP服务器,并且我必须至少针对两个进行身份验证。
因此使用AuthnProviderAlias http://httpd.apache.org/docs/current/mod/mod_authn_core.html#authnprovideralias,现在是 (2.4) 的一部分mod_authn_core核心认证模块 http://httpd.apache.org/docs/current/mod/mod_authn_core.html,而不是旧的2.2 LDAP认证模块mod_authn_alias http://httpd.apache.org/docs/2.2/mod/mod_authn_alias.html.


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

我尝试的是调试会话(gdb --command=debug, with '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

我看到的是:

  • the authaliassection的函数mod_authn_core https://github.com/apache/httpd/blame/trunk/modules/aaa/mod_authn_core.c#L194-L207叫做twice,可能是因为server/main.c https://github.com/apache/httpd/blob/trunk/server/main.c calls ap_process_config_tree twice (一旦来过 https://github.com/apache/httpd/blame/trunk/server/main.c#L639, and 一旦到了那里 https://github.com/apache/httpd/blame/trunk/server/main.c#L739-L742) 在相同的main()功能 https://github.com/apache/httpd/blob/trunk/server/main.c#L438.

那个功能得到authcfg https://github.com/apache/httpd/blob/trunk/modules/aaa/mod_authn_core.c#L204-L206

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

And 设置提供者 https://github.com/apache/httpd/blob/trunk/modules/aaa/mod_authn_core.c#L267-L273用正确的名字'ldap'和正确的别名'myldap'

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

但是:当需要检查密码时(在authn_alias_check_password https://github.com/apache/httpd/blob/trunk/modules/aaa/mod_authn_core.c#L107-L108,得到authcfg再次,并且获取提供者 https://github.com/apache/httpd/blob/trunk/modules/aaa/mod_authn_core.c#L122-L123:

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

它使用正确的provider_name 'myldap', ...并且总是返回null.
这意味着prvdraliasrec->provider->check_password https://github.com/apache/httpd/blob/trunk/modules/aaa/mod_authn_core.c#L128-L131永远不会被打电话。

类似的问题在http-dev 邮件列表 http://mail-archives.apache.org/mod_mbox/httpd-dev/ (2013 年 8 月 23 日“AuthnProviderAlias 在 2.4 中是否被巧妙地破坏了?” http://mail-archives.apache.org/mod_mbox/httpd-dev/201308.mbox/%3C5215672C.8090304@aldan.algebra.com%3E)……没有得到答复。

您将如何解决这个错误?


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

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

解决方法:在 VH 上下文之外定义您的身份验证,或者如果您可以轻松重建,请尝试此补丁:http://people.apache.org/~covener/patches/authprovider.diff 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 */
 };
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AuthnProviderAlias ldap 可以与 Apache2.4.x 一起使用吗? 的相关文章

  • 如何重写 URL 而不刷新,例如 GitHub.com

    我在浏览 GitHub com 时注意到 在查看存储库的源代码时 您单击一个文件 源代码会滑入 并且 URL 会发生变化 但页面看起来并没有刷新 有谁知道这是如何做到的 我见过使用 符号完成此操作 尤其是在创建 Flash 站点时 但我从未
  • 使用来自本地对象的消息的 std::Exception

    以下代码是否可以安全地抛出带有自定义消息的异常 include
  • C 中的分段错误

    我需要用 0 填充二维数组 但编译后的程序会出现此错误 怎么了 int main int vert 1001 1001 int hor 1001 1001 int dudiag 1416 1416 int uddiag 1416 1416
  • 使用 QTextCursor 选择一段文本

    使用 Qt 框架选择文本片段时遇到问题 例如 如果我有这个文件 没有时间休息 我想选择 ime for r 并从文档中删除这段文本 我应该如何使用 QTextCursor 来做到这一点 这是我的代码 QTextCursor cursor n
  • 将内核链接到 PTX 函数

    我可以使用 PTX 文件中包含的 PTX 函数作为外部设备函数 将其链接到另一个应调用该函数的 cu 文件吗 这是另一个问题CUDA 将内核链接在一起 https stackoverflow com questions 20636800 c
  • 优化对绑定到 DataGridView 的 DataTable 的更新

    我的应用程序中有一个显示一些数据的表单 当我第一次显示表单时 我将一些数据加载到 DataTable 中 然后将 DataTable 绑定到 DataGridView 我还启动了一个异步方法来执行一些较慢的数据库查询 当这些慢查询完成时 我
  • ResourceDictionary 源中的 Uri 语法(通用 Windows 平台)

    我正在迁移我的Windows 8 1项目到Windows 10 通用 Windows 平台 这时我被拦住了ResourceDictionary改变在UWP 为了简单起见 我有包含 2 个项目的 Windows 8 1 解决方案 App pr
  • 了解 MVC-5 身份

    我创建了一个新的ASP NET MVC 5申请与Individual User Accounts然后更新了所有的Nuget packages在解决方案中 现在我尝试遵循一些教程中显示的一些指南 但遇到了一些问题 第一个是一个名为Applic
  • 没有真正理解 std::atomic::compare_exchange_weak 和compare_exchange_strong 的逻辑

    我读了https en cppreference com w cpp atomic atomic compare exchange https en cppreference com w cpp atomic atomic compare
  • 编译器在函数名称前添加下划线前缀的原因是什么?

    当我看到 C 应用程序的汇编代码时 如下所示 emacs hello c clang S O hello c o hello s cat hello s 函数名称以下划线作为前缀 例如callq printf 为什么这样做以及它有什么优点
  • C# Linq 可以做组合数学吗?

    我有这个数据结构 class Product public string Name get set public int Count get set var list new List
  • 一些涉及类析构函数和删除运算符的内存管理问题?

    在阅读了一些教程后 我仍然不清楚 C 中内存管理的一些观点 1 当使用 new 运算符声明的类超出范围时 是否会调用其析构函数并释放内存 是否有必要调用删除运算符来释放类的内存并调用其析构函数 class Test void newTest
  • 一个对大文件有效的轻量级 XML 解析器?

    我需要解析潜在的巨大 XML 文件 所以我猜这排除了 DOM 解析器 是否有任何优秀的 C 轻量级 SAX 解析器 在占用空间上可与 TinyXML 相媲美 XML的结构非常简单 不需要诸如命名空间和DTD之类的高级东西 只是元素 属性和
  • MPI_Gatherv:根数组中收到的垃圾值

    我正在尝试实施MPI Gatherv函数于C 根据我的程序 包括 root 在内的每个进程都应该创建一个大小等于 进程的等级 1 这将在所有单元格中保持进程的等级 然后这个本地数组被收集到根的 rcv array 中 不知何故 我得到了垃圾
  • 将函数作为函数参数传递

    Unity C 似乎无法识别Func lt gt 作为函数委托的符号 那么 如何将函数作为函数参数传递呢 我有一个想法Invoke functionName 0 可能有帮助 但我不确定它是否实际上立即调用该函数 或者等待帧结束 还有别的办法
  • 序列化时如何跳过 xml 声明?

    我正在尝试输出一个没有 xml 头的 xml 文件 例如 我试过 Type t obj GetType XmlSerializer xs new XmlSerializer t XmlWriter xw XmlWriter Create c
  • MonoGame 中的 ContentLoadException

    我一直在尝试使用 Xamarin Studio 在 MonoGame 中加载纹理 我的代码设置如下 region Using Statements using System using Microsoft Xna Framework usi
  • 字符串常量之前应有非限定 ID

    我目前正在编写一个 C 应用程序 它与 math h 结合实现了振荡器 我拥有的代码应该可以很好地用于该应用程序 尝试编译目标文件 但是我遇到编译器错误 很可能与语法 等有关 我认为这与命名空间有关 错误 终端输出 User Name Ma
  • 散列 hash_hmac 时,Convert.ToChar(0) 散列结果与 PHP 中的 chr(0) 不同的字符串

    我在 PHP 中有一个字符串 它被转换为字节数组并进行哈希处理 转换为字节数组的字符串如下所示 G 字符 0 便便 我需要 C 中的等效字节数组 这样我才能得到相同的哈希值 编辑 这是完整的问题 生成的哈希值不同 PHP api secre
  • “保留供任何使用”是什么意思?

    注意 这是一个c questions tagged c问题 虽然我补充说c questions tagged c 2b 2b如果某些 C 专家可以提供 C 使用与 C 不同的措辞的基本原理或历史原因 在 C 标准库规范中 我们有这个规范文本

随机推荐