Overview
his article explains how to logout a user out via an Open ID Connect (OIDC) logout but not redirect the user off the current page. The logout occurs in the browser and the redirection should not occur.
Applies To
- OIDC Logout
Solution
One option is to execute the logout in a hidden iframe on the page. This way, the logout takes effect, and the user stays on the current page.
Example () using the SPA SDK Quickstart
NOTE: This is an example and not a full solution. Please update to work with the necessary environment.
In Index.html, add towards the bottom:
<iframe id="launchHiddenIframe" data-src="https://<DOMAIN>/oidc/logout?client_id=CLIENTID&logout_hint=xNXPsTYg_BsAEn5iR1zQlZJUFAynor4b" src="about:blank" width="200" height="200" style="background:#ffffff"></iframe>
<script>
function launchHiddenIframe() {
var iframe = $("#launchHiddenIframe");
iframe.attr("src", iframe.data("src"));
}
</script>