簡體   English   中英

來自OpenIdConnect提供程序的配置文件數據-Thinktecture IdentityServer V3

[英]Profile data from OpenIdConnect provider - Thinktecture IdentityServer V3

我使用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);
                }

            }

        });

通過提供ResponseType =“ id_token令牌”,您正在請求身份令牌和訪問令牌。 嘗試僅請求id_token來檢查是否將執行GetProfileDataAsync。

另請參閱有關范圍的AlwaysIncludeInIdToken。 默認情況下,如果您請求身份令牌和訪問令牌一起使用,則身份服務器不包含數據,假設您將通過UserInfo端點手動請求此信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM