我已将elmah添加到asp.net mvc 4应用程序中。日志记录正常工作,现在我正在尝试配置安全性,但是elmah没有获取设置,而且所有用户都可以看到日志。
这是一个Intranet应用程序,因此我们使用Windows集成安全性。我正在尝试限制访问,以便只有域\log_readers AD组的成员可以读取日志。
我已阅读了此处的设置指南:http://code.google.com/p/elmah/wiki/SecuringErrorLogPages,并且我还阅读了 SO 和其他论坛上的几篇帖子,这些帖子促使我添加了roleManager和WindowsRoleProvider配置,但均无效。
这是我的web.config文件中关于elmah部分的内容:
<elmah>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on remote access and securing ELMAH.
-->
<security allowRemoteAccess="true" />
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/Logs" />
</elmah>
<location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<authentication mode="Windows" />
<roleManager defaultProvider="WindowsProvider"
enabled="true" cacheRolesInCookie="false">
<providers>
<add
name="WindowsProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on using ASP.NET authorization securing ELMAH.
-->
<authorization>
<allow roles="domain\log_readers"/>
<deny users="*" />
</authorization>
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
</location>
我还尝试了完全的锁定,通过将我的授权配置设置为拒绝所有人。
<authorization>
<deny users="*" />
</authorization>
还有
<authorization>
<deny users="?" />
</authorization>
记录仍然对所有人开放。
我怀疑问题可能出在位置上。我没有更改elmah的位置。它从默认位置访问(http://server/myapp/elmah)。