Pet*_*ter 4 ws-federation asp.net-mvc-4
我正在运行Win 7,IIS 7.0,VS2012我已经创建了asp.mvc4 web应用程序我在单独的VM上有ADFS2.0
使用VS 2012中的Identity and Access工具
我选择使用业务标识提供程序(例如ADFS2)并键入STS元数据文档的URL.
HTTPS://server.local/federationmetadata/2007-06/federationmetadata.xml
编辑了Web配置
<system.web>
...
<httpModules>
...
<remove name="FormsAuthentication" />
</httpModules>
</system.web>
Run Code Online (Sandbox Code Playgroud)
还有这个
<system.webServer>
...
<modules>
...
<remove name="FormsAuthentication" />
</modules>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
还检查了为项目禁用了Windows身份验证
该网站重定向到这样的URL http:// localhost /WebSite/login.aspx?ReturnUrl=%2fWebSite%2f,其中包含"无法找到资源"错误.
我还有什么可以帮助你做这项工作?
Microsoft doco是轻量级的http://blogs.msdn.com/b/vbertocci/archive/2012/03/15/windows-identity-foundation-tools-for-visual-studio-11-part-iii-connecting-with -a-企业STS-EG-adfs2.aspx
我已经遇到过与本地开发STS MS Identity and Access Tool MVC 4类似的问题
好的,这花了我几天的时间来解决,但这些是我为了让它运行而做的事情.还有很多工作要做.
先决条件:
论发展工作站
在你的MVC4项目中
将以下代码添加到项目中
using System;
using System.IdentityModel.Services;
namespace NAMESPACE
{
public class FixedWsFederationAuthenticationModule : WSFederationAuthenticationModule
{
public override void RedirectToIdentityProvider(string uniqueId, string returnUrl, bool persist)
{
//This corrects WIF error ID3206 "A SignInResponse message may only redirect within the current web application:"
//First Check if the request url doesn't end with a "/"
if (!returnUrl.EndsWith("/"))
{
//Compare if Request Url +"/" is equal to the Realm, so only root access is corrected
//https://localhost/AppName plus "/" is equal to https://localhost/AppName/
//This is to avoid MVC urls
if (String.Compare(System.Web.HttpContext.Current.Request.Url.AbsoluteUri + "/", base.Realm, StringComparison.InvariantCultureIgnoreCase) == 0)
{
//Add the trailing slash
returnUrl += "/";
}
}
base.RedirectToIdentityProvider(uniqueId, returnUrl, persist);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在ADFS 2.0服务器上
添加一些自定义规则
MVC4需要这些规则才能生成可用的ClaimsPrincipal
在Name属性上添加传递规则.
而这两个自定义规则
=> issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", Value = "true");
=> issue(Type = "http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", Value = "true");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3048 次 |
| 最近记录: |