简体   繁体   中英

Profile data from OpenIdConnect provider - Thinktecture IdentityServer V3

I am using Thinktecture IdentitiyServer V3 as OpenIdConnect provider for authentication. I have a custom user service that authenticate users against Active Directory. I want to send some profile data to the RP. Authentication is happening successfully but I am not sure how to configure the RP to retrieve profile data.

My user service implement GetProfileDataAsync method to get the required data with my current configuration this method never gets hit.

I am new to OpenIdConnect. Please help.

My RP Configuration from Startup.cs:

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);
                }

            }

        });

You are requesting both identity token and access token by providing ResponseType="id_token token". Try to request id_token only to check if GetProfileDataAsync will be executed.

Also read about scope's AlwaysIncludeInIdToken. By default identity server does not include data if identity token requested together with access token, assumed that you will manually request this info by UserInfo endpoint.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM