mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +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
|
||||
const qs = querystring.buildFromParams(params);
|
||||
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);
|
||||
|
||||
console.log('[oauth2] Detected redirect ' + redirectedTo);
|
||||
|
||||
const {query} = urlParse(redirectedTo);
|
||||
return responseToObject(query, [
|
||||
c.P_CODE,
|
||||
|
@ -53,8 +53,11 @@ export function authorizeUserInWindow (url, urlRegex = /.*/) {
|
||||
child.webContents.on('did-navigate', () => {
|
||||
const url = child.webContents.getURL();
|
||||
if (url.match(urlRegex)) {
|
||||
console.log(`[oauth2] Matched redirect to "${url}" with ${urlRegex.toString()}`);
|
||||
finalUrl = url;
|
||||
child.close();
|
||||
} else {
|
||||
console.log(`[oauth2] Ignoring redirect to "${url}" with match ${urlRegex.toString()}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user