Skip to content

armgit / core

Public Imported from GitHub
0

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

Disable access token check when or-app is in error state

Christian Bauere8dbb3d88527
diff --git a/client/src/main/webapp/src/or-app/or-app-security.html b/client/src/main/webapp/src/or-app/or-app-security.html
index b1ab1b224..6f9b1cca5 100644
--- a/client/src/main/webapp/src/or-app/or-app-security.html
+++ b/client/src/main/webapp/src/or-app/or-app-security.html
@@ -174,6 +174,12 @@
};
}
+ static get observers() {
+ return [
+ "onLoginChange(login)"
+ ]
+ }
+
ready() {
super.ready();
@@ -208,6 +214,13 @@
}
}
+ onLoginChange(login) {
+ // If login is no longer required and Keycloak is available, stop checking access token
+ if (!login && this.keycloak) {
+ this.stopKeycloakAccessTokenCheck();
+ }
+ }
+
/**
* Called either manually by the user or when auth token refresh fails (refresh token invalid).
*/
@@ -226,11 +239,7 @@
let logoutUrl = location.protocol + "//" + location.host + location.pathname;
if (this.keycloak) {
- // Clear refresh token check interval
- if (this.keycloakUpdateTokenInterval) {
- clearInterval(this.keycloakUpdateTokenInterval);
- delete this.keycloakUpdateTokenInterval;
- }
+ this.stopKeycloakAccessTokenCheck();
// Navigate to start page on logout, drop the hash (also, Keycloak has a bug where it
// puts the hash into redirect_uri instead of redirect_fragment and then denies that
@@ -410,9 +419,7 @@
this.set("authenticated", true);
// Check every 10 seconds if the refresh token can still get an access token
- if (this.keycloakUpdateTokenInterval) {
- clearInterval(this.keycloakUpdateTokenInterval);
- }
+ this.stopKeycloakAccessTokenCheck();
this.keycloakUpdateTokenInterval = setInterval(() => {
this.updateKeycloakAccessToken()
}, 10000);
@@ -447,6 +454,14 @@
});
}
+ stopKeycloakAccessTokenCheck() {
+ // Clear refresh token check interval
+ if (this.keycloakUpdateTokenInterval) {
+ clearInterval(this.keycloakUpdateTokenInterval);
+ delete this.keycloakUpdateTokenInterval;
+ }
+ }
+
getNativeOfflineRefreshToken() {
if (this.shellNative && this.shellNative.enabled) {
let storedToken = this.shellNative.readNativeShellMessage('token');