<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-AU" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I&#8217;ve noticed some issues when testing single logout with the spring security adapter.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">I setup the admin url for the test application that used the spring security adapter in keycloak and tested logging out from keycloak and it didn&#8217;t invalidate the session.&nbsp; This is consistent with what I saw in other environments while
 testing.&nbsp; I did some digging and found that the spring adapter isn&#8217;t working correctly for single log out in my environments.&nbsp; We&#8217;re not using spring boot so not sure if that might be a reason why its not working out of the box.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The issue is with the org.keycloak.adapters.springsecurity.management.HtttpSessionManager class.&nbsp; This implements javax.servlet.http.HttpSessionListener to receive events when sessions are created and stores the sessions in a hash map.&nbsp;
 When you do a logout from keycloak, it sends a POST request to &lt;admin_url&gt;/k_logout.&nbsp; This results in a call to the HttpSessionManager.logoutHttpSessions method with the session id passed in as an argument.&nbsp; This method attempts to lookup the session in the
 hashmap and call the invalidate() method.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The problem is by default the HttpSessionManager class isn&#8217;t receiving the session create events.&nbsp; You need to configure it as a listener in web.xml to enable that.&nbsp; But even if you do that it still doesn&#8217;t work because the servlet container
 will create a instance of the class, but spring will also create another instance when creating the keycloak beans and this new instance is the one passed into the KeycloakPreAuthActionsFilter constructor.&nbsp; So the instance that is created by the servlet container
 is the one receiving the session create event and the one used by spring isn&#8217;t receiving any events but is the one used to do the logoutHttpSessions() call.&nbsp; The spring instance has no sessions in the hashmap, so logoutHttpSessions() does nothing.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The fix is to make a new version of HttpSessionManager that implements org.keycloak.adapters.spi.UserSessionManagement
<i>and</i> org.springframework.context.ApplicationListener&lt;ApplicationEvent&gt;, which is a spring interface that receives session create/destroy events.&nbsp; In web.xml you need to register org.springframework.security.web.session.HttpSessionEventPublisher as a listener
 so spring will receive those events from the servlet container.&nbsp; Then in the spring config, you need the KeycloakPreAuthActionsFilter to be initialized with the new HttpSessionManager instead of the default one.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The HttpSessionManager class that works for me is below&#8230;<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<table class="MsoTableGrid" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border:none">
<tbody>
<tr>
<td width="638" valign="top" style="width:478.8pt;border:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">package</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> my.keycloak;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> java.util.List;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> javax.servlet.http.HttpSession;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> org.keycloak.adapters.spi.UserSessionManagement;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> org.keycloak.adapters.springsecurity.management.LocalSessionManagementStrategy;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> org.keycloak.adapters.springsecurity.management.SessionManagementStrategy;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> org.slf4j.Logger;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> org.slf4j.LoggerFactory;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> org.springframework.context.ApplicationEvent;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> org.springframework.context.ApplicationListener;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> org.springframework.security.web.session.HttpSessionCreatedEvent;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">import</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> org.springframework.security.web.session.HttpSessionDestroyedEvent;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">public</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> HttpSessionManager
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">implements</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> UserSessionManagement, ApplicationListener&lt;ApplicationEvent&gt; {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">private</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">static</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">final</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> Logger
</span><b><i><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">log</span></i></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> = LoggerFactory.<i>getLogger</i>(HttpSessionManager.</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">);</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">private</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> SessionManagementStrategy
</span><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">sessions</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> =
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> LocalSessionManagementStrategy();</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#646464">@<span style="background:silver;mso-highlight:silver">Override</span></span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">public</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">void</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> logoutAll() {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><i><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">log</span></i></b><span style="font-size:8.0pt;font-family:Consolas;color:black">.info(</span><span style="font-size:8.0pt;font-family:Consolas;color:#2A00FF">&quot;Received request to
 log out all users.&quot;</span><span style="font-size:8.0pt;font-family:Consolas;color:black">);</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">for</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> (HttpSession
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> :
</span><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">sessions</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.getAll()) {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.invalidate();</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">sessions</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.clear();</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#646464">@<span style="background:silver;mso-highlight:silver">Override</span></span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">public</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">void</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> logoutHttpSessions(List&lt;String&gt;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">ids</span><span style="font-size:8.0pt;font-family:Consolas;color:black">) {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><i><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">log</span></i></b><span style="font-size:8.0pt;font-family:Consolas;color:black">.info(</span><span style="font-size:8.0pt;font-family:Consolas;color:#2A00FF">&quot;Received request to
 log out {} session(s): {}&quot;</span><span style="font-size:8.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">ids</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.size(),
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">ids</span><span style="font-size:8.0pt;font-family:Consolas;color:black">);</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">for</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> (String
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">id</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> :
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">ids</span><span style="font-size:8.0pt;font-family:Consolas;color:black">) {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpSession
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">sessions</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.remove(</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">id</span><span style="font-size:8.0pt;font-family:Consolas;color:black">);</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">if</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> (</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black">
 != </span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">null</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">) {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.invalidate();</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">sessions</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.clear();</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#646464">@<span style="background:silver;mso-highlight:silver">Override</span></span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">public</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">void</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> onApplicationEvent(ApplicationEvent
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">event</span><span style="font-size:8.0pt;font-family:Consolas;color:black">) {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">if</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> (</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">event</span><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">instanceof</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> HttpSessionCreatedEvent) {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpSessionCreatedEvent
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">e</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> = (HttpSessionCreatedEvent)</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">event</span><span style="font-size:8.0pt;font-family:Consolas;color:black">;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpSession
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">e</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.getSession();</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><i><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">log</span></i></b><span style="font-size:8.0pt;font-family:Consolas;color:black">.debug(</span><span style="font-size:8.0pt;font-family:Consolas;color:#2A00FF">&quot;Session created: {}&quot;</span><span style="font-size:8.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.getId());</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">sessions</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.store(</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black">);</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">else</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">if</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> (</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">event</span><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">instanceof</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> HttpSessionDestroyedEvent) {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpSessionDestroyedEvent
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">e</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> = (HttpSessionDestroyedEvent)</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">event</span><span style="font-size:8.0pt;font-family:Consolas;color:black">;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpSession
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">e</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.getSession();</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">sessions</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.remove(</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.getId());</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><i><span style="font-size:8.0pt;font-family:Consolas;color:#0000C0">log</span></i></b><span style="font-size:8.0pt;font-family:Consolas;color:black">.debug(</span><span style="font-size:8.0pt;font-family:Consolas;color:#2A00FF">&quot;Session destroyed:
 {}&quot;</span><span style="font-size:8.0pt;font-family:Consolas;color:black">, </span>
<span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">session</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.getId());</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">}</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt"><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The keycloak config changes are below&#8230;<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<table class="MsoTableGrid" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border:none">
<tbody>
<tr>
<td width="638" valign="top" style="width:478.8pt;border:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:#646464">@Configuration</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:#646464">@EnableWebSecurity</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:#646464">@ComponentScan</span><span style="font-size:8.0pt;font-family:Consolas;color:black">(basePackageClasses = KeycloakSecurityComponents.</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">)</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">public</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> WebSecurityConfig
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">extends</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> KeycloakWebSecurityConfigurerAdapter {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#646464">@Autowired</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">&nbsp;&nbsp;&nbsp; public</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">void</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> configureGlobal(AuthenticationManagerBuilder
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">auth</span><span style="font-size:8.0pt;font-family:Consolas;color:black">)
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">throws</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> Exception {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">auth</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.authenticationProvider(keycloakAuthenticationProvider());</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:#646464">&nbsp;&nbsp;&nbsp; @Override</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">&nbsp;&nbsp;&nbsp; protected</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> SessionAuthenticationStrategy sessionAuthenticationStrategy()
 {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">return</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> RegisterSessionAuthenticationStrategy(</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
 SessionRegistryImpl());</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:#646464">&nbsp;&nbsp;&nbsp; @Bean</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">protected</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> KeycloakPreAuthActionsFilter keycloakPreAuthActionsFilter() {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">return</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> KeycloakPreAuthActionsFilter(<span style="background:silver;mso-highlight:silver">springHttpSessionManager</span>());</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:#646464">&nbsp;&nbsp;&nbsp; @Bean</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">protected</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> my.keycloak.HttpSessionManager
<span style="background:silver;mso-highlight:silver">springHttpSessionManager</span>() {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">return</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> my.keycloak.HttpSessionManager();</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#646464">@Override</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">&nbsp;&nbsp;&nbsp; protected</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">void</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> configure(HttpSecurity
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">http</span><span style="font-size:8.0pt;font-family:Consolas;color:black">)
</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">throws</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black"> Exception {</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">.configure(</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">http</span><span style="font-size:8.0pt;font-family:Consolas;color:black">);</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">http</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .logout()</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .logoutRequestMatcher(</span><b><span style="font-size:8.0pt;font-family:Consolas;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:Consolas;color:black">
 AntPathRequestMatcher(</span><span style="font-size:8.0pt;font-family:Consolas;color:#2A00FF">&quot;/sso/logout&quot;</span><span style="font-size:8.0pt;font-family:Consolas;color:black">))</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .and()</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .authorizeRequests()</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .antMatchers(</span><span style="font-size:8.0pt;font-family:Consolas;color:#2A00FF">&quot;/user*&quot;</span><span style="font-size:8.0pt;font-family:Consolas;color:black">).authenticated()</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .anyRequest().permitAll();</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp; }</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas;color:black">}</span><span style="font-size:8.0pt"><o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">and web.xml needs this added to it&#8230;<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<table class="MsoTableGrid" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border:none">
<tbody>
<tr>
<td width="638" valign="top" style="width:478.8pt;border:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:teal">&lt;</span><span style="font-size:8.0pt;font-family:Consolas;color:#3F7F7F">listener</span><span style="font-size:8.0pt;font-family:Consolas;color:teal">&gt;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:teal">&lt;</span><span style="font-size:8.0pt;font-family:Consolas;color:#3F7F7F">listener-class</span><span style="font-size:8.0pt;font-family:Consolas;color:teal">&gt;</span><span style="font-size:8.0pt;font-family:Consolas;color:black">org.springframework.security.web.session.HttpSessionEventPublisher</span><span style="font-size:8.0pt;font-family:Consolas;color:teal">&lt;/</span><span style="font-size:8.0pt;font-family:Consolas;color:#3F7F7F">listener-class</span><span style="font-size:8.0pt;font-family:Consolas;color:teal">&gt;</span><span style="font-size:8.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:teal">&lt;/</span><span style="font-size:8.0pt;font-family:Consolas;color:#3F7F7F">listener</span><span style="font-size:8.0pt;font-family:Consolas;color:teal">&gt;</span><span style="font-size:8.0pt"><o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">After making the above changes, log out from the keycloak admin console works as expected.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Anthony Fryer<span style="mso-fareast-language:EN-AU"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
The content of this e-mail, including any attachments, is a confidential communication between Virgin Australia Airlines Pty Ltd (Virgin Australia) or its related entities (or the sender if this email is a private communication) and the intended addressee and
 is for the sole use of that intended addressee. If you are not the intended addressee, any use, interference with, disclosure or copying of this material is unauthorized and prohibited. If you have received this e-mail in error please contact the sender immediately
 and then delete the message and any attachment(s). There is no warranty that this email is error, virus or defect free. This email is also subject to copyright. No part of it should be reproduced, adapted or communicated without the written consent of the
 copyright owner. If this is a private communication it does not represent the views of Virgin Australia or its related entities. Please be aware that the contents of any emails sent to or from Virgin Australia or its related entities may be periodically monitored
 and reviewed. Virgin Australia and its related entities respect your privacy. Our privacy policy can be accessed from our website: www.virginaustralia.com
</body>
</html>