Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Extension with proxy, onAuthRequired never being triggered

I try to make a proxy in the Chrome extension, proxy is working connecting and all is good. But I need to manually enter auth credentials for proxy connection.

I'm trying to use webRequest and webRequestAuthProvider to automatically apply proxy auth credentials when it is required

let authListener = function(details, callbackFn) {
    console.log('Auth required for', details.url);
    callbackFn({
        authCredentials: {
            username: 'username',
            password: 'pass',
        }
    });
}

chrome.webRequest.onAuthRequired.addListener(
    authListener,
    { urls: ["<all_urls>"] }
    ['asyncBlocking']
);

When proxy auth block popups in the browser, chrome.webRequest.onAuthRequired never being triggered, but, for example, chrome.webRequest.onBeforeRequest or chrome.webRequest.onCompleted are triggered correctly

"permissions": ["storage", "alarms", "tabs", "proxy", "webRequest", "webRequestAuthProvider"],
export function proxyConnect(proxy, scheme = 'http') {
    chrome.proxy.settings.set(
        {
            value: {
                mode: "fixed_servers",
                rules: {
                    singleProxy: {
                        scheme,
                        host: proxy.host,
                        port: proxy.port
                    },
                    bypassList: ['https://2ip.io'] // "<all_urls>"
                }
            },
            scope: 'regular'
        },
    );
}
like image 417
yur0n Avatar asked Jan 26 '26 21:01

yur0n


1 Answers

Starting from Chrome 79 if you need to deceive the CORS protocol, you also need to specify extraHeaders for the response modifications.

"permissions": [
    "storage", 
    "alarms", 
    "tabs", 
    "proxy", 
    "webRequest", 
    "webRequestAuthProvider", 
    "extraHeaders"
]

Please refer this doc for more information

like image 136
Shehan Lakshitha Avatar answered Jan 28 '26 10:01

Shehan Lakshitha