2

我从 ACS 门户为我的应用程序下载了示例登录页面,这是一个 html 文件。然后我用 WIF 配置了我的应用程序,一切都运行良好。

由于我们需要处理和保存传入的查询字符串,以便用户登录后可以稍后使用查询字符串,因此我们需要将 html 登录页面移动到 aspx 页面。

问题是当我将 web.config 文件中 WIF 的颁发者更改为 aspx 文件时,它停止工作。当它工作时,它看起来像这样:

<certificateValidation certificateValidationMode="None" />
  <federatedAuthentication>
    <wsFederation passiveRedirectEnabled="true" issuer="http://localhost:81/acstest/WebSiteAdvancedACSLoginPageCode.html" realm="http://localhost:81/acstest/" requireHttps="false" />
    <cookieHandler requireSsl="false" />
  </federatedAuthentication>

但是当我将其更改为我的 aspx 页面时,我只是将 html 页面中的所有代码移入其中,我什至无法加载该页面:

<certificateValidation certificateValidationMode="None" />
  <federatedAuthentication>
    <wsFederation passiveRedirectEnabled="true" issuer="http://localhost:81/acstest/WebSiteAdvancedACSLoginPageCode.aspx" realm="http://localhost:81/acstest/" requireHttps="false" />
    <cookieHandler requireSsl="false" />
  </federatedAuthentication>

然后,当我使用配置的 aspx 文件运行时,我可以在 fiddler 中看到一些不正确的东西,它尝试获取,并不断获取“对象移动到此处:”这是获取请求:

GET http://localhost:81/acstest/WebSiteAdvancedACSLoginPageCode.aspx?wa=wsignin1.0&wtrealm=http%3a%2f%2flocalhost%3a81%2facstest%2f&wctx=rm%3d0%26id%3dpassive%26ru%3d%252facstest%252fWebSiteAdvancedACSLoginPageCode.aspx&wct=2011-11-23T09%3a33%3a30Z HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: sv-SE
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: localhost:81
Cookie: ACSChosenIdentityProvider-10001951=Google

最后它会抛出查询字符串太长的异常。请求的错误和警告:

MODULE_SET_RESPONSE_ERROR_STATUS

ModuleName UrlAuthorization

通知 AUTHORIZE_REQUEST

Http状态 401

HttpReason 未经授权

HttpSubStatus 0

ErrorCode Åtgärden har slutförts。(0x0)

配置异常信息

任何反馈或替代解决方案都值得赞赏。

4

1 回答 1

3

“发行者”应该仍然是 ACS,而不是您的站点(除非您实现自己的 STS,这看起来不像您想要的那样)。发行者 == WIF 配置中的 STS。

在令牌协商(通过重定向发生)中保留状态(例如 url 等)的最佳候选者是通过wctx参数。您可以通过编程方式进行设置。

查看此下载中的示例 #7:http: //www.microsoft.com/download/en/details.aspx?id=27289

章节: http: //msdn.microsoft.com/en-us/library/hh446534.aspx来自本指南:http: //msdn.microsoft.com/en-us/library/ff423674.aspx

代码如下所示(片段):

var returnUrl = GetReturnUrl(context.RequestContext);

// user is not authenticated and it's entering for the first time
var fam = FederatedAuthentication.WSFederationAuthenticationModule;
var signIn = new SignInRequestMessage(new Uri(fam.Issuer), fam.Realm)
                {
                    Context = returnUrl.ToString(),
                    Realm = string.Format("https://localhost/f-shipping.7/{0}", organizationName)
                };

context.Result = new RedirectResult(signIn.WriteQueryString());
于 2011-11-23T17:44:58.623 回答