Skip to content

Commit

Permalink
KEYCLOAK-2617 Ignore postmessages if not initiated by keycloak.js
Browse files Browse the repository at this point in the history
  • Loading branch information
stianst committed Jul 4, 2016
1 parent 450b57c commit f3a780c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions adapters/oidc/js/src/main/resources/keycloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
storage = new PersistentStorage();

if (initOptions && initOptions.adapter === 'cordova') {
adapter = loadAdapter('cordova');
adapter = loadAdapter('cordova');
} else if (initOptions && initOptions.adapter === 'default') {
adapter = loadAdapter();
} else {
Expand Down Expand Up @@ -792,8 +792,22 @@
if (event.origin !== loginIframe.iframeOrigin) {
return;
}
var data = JSON.parse(event.data);

try {
var data = JSON.parse(event.data);
} catch (err) {
return;
}

if (!data.callbackId) {
return;
}

var promise = loginIframe.callbackMap[data.callbackId];
if (!promise) {
return;
}

delete loginIframe.callbackMap[data.callbackId];

if ((!kc.sessionId || kc.sessionId == data.session) && data.loggedIn) {
Expand Down

0 comments on commit f3a780c

Please sign in to comment.