【问题标题】:Azure samples - WebApp-WSFederation-DotNetAzure 示例 - WebApp-WSFederation-DotNet
【发布时间】:2016-04-26 19:46:32
【问题描述】:

可以在此处找到示例应用程序 --> https://github.com/Azure-Samples/active-directory-dotnet-webapp-wsfederation

应用程序正在使用 Microsoft.Owin,这是我所期望的:

  1. 用户导航到您的应用程序。

  2. 您的应用程序将匿名用户重定向到 Azure AD 进行身份验证,发送一个指示领域参数的应用程序 URI 的 WS-Federation 协议请求。 URI 应与单点登录设置中显示的 App ID URI 匹配。

  3. 请求被发送到您的租户 WS-Federation 端点,例如:https://login.windows.net/solexpaad.onmicrosoft.com/wsfed

  4. 用户会看到一个登录页面,除非他或她已经拥有 Azure AD 租户的有效 cookie。

  5. 通过身份验证后,SAML 令牌会在 HTTP POST 中返回到应用程序 URL,并带有 WS-Federation 响应。要使用的 URL 在单点登录设置中指定为回复 URL。

  6. 应用程序处理此响应,验证令牌是否由受信任的颁发者 (Azure AD) 签名,并确认令牌仍然有效。

我的问题:

身份验证后,通过 HTTP POST 返回 SAML 令牌。如何查看 SAML 响应?目前,当我在 POST 后查看 HttpContext 时,其中没有任何内容。

感谢您的帮助。

【问题讨论】:

    标签: azure single-sign-on azure-active-directory


    【解决方案1】:

    在 App_Start/Startup.Auth.cs 中,您应该能够访问令牌。 我添加了 SecurityTokenReceived 函数:

    app.UseWsFederationAuthentication(
        new WsFederationAuthenticationOptions
        {
            Wtrealm = realm,
            MetadataAddress = metadata,
            Notifications = new WsFederationAuthenticationNotifications
                {
                    AuthenticationFailed = context =>
                    {
                        context.HandleResponse();
                        context.Response.Redirect("Home/Error?message=" + context.Exception.Message);
                        return Task.FromResult(0);
                    },
                    SecurityTokenReceived = context =>
                    {
                        // Get the token
                        var token = context.ProtocolMessage.GetToken();
                        return Task.FromResult(0);
                    }
                }
            });
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2021-11-24
    • 2022-01-10
    • 2012-04-15
    相关资源
    最近更新 更多