identityserver doesn't display post logout link
- [x] I read and understood how to enable logging
Issue / Steps to reproduce the problem
I'm using identityserver4 with angular 5 application and oidc-client 1.4.1. I'm running angular application using angular cli's ng serve (localhost:4200). And I have problems with logging out.
After successful logon I'm trying to logout and getting in browser's console something like this:
XHR failed loading: GET "http://localhost:5000/.well-known/openid-configuration"
In network log at the same time I see this request with status canceled.
Some time (~1 min) later logout finally redirects to identityserver.
But after logging of page does not display the return link because LogoutRequest.PostLogoutRedirectUri is null in AccountService.BuildLoggedOutViewModelAsync.
How to fix the problems?
IS4 Client info:
new Client
{
ClientId = "Angular2",
ClientName = "Angular2 Client",
ClientUri = "http://identityserver.io",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris =
{
"http://localhost:4200/auth-callback",
"http://localhost:4200/auth-silent-callback",
"http://localhost:4200/logout-callback",
"http://localhost:4200/",
},
PostLogoutRedirectUris = { "http://localhost:4200/logout-callback" },
AllowedCorsOrigins = { "http://localhost:4200" },
AllowedScopes = { "openid", "profile", "api1" },
}
oidc-client initialization:
//config from environment.ts
{
authority: "http://localhost:5000",
clientId: "Angular2",
redirectUri: "http://localhost:4200/auth-callback",
responseType: "id_token token",
scope: "openid profile api1",
postLogoutRedirectUri: "http://localhost:4200/logout-callback",
monitorSession: true,
checkSessionInterval: 30000,
revokeAccessTokenOnSignout: true,
clockSkew: 300,
loadUserInfo: true
}
//UserManager settings initialization where oc is above object
const umSettings: UserManagerSettings = {
authority: oc.authority,
client_id: oc.clientId,
redirect_uri: oc.redirectUri,
response_type: oc.responseType,
scope: oc.scope,
post_logout_redirect_uri: oc.postLogoutRedirectUri,
monitorSession: oc.monitorSession,
checkSessionInterval: oc.checkSessionInterval,
revokeAccessTokenOnSignout: oc.revokeAccessTokenOnSignout,
clockSkew: oc.clockSkew,
loadUserInfo: oc.loadUserInfo
};
Relevant parts of the log file
2017-12-13 00:02:12.969 +03:00 [INF] End session request validation success
{
"SubjectId": "818727",
"Raw": {
"post_logout_redirect_uri": "http://localhost:4200/logout-callback"
}
}
I don't see the id_token_hint in the request to end session. This would explain why there's no link to go back to post_logout_redirect_uri.
Looks like that token is removed from sessionStorage at some moment. Let me describe the details...
userManager is used only inside my AuthService. Application starts logging in with
this.tokenStorage.removeUser();
this.userManager.signinRedirect()
after successful login callback it calls
this.userManager.signinRedirectCallback()
.then(user => {
this.tokenStorage.saveUser(user);
this.setIsLogged();
});
tokenStorage here is a wrapper for sessionStorage.
this.setIslogged() uses eventEmitter.emit() to raise an event for component (emitter is defined in AuthService).
For logging out application uses:
this.userManager.signoutRedirect();
One more thing: when I click logout for the first time I don't see any network call to my identityserver. But I see the following records in console:
10:48:03.737 user removed from storage
10:48:03.748 signoutRedirect successful
10:48:04.116 Navigated to http://localhost:4200/
After this I don't see item oidc.user:http://localhost:5000/Angular2 in sessionStorage. I see only my custom item with the same token.
What can I check?
this.tokenStorage.saveUser(user);
This is unnecessary, as the user is stored for you, and that might be why it loses the id_token? Not sure.
This code stores the user with using another (not oidc.user:http://localhost:5000/Angular2) key. I see 2 tokens in session storage (before I click logout).
Again, not sure. You will have to debug why the id_token_hint is not peing passed, or not being stored.
Closing this issue. New issue is created in oidc-client project: https://github.com/IdentityModel/oidc-client-js/issues/471
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.