Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Break out of Keycloak account iframe if session times out

Christian Bauerfe70ecffb231
diff --git a/keycloak/theme/account/template.ftl b/keycloak/theme/account/template.ftl
index 53741219d..addd1ad8c 100644
--- a/keycloak/theme/account/template.ftl
+++ b/keycloak/theme/account/template.ftl
@@ -36,8 +36,8 @@
<div class="flex layout horizontal center-start">
<div class="or-SidebarContent theme-SidebarContent">
<ul class="or-UnorderedList theme-UnorderedList">
- <li class="or-Hyperlink theme-Hyperlink <#if active=='account'>active</#if>"><a href="${url.accountUrl}">${msg("account")}</a></li>
- <#if features.passwordUpdateSupported><li class="or-Hyperlink theme-Hyperlink <#if active=='password'>active</#if>"><a href="${url.passwordUrl}">${msg("password")}</a></li></#if>
+ <li><div class="or-Hyperlink theme-Hyperlink <#if active=='account'>active</#if>"><a href="${url.accountUrl}">${msg("account")}</a></div></li>
+ <#if features.passwordUpdateSupported><li><div class="or-Hyperlink theme-Hyperlink <#if active=='password'>active</#if>"><a href="${url.passwordUrl}">${msg("password")}</a></div></li></#if>
</ul>
</div>
<div class="or-MainContent theme-MainContent">
diff --git a/manager/src/main/java/org/openremote/manager/client/user/UserAccountViewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/user/UserAccountViewImpl.ui.xml
index 22a504ab8..645c6730b 100644
--- a/manager/src/main/java/org/openremote/manager/client/user/UserAccountViewImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/user/UserAccountViewImpl.ui.xml
@@ -8,7 +8,8 @@
<g:HTMLPanel styleName="flex layout vertical">
<iframe ui:field="frame"
class="flex"
- style="width:100%; height:100%;border:0;"/>
+ style="width:100%; height:100%;border:0;"
+ onLoad="checkLogoutRedirect(this.contentWindow.location.pathname)"/>
</g:HTMLPanel>
</ui:UiBinder>
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml
index d905a1356..0f2f88d3b 100644
--- a/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml
@@ -21,6 +21,9 @@
.header {
font-weight: 700;
padding: 0.4em;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
.content {
diff --git a/manager/src/main/webapp/css/style.html b/manager/src/main/webapp/css/style.html
index d2a035366..7ab49752d 100644
--- a/manager/src/main/webapp/css/style.html
+++ b/manager/src/main/webapp/css/style.html
@@ -73,6 +73,10 @@
filter: inherit;
}
+ .or-Hyperlink {
+ display: inline-block;
+ }
+
.or-Hyperlink a,
.or-Hyperlink a:visited {
cursor: pointer;
@@ -104,6 +108,7 @@
list-style: square inside none;
margin: 0;
padding: 0;
+ white-space: nowrap;
}
.or-MessagesIcon {
diff --git a/manager/src/main/webapp/js/loader.js b/manager/src/main/webapp/js/loader.js
index 27edd2b5d..8aa38cd34 100644
--- a/manager/src/main/webapp/js/loader.js
+++ b/manager/src/main/webapp/js/loader.js
@@ -39,4 +39,14 @@ window.load = (function () {
js: _load("script"),
img: _load("img")
}
-})();
\ No newline at end of file
+})();
+
+window.checkLogoutRedirect = function(pathname) {
+ // We listen to onLoad event of iframes in parent window: If the iframe is loading
+ // the /auth path (this is how we detect a redirect after session timeout), we logout
+ // the parent window and go to the start page of the realm
+ if (pathname.endsWith('/auth')) {
+ var options = {redirectUri: "/" + keycloak.realm};
+ keycloak.logout(options);
+ }
+};
\ No newline at end of file