我试图让隐式流程为IdentityServer4工作.登录和注销正常工作,但PostLogoutRedirectUri返回null,尽管设置了需要设置的值.我想要的是注销过程在注销完成后重定向回我的应用程序.
我正确获取logoutId,Logout调用BuildLoggedOutViewModelAsync:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Logout(LogoutInputModel model)
{
var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId);
...
Run Code Online (Sandbox Code Playgroud)
此方法位于我的AccountService.cs类中,然后调用DefaultIdentityServiceInteractionService的GetLogoutContextAsync:
public async Task<LoggedOutViewModel> BuildLoggedOutViewModelAsync(string logoutId)
{
// get context information (client name, post logout redirect URI and iframe for federated signout)
var logout = await _interaction.GetLogoutContextAsync(logoutId);
...
Run Code Online (Sandbox Code Playgroud)
这会创建一个IdentityServer4.Models.LogoutRequest.
该SignOutIFrameUrl字符串属性设置为"http://localhost:5000/connect/endsession/callback?sid=bf112f7785bc860fcc4351893012622e&logoutId=d6649e7f818d9709b2c0bc659696abdf",但没有别的似乎都在LogoutRequest被填充.
不幸的是,这意味着它PostLogoutRedirectUri是null并且AutomaticRedirectAfterSignOut也是null,并且当LoggedOut.cshtml加载页面时,signout-callback.js永远不会加载该文件:
@section scripts
{
@if (Model.AutomaticRedirectAfterSignOut)
{
<script src="~/js/signout-redirect.js"></script>
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的配置设置.
Config.cs:
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{ …Run Code Online (Sandbox Code Playgroud)