【问题标题】:Profile data from OpenIdConnect provider - Thinktecture IdentityServer V3来自 OpenIdConnect 提供商的配置文件数据 - Thinktecture IdentityServer V3
【发布时间】:2015-11-18 11:26:55
【问题描述】:

我使用 Thinktecture IdentitiyServer V3 作为 OpenIdConnect 提供程序进行身份验证。我有一个自定义用户服务,可以针对 Active Directory 对用户进行身份验证。我想向 RP 发送一些配置文件数据。身份验证成功进行,但我不确定如何配置 RP 以检索配置文件数据。

我的用户服务实现了 GetProfileDataAsync 方法,以使用我当前的配置获取所需的数据,此方法永远不会被命中。

我是 OpenIdConnect 的新手。请帮忙。

我在 Startup.cs 中的 RP 配置:

app.UseCookieAuthentication(new CookieAuthenticationOptions()
        {
            AuthenticationType = "Cookies"
        });

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
        {
            Authority = "url",
            ClientId = "owinmvc",
            Scope = "openid profile",
            ResponseType = "id_token token",
            RedirectUri = "https://localhost:44307/",
            SignInAsAuthenticationType = "Cookies",

            Notifications = new OpenIdConnectAuthenticationNotifications()
            {
                SecurityTokenValidated = (context) =>
                {
                    var identity = context.AuthenticationTicket.Identity;
                    identity.AddClaim(new Claim("CustomRoleClaim", "This is a role"));
                    return Task.FromResult(0);
                }

            }

        });

【问题讨论】:

    标签: c# asp.net-mvc-5 owin thinktecture-ident-server openid-connect


    【解决方案1】:

    您通过提供 ResponseType="id_token token" 来请求身份令牌和访问令牌。尝试仅请求 id_token 以检查是否会执行 GetProfileDataAsync。

    还可以阅读范围的 AlwaysIncludeInIdToken。默认情况下,如果身份令牌与访问令牌一起请求,身份服务器不包含数据,假设您将通过 UserInfo 端点手动请求此信息。

    【讨论】:

    • 是的。我能够解决这个问题,但我没有更新问题。我做了两个改变。我已将电子邮件添加到我的范围并将 AlwaysIncludeInToken 设置为 True。
    猜你喜欢
    • 2015-04-08
    • 2015-05-02
    • 1970-01-01
    • 2015-03-24
    • 1970-01-01
    • 1970-01-01
    • 2014-12-26
    • 1970-01-01
    • 2015-04-20
    相关资源
    最近更新 更多