Signout for native client (uwp)
We have a UWP app that signs users in through ODIC (GrantType=Hybrid) with IdentityServer4 that is configured with local and AAD external provider. We're using WebAuthenticationClient and OidcClient for the sign in. With the latest update, WAB now added the ability to save the sign-in info which keeps the user signed in to AAD. Next time the app starts and the user logs in to AAD, that session is still there, so they just go straight through and that is something we don't want.
I have been looking at the signout docs http://docs.identityserver.io/en/release/topics/signout.html#sign-out-initiated-by-a-client-application and tried a bunch of suggestions from people that have been trying to do it in UWP.
One of those posts suggested a call like this
WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.SilentMode, new Uri(logout-url-here));
which I have tried with and without the SilentMode.
I have also tried to pass in the id_token_hint with the id_token. I can see in fiddler that the endsession endpoint turns that into logoutId value, but the user is still seen as unauthenticated (HttpContext.User?.Identity.IsAuthenticated), so the external logout never happens. This code pretty closely follows the IdentityServer UI for its signout project.
Are we missing something in the request to the endsession endpoint? What would have to be sent through in order for IdSrv to recognize the logged in user?
I personally would stay away from WAB and just launch the default browser.
Is that an option in UWP? From what I am reading, not yet. Perhaps that is what WAB will do eventually.
I did find that by sending a request directly to AAD, I can sign the user out of AAD - clear AAD cookies.
await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.SilentMode,
new Uri("https://login.windows.net/common/oauth2/logout?post_logout_redirect_uri=" +
Uri.EscapeDataString(WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString())),
WebAuthenticationBroker.GetCurrentApplicationCallbackUri()
I would still prefer going to IdSrv and have IdSrv send the request upstream. Looking at the samples, when IdSrv recognizes the logged in user in the LogOut process, it can detect the external provider information and put together the upstream request.
Any pointers as to what must be sent in the logout request (sent by WAB) that would have IdSrv recognize the logged in user? It is probably not id_token_hint, is it? Is it the aspnet identity cookie?
UPDATE: It is the cookie. I am now seeing that if I tell the signInManager to persist the cookie (persist: true), the cookie will be send along with the LogOut request. So what appears to be happening is that every time WAB launches a new browser window, the session cookies are gone. That cookie is needed though in a LogOut request to perform all its actions particularly when an external provider is involved.
This seems to indicate otherwise
https://github.com/googlesamples/oauth-apps-for-windows
That being said - we support standard OIDC logout (via the end_session endpoint) - not sure how WAB screws that up though ;)
Thanks for the link, good to know.
I made it work in WAB, both the cookie as well as the id_token_hint were needed against the end session endpoint.
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.