chimney, bugfix, cleanup
This commit is contained in:
parent
9f923b5f65
commit
e25398f213
|
@ -19,7 +19,6 @@
|
||||||
}
|
}
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
opts.debug = true;
|
opts.debug = true;
|
||||||
console.log('discover providerUri', providerUri);
|
|
||||||
providerUri = OAUTH3_CORE.normalizeUrl(providerUri);
|
providerUri = OAUTH3_CORE.normalizeUrl(providerUri);
|
||||||
var discObj = OAUTH3_CORE.urls.discover(providerUri, { appUrl: (opts.appUrl || getDefaultAppUrl()), debug: opts.debug });
|
var discObj = OAUTH3_CORE.urls.discover(providerUri, { appUrl: (opts.appUrl || getDefaultAppUrl()), debug: opts.debug });
|
||||||
|
|
||||||
|
@ -74,7 +73,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
window['--oauth3-callback-' + state] = function (params) {
|
window['--oauth3-callback-' + state] = function (params) {
|
||||||
console.info('[iframe] complete', params);
|
|
||||||
resolve(params);
|
resolve(params);
|
||||||
cleanup();
|
cleanup();
|
||||||
};
|
};
|
||||||
|
@ -87,7 +85,7 @@
|
||||||
}, opts.timeout || 15000);
|
}, opts.timeout || 15000);
|
||||||
|
|
||||||
// TODO hidden / non-hidden (via directive even)
|
// TODO hidden / non-hidden (via directive even)
|
||||||
var framesrc = '<iframe src="' + url + '" ';
|
var framesrc = '<iframe class="js-oauth3-iframe" src="' + url + '" ';
|
||||||
if (opts.debug) {
|
if (opts.debug) {
|
||||||
framesrc += ' width="800px" height="800px" style="opacity: 0.8;" frameborder="1"';
|
framesrc += ' width="800px" height="800px" style="opacity: 0.8;" frameborder="1"';
|
||||||
}
|
}
|
||||||
|
@ -95,9 +93,8 @@
|
||||||
framesrc += ' width="1px" height="1px" frameborder="0"';
|
framesrc += ' width="1px" height="1px" frameborder="0"';
|
||||||
}
|
}
|
||||||
framesrc += '></iframe>';
|
framesrc += '></iframe>';
|
||||||
$iframe = $(framesrc);
|
|
||||||
|
|
||||||
$('body').append($iframe);
|
$('body').append(framesrc);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO periodically garbage collect expired handlers from window object
|
// TODO periodically garbage collect expired handlers from window object
|
||||||
|
@ -119,7 +116,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
window['--oauth3-callback-' + state] = function (params) {
|
window['--oauth3-callback-' + state] = function (params) {
|
||||||
//console.info('[popup] (or window) complete', params);
|
|
||||||
resolve(params);
|
resolve(params);
|
||||||
cleanup();
|
cleanup();
|
||||||
};
|
};
|
||||||
|
@ -160,8 +156,6 @@
|
||||||
, opts
|
, opts
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('[DEBUG] [core] authorizationRedirect URL:', prequest);
|
|
||||||
|
|
||||||
if (!prequest.state) {
|
if (!prequest.state) {
|
||||||
throw new Error("[Devolper Error] [authorization redirect] prequest.state is empty");
|
throw new Error("[Devolper Error] [authorization redirect] prequest.state is empty");
|
||||||
}
|
}
|
||||||
|
@ -178,8 +172,6 @@
|
||||||
, opts
|
, opts
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('[DEBUG] [core] implicitGrant URL', prequest);
|
|
||||||
|
|
||||||
if (!prequest.state) {
|
if (!prequest.state) {
|
||||||
throw new Error("[Devolper Error] [implicit grant] prequest.state is empty");
|
throw new Error("[Devolper Error] [implicit grant] prequest.state is empty");
|
||||||
}
|
}
|
||||||
|
@ -212,12 +204,6 @@
|
||||||
, state: prequest.state
|
, state: prequest.state
|
||||||
};
|
};
|
||||||
|
|
||||||
//console.log('DEBUG oauth3.logout NIX insertIframe');
|
|
||||||
//console.log(url, params.redirect_uri);
|
|
||||||
//console.log(state);
|
|
||||||
//console.log(params); // redirect_uri
|
|
||||||
//console.log(opts);
|
|
||||||
|
|
||||||
if (prequest.url === params.redirect_uri) {
|
if (prequest.url === params.redirect_uri) {
|
||||||
return OAUTH3.PromiseA.resolve();
|
return OAUTH3.PromiseA.resolve();
|
||||||
}
|
}
|
||||||
|
@ -251,7 +237,7 @@
|
||||||
// The client should have a list of allowed URLs to choose from and perhaps a wildcard will do
|
// The client should have a list of allowed URLs to choose from and perhaps a wildcard will do
|
||||||
//
|
//
|
||||||
// api.example.com.evil.com SHOULD NOT match example.com
|
// api.example.com.evil.com SHOULD NOT match example.com
|
||||||
return dst.hostname !== src.hostname;
|
return dst.hostname === src.hostname;
|
||||||
}
|
}
|
||||||
, checkRedirect: function (client, query) {
|
, checkRedirect: function (client, query) {
|
||||||
console.warn("[security] URL path checking not yet implemented");
|
console.warn("[security] URL path checking not yet implemented");
|
||||||
|
@ -343,12 +329,9 @@
|
||||||
};
|
};
|
||||||
preq.clientId = preq.appId = DaplieApiConfig.appId || DaplieApiConfig.clientId;
|
preq.clientId = preq.appId = DaplieApiConfig.appId || DaplieApiConfig.clientId;
|
||||||
preq.clientUri = preq.appUri = DaplieApiConfig.appUri || DaplieApiConfig.clientUri;
|
preq.clientUri = preq.appUri = DaplieApiConfig.appUri || DaplieApiConfig.clientUri;
|
||||||
console.log('hackFormSubmit preq', preq);
|
|
||||||
// TODO need a way to have middleware in Oauth3.request for TherapySession et al
|
// TODO need a way to have middleware in Oauth3.request for TherapySession et al
|
||||||
return Oauth3.request(preq).then(function (resp) {
|
|
||||||
console.log('[DEBUG] grant code');
|
|
||||||
console.log(resp);
|
|
||||||
|
|
||||||
|
return Oauth3.request(preq).then(function (resp) {
|
||||||
var err;
|
var err;
|
||||||
var data = resp.data || {};
|
var data = resp.data || {};
|
||||||
|
|
||||||
|
|
13
oauth3.js
13
oauth3.js
|
@ -75,7 +75,10 @@
|
||||||
|
|
||||||
oauth3.hooks._stalePromise = oauth3.requests.refreshToken(
|
oauth3.hooks._stalePromise = oauth3.requests.refreshToken(
|
||||||
staleSession.provider_uri
|
staleSession.provider_uri
|
||||||
, staleSession
|
, { client_uri: staleSession.client_uri
|
||||||
|
, session: staleSession
|
||||||
|
, debug: staleSession.debug
|
||||||
|
}
|
||||||
).then(function (newSession) {
|
).then(function (newSession) {
|
||||||
oauth3.hooks._stalePromise = null;
|
oauth3.hooks._stalePromise = null;
|
||||||
return newSession; // oauth3.hooks.refreshSession(staleSession, newSession);
|
return newSession; // oauth3.hooks.refreshSession(staleSession, newSession);
|
||||||
|
@ -87,7 +90,13 @@
|
||||||
}
|
}
|
||||||
, sessionExpired: function (expiredSession) {
|
, sessionExpired: function (expiredSession) {
|
||||||
console.info('[oauth3.hooks.sessionExpired] called');
|
console.info('[oauth3.hooks.sessionExpired] called');
|
||||||
return oauth3.requests.refreshToken(expiredSession.provider_uri, expiredSession).then(function (newSession) {
|
return oauth3.requests.refreshToken(
|
||||||
|
expiredSession.provider_uri
|
||||||
|
, { client_uri: expiredSession.client_uri
|
||||||
|
, session: expiredSession
|
||||||
|
, debug: expiredSession.debug
|
||||||
|
}
|
||||||
|
).then(function (newSession) {
|
||||||
return newSession; // oauth3.hooks.refreshSession(expiredSession, newSession);
|
return newSession; // oauth3.hooks.refreshSession(expiredSession, newSession);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue