简体   繁体   English

如何使MVC Sitemap提供程序正确调整安全性

[英]How to get MVC Sitemap provider to security trim properly

I have the following sitemap XML using mvcsitemapprovider project. 我有以下使用mvcsitemapprovider项目的站点地图XML。

It is not hiding the following node when all of the children are not accessible to the user: 当用户无法访问所有子项时,它不会隐藏以下节点:

 <mvcSiteMapNode url="~/Form.aspx" title="Form Editor" roles="ItemBank User" /> 

Instead it just shows an unclickable link titled "Forms". 相反,它仅显示标题为“ Forms”的不可单击的链接。

How do you make MVCSitemapProvider hide the parent unclickable links when none of the children are visible to the end user? 当最终用户看不到任何子级时,如何使MVCSitemapProvider隐藏父级不可点击的链接?

 <?xml version="1.0" encoding="utf-8" ?> <mvcSiteMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0" xsi:schemaLocation="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0 MvcSiteMapSchema.xsd"> <mvcSiteMapNode url="~/Default.aspx" title="Web Site" roles="*" > <mvcSiteMapNode title="Forms" clickable="false"> <mvcSiteMapNode url="~/Form.aspx" title="Form Editor" roles="ItemBank User" /> <mvcSiteMapNode url="~/FormHierarchy.aspx" title="Form Hiearchy" roles="ItemBank User" /> <mvcSiteMapNode url="~/ContentCodeEditor.aspx" title="Content Code Editor" roles="ItemBank User"/> <mvcSiteMapNode url="~/FormCopy.aspx" title="Form Copy" roles="ItemBank User"/> <mvcSiteMapNode controller="Home" action="Index" area="Mvc" title="Mvc Area Non-Admin"/> <mvcSiteMapNode controller="Home" action="Index2" area="Mvc" title="Mvc Area Admin"/> </mvcSiteMapNode> <mvcSiteMapNode title="Items" clickable="false" roles="ItemBank User"> <mvcSiteMapNode url="~/Items.aspx" title="Item Editor" roles="ItemBank User" /> <mvcSiteMapNode url="~/NewItem.aspx" title="New Item" roles="ItemBank User" /> <mvcSiteMapNode url="~/ItemPairings.aspx" title="Item Pairings" roles="ItemBank User" /> <mvcSiteMapNode url="~/ItemCopy.aspx" title="Item Copy" roles="ItemBank User" /> <mvcSiteMapNode url="~/ContentReclassification.aspx" title="Content Reclassification" roles="ItemBank User"/> </mvcSiteMapNode> </mvcSiteMapNode> </mvcSiteMap> 

There is a TrimEmptyGroupingNodesVisibilityProvider for this specific purpose. 有一个TrimEmptyGroupingNodesVisibilityProvider用于此特定目的。

<mvcSiteMapNode url="~/Form.aspx" title="Form Editor" roles="ItemBank User" 
    visibilityProvider="MvcSiteMapProvider.TrimEmptyGroupingNodesVisibilityProvider, MvcSiteMapProvider" />

Reference: https://github.com/maartenba/MvcSiteMapProvider/issues/375 参考: https : //github.com/maartenba/MvcSiteMapProvider/issues/375

NOTE: The default implementation requires the node to be non-clickable in order to work. 注意:默认实现要求节点不可单击才能正常工作。 However, you could make a custom visibility provider to handle this case. 但是,您可以创建自定义可见性提供程序来处理这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM