Skip to content

Commit

Permalink
Task 6916: PPG-801 - Issues with relying party[CAS] session timeout a…
Browse files Browse the repository at this point in the history
…nd logout [existing issue on Production] - rootcause analysis
  • Loading branch information
brijrajsinh-bc committed Jan 9, 2024
1 parent 54f6ea8 commit 5a211dc
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/assets/rpIFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function onLoad() {

function check_session() {
let win = window.parent.document.getElementById("opIFrame").contentWindow;
let client_id = this.localStorage.getItem('client_id');
let client_id = decrypt('client_id');
let session_state = this.localStorage.getItem('session_state');
let mes = client_id + ' ' + session_state;
win.postMessage(mes, 'https://identify.crowncommercial.gov.uk/');
win.postMessage(mes, this.localStorage.getItem('securityapiurl'));
}

function setTimer() {
Expand All @@ -32,7 +32,7 @@ function noticeToParentWindow(stat) {
console.log('changed');
let secApiURl = this.localStorage.getItem('securityapiurl');
let redirect_uri = this.localStorage.getItem('redirect_uri') + '/authsuccess';
let client_id = this.localStorage.getItem('client_id');
let client_id = decrypt('client_id');
let secApi = secApiURl + '/security/authorize?client_id=' + client_id
+ '&redirect_uri=' + redirect_uri + '&response_type=code' +
'&scope=email profile openid offline_access&prompt=none';
Expand All @@ -41,4 +41,24 @@ function noticeToParentWindow(stat) {
} else {
console.log('not-changed');
}
}

function decrypt(key) {
const shift = 3;
var encryptedText = localStorage.getItem(key) || '';
var decryptedText = '';
for (var i = 0; i < encryptedText.length; i++) {
var charCode = encryptedText.charCodeAt(i);
if (charCode >= 65 && charCode <= 90) {
decryptedText += String.fromCharCode.apply(null,[((charCode - 65 - shift + 26) % 26) + 65]);
}
else if (charCode >= 97 && charCode <= 122) {
decryptedText += String.fromCharCode.apply(null,[((charCode - 97 - shift + 26) % 26) + 97]);
}
else {
decryptedText += encryptedText[i];
}
}

return decryptedText;
}

0 comments on commit 5a211dc

Please sign in to comment.