ThunderDev1 / reactjs-ts-identityserver

Demo app for using Identity Server with React.js SPA, .Net Core 3.0 and TypeScript
MIT License
136 stars 31 forks source link

No post logout redirect ? #1

Open SebiNUI opened 6 years ago

SebiNUI commented 6 years ago

@ThunderDev1 I'm trying to use the post logout redirect within a similar SPA client... I noticed you didn't follow the same approach. My question is: did you manage to make post logout redirect work ?

ThunderDev1 commented 6 years ago

Unfortunately no, I didn't get it to work. I did research the issue and as you probably saw, other people seem to have problems making it work.. I'll try to look in to it again when I have the time

SebiNUI commented 6 years ago

@ThunderDev1 I did, by creating the following method in the account controller:

[HttpGet] [AllowAnonymous] public async Task Logout(string logoutId) { var logout = await _interaction.GetLogoutContextAsync(logoutId); await _signInManager.SignOutAsync(); _logger.LogInformation("User logged out."); return Redirect(logout.PostLogoutRedirectUri); }

floodi commented 5 years ago

I think id_token_hint should be used in logout-function(Spa - Nav.tsx): const logout = (event: any) => { event.preventDefault(); userManager.getUser() .then(user => { userManager.signoutRedirect({ 'id_token_hint': user.id_token }); }); userManager.removeUser(); };

ThunderDev1 commented 5 years ago

Yes, that seems to be it, according to http://docs.identityserver.io/en/latest/endpoints/endsession.html you also need to pass the post_logout_redirect_uri. For some reason identity server is not providing the id_token, not sure what is missing.