Add redirect_uri to access token request in keycloak.js

This commit is contained in:
Stian Thorgersen 2015-01-14 15:17:22 +01:00
parent b16845a09e
commit c3c6d4cbba

View file

@ -120,7 +120,7 @@
redirectUri += (redirectUri.indexOf('?') == -1 ? '?' : '&') + 'prompt=' + options.prompt;
}
sessionStorage.oauthState = state;
sessionStorage.oauthState = JSON.stringify({ state: state, redirectUri: encodeURIComponent(redirectUri) });
var url = getRealmUrl()
+ '/tokens/login'
@ -315,6 +315,8 @@
params += '&client_id=' + encodeURIComponent(kc.clientId);
}
params += '&redirect_uri=' + oauth.redirectUri;
req.withCredentials = true;
req.onreadystatechange = function() {
@ -538,9 +540,13 @@
}
}
if ((oauth.code || oauth.error) && oauth.state && oauth.state == sessionStorage.oauthState) {
var sessionState = sessionStorage.oauthState && JSON.parse(sessionStorage.oauthState);
if (sessionState && (oauth.code || oauth.error) && oauth.state && oauth.state == sessionState.state) {
delete sessionStorage.oauthState;
oauth.redirectUri = sessionState.redirectUri;
if (oauth.fragment) {
oauth.newUrl += '#' + oauth.fragment;
}