我们已经在我们的ASP.NET 4.5 MVC 4项目中借助标识和访问成功配置了windows身份基础(WIF)...扩展对于Visual Studio 2012.但无法从授权中排除特定路径以允许匿名访问。在ASP.NET MVC 4项目中排除WIF授权的特定路径
当我们进入我们的默认路由(即/Home
),被动重定向将我们重定向到配置的发布者URI。这是正确的。但是,现在假设我们想从STS认证排除路径/Guest
,让大家可以在不beeing路由到STS发行人访问http://ourhost/Guest
。只有静态文档位于那里。从Web.config
摘录:
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="http://ourhost/" />
</audienceUris>
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<trustedIssuers>
<add thumbprint="9B74****40D0" name="OurSTS" />
</trustedIssuers>
</issuerNameRegistry>
<certificateValidation certificateValidationMode="None" />
</identityConfiguration>
</system.identityModel>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" />
<wsFederation passiveRedirectEnabled="true" issuer="http://oursts/Issue" realm="http://ourhost/" reply="http://ourhost/" requireHttps="false" />
</federationConfiguration>
</system.identityModel.services>
而且我们有...
<system.webServer>
<!-- ... -->
<modules runAllManagedModulesForAllRequests="true">
<add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
<add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
<remove name="FormsAuthentication" />
</modules>
</system.webServer>
最后:
<system.web>
<!-- ... -->
<authentication mode="None" />
</system.web>
我们尝试没有成功如下:
<location path="~/Guest"> <!-- also "/Guest" is not working -->
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
我们也试图把一个小的Web.config文件放到这个文件夹,但没有成功。无论我们在浏览器中找到哪个Uri,我们都会重定向。
什么是实现这一目标的正确方法?
编辑
删除了以前的“接受回答”,将“接受答案” Eugenios answer,因为这是比较有用的回复。
谢谢欧金尼奥,我们使用Visual Studio 2012和 “添加STS引用” 不在那里可用,你必须使用“身份和交流cess ...“工具。我认为我接近解决方案,看起来像'passiveRedirectEnabled =“true”'将我重定向到STS,而不管任何属性的用法。设置为“false”并在自定义身份验证属性中使用一些重定向助手重定向似乎相当不错。完成后会发布我的解决方案,谢谢! – thmshd
我明白了。它也应该与passiveRedirectEnabled = true一起工作。我也会检查我的系统。 –
因为我确实遇到了启用passiveRedirectEnabled选项的问题,所以我想接受我自己的答案作为解决方案,但是我真的很感谢你对这个主题的帮助,我相信它也可能工作,但也许解决方案是埋在某个地方我的'web.config'设置结合IIS设置。谢谢你的时间,真的很感激! – thmshd