Il existe de nombreux exemples d'annulation de licences persistantes lors de la déconnexion à l'aide d'IdentityServer4, mais tous affichent le paramètre ClientId de façon statique. Tout le monde sait comment obtenir dynamiquement le ClientId car je prévois d'utiliser ce IdentityServer avec plusieurs clients différents. Voici le code found here vous trouvez habituellement, regardez la deuxième à la dernière ligne:Déconnexion IDSRV4 - obtention dynamique de l'ID client
[HttpPost]
[ValidateAntiForgeryToken]
[AllowAnonymous]
public async Task<IActionResult> Logout(LogoutViewModel model)
{
var idp = User?.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;
var subjectId = HttpContext.User.Identity.GetSubjectId();
if (idp != null && idp != IdentityServerConstants.LocalIdentityProvider)
{
if (model.LogoutId == null)
{
// if there's no current logout context, we need to create one
// this captures necessary info from the current logged in user
// before we signout and redirect away to the external IdP for signout
model.LogoutId = await _interaction.CreateLogoutContextAsync();
}
string url = "/Account/Logout?logoutId=" + model.LogoutId;
try
{
// hack: try/catch to handle social providers that throw
await HttpContext.Authentication.SignOutAsync(idp, new AuthenticationProperties { RedirectUri = url });
}
catch(NotSupportedException)
{
}
}
// delete authentication cookie
await _signInManager.SignOutAsync();
// set this so UI rendering sees an anonymous user
HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
// get context information (client name, post logout redirect URI and iframe for federated signout)
var logout = await _interaction.GetLogoutContextAsync(model.LogoutId);
var vm = new LoggedOutViewModel
{
PostLogoutRedirectUri = logout?.PostLogoutRedirectUri,
ClientName = logout?.ClientId,
SignOutIframeUrl = logout?.SignOutIFrameUrl
};
await _persistedGrantService.RemoveAllGrantsAsync(subjectId, "angular2client");
return Redirect(Config.HOST_URL + "/index.html");
}
Demandez-vous comment trouver l'identifiant client pour l'application cliente qui a déclenché la déconnexion? Aussi, d'où avez-vous eu ce code? –
@ScottBrady Hé, c'est le fameux Scott Brady! Merci d'avoir répondu, je viens de trouver la réponse c'était trop simple. Je n'aurais probablement pas dû poster ça. Je suis sur le point de répondre à ma propre question après le test. Je vais ajouter le lien à ma question. – Helzgate