#StackBounty: #javascript #google-chrome-extension #proxy Changing credentials to a proxy server on fly

Bounty: 50

I’m developing an extension for chrome. The extension allow to pick any proxy server from a list each proxy is required authorization. There is an issue when a user would like to connect to the same proxy server twice but with different credentials for example if a user was successfully logged it in the first time the chome remebers it and when the user whould try to connect with another credentails the chrome whould use credentilas that was inputed in the first login.

var authCredentials = {
  username: 'Jack',
  password: 'PassForJack'
}

var auth = function () {
    return {
       authCredentials
    };
};


chrome.webRequest.onAuthRequired.addListener(auth, {
   urls: ["<all_urls>"]
 }, ["blocking"]);

// set a new proxy server for the first login
chrome.proxy.settings.set({
  value: {
      mode: 'fixed_servers',
      rules: {
        singleProxy: {
            host: 'some-proxy-server.com',
            port: 8000
        }
    }
  },
  scope: 'regular'
});


// change credentails 
authCredentials = {
  username: 'Bob',
  password: 'PassForBob'
};

// remove proxy configuration
chrome.proxy.settings.set({
  value: {
    mode: 'direct'
  },
  scope: 'regular'
});

// remove onAuthListener
chrome.webRequest.onAuthRequired.removeListener(auth)
chrome.webRequest.onAuthRequired.hasListener(auth) // returns false

chrome.webRequest.onAuthRequired.addListener(auth, {
   urls: ["<all_urls>"]
 }, ["blocking"]);

// lets re connect 
chrome.proxy.settings.set({
  value: {
    mode: 'fixed_servers',
    rules: {
        singleProxy: {
            host: 'some-proxy-server.com',
            port: 8000
        }
    }
  },
  scope: 'regular'
});

// that doesn't help the user would be loged as "Jack" but has to be as "Bob"


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.