Merge pull request #2995 from stianst/KEYCLOAK-2617

KEYCLOAK-2617 Ignore postmessages if not initiated by keycloak.js
This commit is contained in:
Stian Thorgersen 2016-07-04 19:19:34 +02:00 committed by GitHub
commit dd6434a487

View file

@ -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 {
@ -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) {