Skip to content

Commit

Permalink
fix: access_token purge (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
rentallect authored Nov 18, 2023
1 parent fc0ce27 commit db0a655
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"cookie-interceptor": "^1.0.0",
"core-js": "^3.22.8",
"js-base64": "^3.7.2",
"jwt-decode": "^3.1.2",
"localforage": "^1.10.0",
"lodash-es": "^4.17.21",
"uplot": "^1.6.24",
Expand Down
20 changes: 20 additions & 0 deletions src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import Bowser from 'bowser';
import uPlot from 'uplot';
import * as msal from '@azure/msal-browser';
import { stringify } from './urlon';
import jwt_decode from 'jwt-decode';


/**
Expand Down Expand Up @@ -837,6 +838,13 @@ class ZitiBrowzerRuntime {

window.zitiBrowzerRuntime.authClient_doLogout();

setTimeout(function() {
window.zitiBrowzerRuntime.wb.messageSW({
type: 'UNREGISTER',
payload: {
}
});
}, 50);
}

idpAuthHealthEventHandler(idpAuthHealthEvent) {
Expand Down Expand Up @@ -1452,6 +1460,18 @@ class ZitiBrowzerRuntime {

this.logger.trace(`isAuthenticated: ${this.isAuthenticated}`);

this.zitiConfig.access_token = this.getCookie( this.authTokenName );
if (!isEqual(this.zitiConfig.access_token, '')) {
let decoded_access_token = jwt_decode(this.zitiConfig.access_token);
let exp = decoded_access_token.exp;
if (Date.now() >= exp * 1000) {
this.logger.trace(`${this.authTokenName} has expired`);
this.isAuthenticated = false;
}
} else {
this.isAuthenticated = false;
}

if (!this.isAuthenticated) {

const query = window.location.search;
Expand Down

0 comments on commit db0a655

Please sign in to comment.