mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
Added some OAuth 2.0 logging
This commit is contained in:
parent
68cda7187b
commit
6ee6422e94
@ -57,10 +57,12 @@ async function _authorize (url, clientId, redirectUri = '', scope = '', state =
|
|||||||
// Add query params to URL
|
// Add query params to URL
|
||||||
const qs = querystring.buildFromParams(params);
|
const qs = querystring.buildFromParams(params);
|
||||||
const finalUrl = querystring.joinUrl(url, qs);
|
const finalUrl = querystring.joinUrl(url, qs);
|
||||||
const regex = new RegExp(`${escapeRegex(redirectUri)}.*(code=|error=)`);
|
const regex = new RegExp(`${escapeRegex(redirectUri)}.*(code=|error=)`, 'i');
|
||||||
|
|
||||||
const redirectedTo = await authorizeUserInWindow(finalUrl, regex);
|
const redirectedTo = await authorizeUserInWindow(finalUrl, regex);
|
||||||
|
|
||||||
|
console.log('[oauth2] Detected redirect ' + redirectedTo);
|
||||||
|
|
||||||
const {query} = urlParse(redirectedTo);
|
const {query} = urlParse(redirectedTo);
|
||||||
return responseToObject(query, [
|
return responseToObject(query, [
|
||||||
c.P_CODE,
|
c.P_CODE,
|
||||||
|
@ -53,8 +53,11 @@ export function authorizeUserInWindow (url, urlRegex = /.*/) {
|
|||||||
child.webContents.on('did-navigate', () => {
|
child.webContents.on('did-navigate', () => {
|
||||||
const url = child.webContents.getURL();
|
const url = child.webContents.getURL();
|
||||||
if (url.match(urlRegex)) {
|
if (url.match(urlRegex)) {
|
||||||
|
console.log(`[oauth2] Matched redirect to "${url}" with ${urlRegex.toString()}`);
|
||||||
finalUrl = url;
|
finalUrl = url;
|
||||||
child.close();
|
child.close();
|
||||||
|
} else {
|
||||||
|
console.log(`[oauth2] Ignoring redirect to "${url}" with match ${urlRegex.toString()}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user