[英]How do I secure Elmah on ASP.Net MVC 4 with Windows Integrated Security : Elmah ignores my settings
我已将elmah添加到asp.net mvc 4应用程序中。 日志记录正在运行,现在我正在尝试配置安全性,但elmah没有获取设置,所有用户仍然可以看到日志。
这是一个内部网应用程序,因此我们使用windows集成secuirty。 我正在尝试限制访问权限,以便只有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>
我还尝试通过设置我的autorisation配置以拒绝所有人来完全锁定
<authorization>
<deny users="*" />
</authorization>
并且
<authorization>
<deny users="?" />
</authorization>
日志对所有人开放。
我怀疑问题可能与位置有关。 我没有改变elmah的位置。 它是从默认位置访问的( http:// server / myapp / elmah )
如果您使用Elmah.Mvc,它们具有相当精细的安全设置。 例如,您可以轻松地将elmah页面保护为仅对Admin组中的登录用户可用。
Elmah.Mvc支持<appSettings>
的以下项目
<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。
一旦我发现在使用Windows身份验证时如何确定角色,上面的答案效果很好:
打开命令窗口并输入以下命令:
cmd /k net user <user> /Domain
对于<user>
,请替换您的用户名。 该命令将列出您所属的组。
说明来自“如何使用ASP.NET MVC创建Intranet站点”, 网址为http://msdn.microsoft.com/en-us/library/gg703322(VS.98).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.