这在 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)……没有得到答复。
您将如何解决这个错误?