[英]ASP.NET MVC bypass/simulate ws-federation/claims-based authentication
在我们的ASP.NET MVC 5项目中,我们将应用程序设置为通过Azure访问控制使用ws联合身份验证。
Web.config的节选:
...
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" persistentSessionLifetime="30:0:0" />
<wsFederation passiveRedirectEnabled="true" realm="http://our-realm/.../" reply="http://localhost/" requireHttps="false" issuer="https://ourissuername.accesscontrol.windows.net/v2/wsfederation" />
</federationConfiguration>
</system.identityModel.services>
...
<modules runAllManagedModulesForAllRequests="true">
<remove name="FormsAuthentication" />
<add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
...
</modules>
...
在应用程序的后面,我们依靠ClaimsPrincipal.Current.Identity.IsAuthenticated
的事实,并具有所有必需的声明,至少是电子邮件地址。
为了ClaimsPrincipal
测试,我们想用我们的自定义声明(例如,运行一些仅适用于此配置的自定义代码)来模拟硬编码的ClaimsPrincipal
,并绕过整个wsfederation过程,尤其是整个重定向。 例如,我们可以仅删除WSFederationAuthenticationModule
并能够跳过ws-federation过程,但我不知道如何提供自己的ClaimsPrincipal
。
有什么提示如何轻松解决吗? (省力,因为它不会用于生产等)
您是否看过Visual Studio身份和访问工具附加组件( https://visualstudiogallery.msdn.microsoft.com/e21bf653-dfe1-4d81-b3d3-795cb104066e )? 它具有开发STS服务,可提供伪造的身份验证信息以进行测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.