MVC3 + WIF - FederationResult 缺少“wctx”

发布于 2024-11-25 16:04:13 字数 1078 浏览 1 评论 0原文

我有一个 MVC3 应用程序,我想为其实现索赔支持。我的目标如下:

  1. 提供一个登录链接,单击该链接时会显示一个带有用户名/密码和 Facebook/WindowsLive/Google 等链接的弹出窗口

  2. 当访问受保护的控制器时自动重定向到我的登录页面,例如 /Order/Delete

我已在 AppFabricLabs.com 中设置了应用程序和提供程序,并将 STS 包含在我的项目中。我还创建了 IAuthorizationFilter 的实现,以便我可以将控制器标记为 [WifAuth] 并成功调用 OnAuthorization 方法。我已经实现了访问者尚未经过身份验证的用例,如下所示:

    private static void AuthenticateUser(AuthorizationContext context)
    {
        var fam = FederatedAuthentication.WSFederationAuthenticationModule;
        var signIn = new SignInRequestMessage(new Uri(fam.Issuer), fam.Realm);
        context.Result = new RedirectResult(signIn.WriteQueryString());
    }

并使用我的身份提供商选择成功获取 AppFabricLabs 页面(尚未弄清楚如何自定义该页面)。当我登录时,我的 returnUrl 被调用,因此我进入了控制器方法 /Home/FederationResult,但是发布给我的表单仅包含 wawresult 字段,但我需要 < strong>wctx 知道将用户发送到哪里...我一直无法弄清楚为什么。

wresult 是一个 XML 文档,其中包含(以及无数其他内容)登录用户的姓名和电子邮件地址,但遗憾的是不包含用户前往的 URL。

我是否配置失败,或者我是否偏离了基地?有人有什么想法吗?

  • e

I have an MVC3 app for which I want to implement claims support. My goal is as follows:

  1. provide a SignIn link, which when clicked displays a popup window with username/password and Facebook/WindowsLive/Google etc. links

  2. automatically redirect to my SignIn page when a protected controller is accessed e.g. /Order/Delete

I've set up the application and providers in AppFabricLabs.com and included the STS in my project. I've also created an implementation of IAuthorizationFilter so I can mark my controllers as [WifAuth] and successfully get the OnAuthorization method called. I've implemented the use-case where the visitor has not been authenticated like this:

    private static void AuthenticateUser(AuthorizationContext context)
    {
        var fam = FederatedAuthentication.WSFederationAuthenticationModule;
        var signIn = new SignInRequestMessage(new Uri(fam.Issuer), fam.Realm);
        context.Result = new RedirectResult(signIn.WriteQueryString());
    }

and successfully get AppFabricLabs page with my Identity Provider choices (haven't figured out how to customise that page). When I log in my returnUrl gets called so I land in a controller method /Home/FederationResult, however the form posted to me contains only wa and wresult fields but I need wctx to know where to send the user... I haven't been able to figure out why.

the wresult is an XML document that contains (amongst a bzillion other things) the name and e-mail address of the user logging in but sadly does not contain the url to which the user was headed.

have I failed to configure something or am I just off base? thoughts anyone?

  • e

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑红尘 2024-12-02 16:04:13

只需为 SignInRequestMessage 指定一个上下文:

signIn.Context = HttpContext.Current.Request.RawUrl;

wctx 参数包含在每个请求/响应中,也是最终发布到您网站的表单的一部分。

Just specify a Context for the SignInRequestMessage:

signIn.Context = HttpContext.Current.Request.RawUrl;

The wctx parameter is included in every request/response and also part of the form posted finally to your site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文