我已经将elmah添加到了asp.net MVC4应用程序中。日志记录工作正常,现在我正在尝试配置安全性,但elmah没有获取设置,日志对所有用户都可见。
这是一个内部网应用程序,因此我们使用的是windows集成安全。我正在尝试限制访问,以便只有domain\log_readers广告组的成员才能读取日志。
我已经阅读了这里的设置指南: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)访问它
发布于 2012-12-06 22:17:16
如果你使用Elmah.Mvc,他们有非常细粒度的安全设置。例如,您可以轻松地保护elmah页面,使其仅对Admin组中的登录用户可用。
在<appSettings>
中,Elmah.Mvc支持以下各项
<appSettings>
<!-- ELMAH configuration. Admin page only available for logged in users in
the Admin role. -->
<add key="elmah.mvc.disableHandler" value="false" />
<add key="elmah.mvc.disableHandleErrorFilter" value="false" />
<add key="elmah.mvc.requiresAuthentication" value="true" />
<add key="elmah.mvc.allowedRoles" value="Admin" />
<add key="elmah.mvc.route" value="elmah" />
</appSettings>
感兴趣的键是elmah.mvc.requiresAuthentication
,它打开需要登录的用户。以及elmah.mvc.allowedRoles
,它指定用户必须在哪个角色中。
您可以从nuget安装Elmah.Mvc。
发布于 2013-08-03 00:12:20
当我发现如何在使用Windows身份验证时确定角色时,上面的答案非常有效:
打开命令窗口,然后输入以下命令:
cmd /k net user <user> /Domain
对于<user>
,请替换您的用户名。该命令将列出您所属的组。
这些说明来自http://msdn.microsoft.com/en-us/library/gg703322(VS.98).aspx的“如何使用ASP.NET MVC创建内部网站点”。
https://stackoverflow.com/questions/13703763
复制相似问题