Possible to display ClientName instead of ClientId after user is Logged Out?
Hi,
I am using IdentityServer4 including the QuickStart UI from the IDSRV4 repo.
I can successfully connect my MVC App to IdentityServer using hybrid flow but I noticed one thing when I logged out of the application. In the IdentityServer4 LoggedOutView it is showing my ClientId (used to connect MVC app to IDSRV4) instead of the client name.

Is it possible to display the ClientName instead of the ClientId? I find ClientName more applicable to be displayed on the LoggedOut page.
Greatly appreciate for your inputs. Thanks.
IDSRV4 log snippet

IDSRV4 Client and MVC Client Configuration
new Client
{
ClientId = "mvc-client",
ClientName = "MVC Client",
AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
ClientSecrets =
{
new Secret("secret".Sha256())
},
RedirectUris = { "http://localhost:40078/signin-oidc" },
PostLogoutRedirectUris = { "http://localhost:40078/signout-callback-oidc" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
},
AllowOfflineAccess = true
};
// MVC Client
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = "oidc",
SignInScheme = "Cookies",
Authority = "http://localhost:5000",
RequireHttpsMetadata = false,
ClientId = "mvc-client",
ClientSecret = "secret",
ResponseType = "code id_token",
Scope = { "api1" },
GetClaimsFromUserInfoEndpoint = true,
SaveTokens = true,
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name"
}
});
It is up to you to create the UI you want in the Identityserver. The repository contains just a sample implementation for the UI.
The LoggedOutViewModel has a property ClientName so you can change the ClientId to that.
<div>
<p>
Click <a class="btn btn-default" href="@Model.PostLogoutRedirectUri">here</a> to return to the
<span>@Model.ClientName</span> application.
</p>
</div>
thanks for the reply @user1336. i do know we have full control on the UI we want for IDSRV.
i have been checking the code in the AccountService.BuildLoggedOutViewModel() method but it seems the LogoutRequest (logout context returned) does not have the ClientName property. So I still could not set the value of the ClientName property in the LoggedOutViewModel.
do correct me if i am wrong.

above code snippet for LogoutMessage (parent class of LogoutRequest) does not have a ClientName property.

If only there were a way to map clientId to a client.... hmmmm!
https://github.com/IdentityServer/IdentityServer4.Samples/blob/release/Quickstarts/8_EntityFrameworkStorage/src/QuickstartIdentityServer/Quickstart/Account/AccountService.cs#L73
Pretty sure this will point you in the right direction!
Yes, what @Mardoxx said.
thanks @Mardoxx @brockallen. I thought ClientName would be returned via the logoutcontext. no further questions from this issue.
Sorry to reopen it, I have the same question. What is the solution now to show the Client Name in the UI.
LoggedOutViewModel is built from the LogoutMessage.
Why can't the LogoutMessasge have also the ClientName like this:
public LogoutMessage(ValidatedEndSessionRequest request)
{
if (request != null)
{
Parameters = request.Raw;
ClientId = request.Client?.ClientId;
**ClientName= request.Client?.ClientName;**
LoggedOutViewModel will use the ClientName instead of ClientId:
var vm = new LoggedOutViewModel
{
AutomaticRedirectAfterSignOut = AccountOptions.AutomaticRedirectAfterSignOut,
PostLogoutRedirectUri = logout?.PostLogoutRedirectUri,
**ClientName = logout?.ClientName**,
SignOutIframeUrl = logout?.SignOutIFrameUrl,
LogoutId = logoutId
};
@kevinlo send a PR please.
@brockallen Ok. If you feel that is the right way, I'll do it, but maybe next week.
@brockallen I just read about #231, you suggested to
inject the IClientStore into your controller, and then lookup the Client configuration (and thus the name) from the ClientId passed via the context.
That works for me. I don't need to add the ClientName to the LogoutMessage unless you feel that is a better way.
Like I said, feel free to submit a PR if you think it helps improve the OSS code.
Just submit the pull request #1893
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.