我有一个受基本authentication保护的虚拟目录。 我想要禁用某些IP地址的身份validation,以便所有来自例如127.0.0.1的请求都被允许而不要求提供凭证。 我怎样才能做到这一点?
我无法find一个内置的方法来实现这一点。 我用http://learn.iis.net/page.aspx/170/developing-a-module-using-net/上的说明写了一个IIS模块。
模块检查客户端的IP地址(使用HttpRequest.UserHostAddress ),如果它不在免除列表中,则重新实现Windows帐户的标准基本authentication(使用LogonUser API并将HttpContext.User设置为WindowsPrincipal )。 从web.config (使用ConfigurationManager.AppSettings )读取authentication域和免除IP地址列表。
绊脚石包括:
127.0.0.1和服务器的IP地址到免除列表,但也必须添加::1 (IPv6本地主机)。 hgrc的allow_push行中的条目从username更改为DOMAIN\username 。