Closed Bug 1380313 Opened 7 years ago Closed 7 years ago

Webextension. webRequest.onAuthRequired with async return not fired for proxy.registerProxyScript with HTTPS return that requires authorization

Categories

(WebExtensions :: Request Handling, defect, P3)

54 Branch
defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: crownofdesign, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [proxy] triaged)

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36 Steps to reproduce: I am using new Proxy API with HTTPS servers ( like 'HTTPS server.com' ) return, that requires authorization. To handle authorization I am using webRequest.onAuthRequired with async return and blocking. Actual results: webRequest.onAuthRequired is not fired in this case Expected results: webRequest.onAuthRequired must be fired
Component: Untriaged → WebExtensions: Request Handling
Product: Firefox → Toolkit
Looks like a bug especially in current Firefox Developer Edition (55). In case of using about:config proxy settings - FF54 works normal. But in 55 with about:config proxy settings (no new Proxy API) webRequest.onAuthRequired is not fired
> webRequest.onAuthRequired is not fired in this case This works for me, both HTTP and HTTPS proxy servers. I am finishing a new example for https://github.com/mdn/webextensions-examples and will post it here.
>I am finishing a new example for https://github.com/mdn/webextensions-examples and will post it here. https://github.com/mdn/webextensions-examples/tree/a9e1d6a0a3e4be57972736e9d8c043b9c282d4a2/proxy-server >webRequest.onAuthRequired is not fired in this case Works for me with both HTTPS and HTTP proxy servers requiring Basic Auth. If the HTTPS cert is not signed, you must import it into Firefox, which can be challenging. Tested in Firefox 55 Developer Edition for @Rustam (I made a few adjustments to the sample) and Fx 56.0a1
I just noticed the bug title says "with async return". Can you please give an example of that?
browser.webRequest.onAuthRequired.addListener( details => new Promise( resolve => { /* add some delay for resolve */ } ) ) with 'blocking'
Realization of onAuthRequired for old firefox version (SDK add-on): const { Cc, Ci } = require( 'chrome' ); // Adding observer to put proxy data during login promt let observerService = Cc[ '@mozilla.org/observer-service;1' ] .getService( Ci.nsIObserverService ); observer = { 'observe': subject => { if( !loginSettings || !premiumServers ) return; let httpChannel = subject.QueryInterface( Ci.nsIHttpChannel ); if( !( httpChannel instanceof Ci.nsIProxiedChannel ) ) return; let proxiedChannel = httpChannel.QueryInterface( Ci.nsIProxiedChannel ); if( !proxiedChannel || !proxiedChannel.proxyInfo ) return; let { host, port } = proxiedChannel.proxyInfo; let { username, password } = loginSettings; /** @type {boolean} */ let ourServer = Boolean( premiumServers.find( item => item.host === host && item.port === port ) ); if( !ourServer ) return; httpChannel.setRequestHeader( 'Proxy-Authorization', 'Basic ' + btoa( username + ':' + password ), false ); } }; observerService.addObserver( observer, 'http-on-modify-request', false );
Priority: -- → P3
Whiteboard: triaged
Whiteboard: triaged → [proxy] triaged
@Shane, according to the bug comments, this is only an issue for use with proxy servers (HTTP 407 not 401). This bug may have to do with the fact that the proxy selection process (FindProxyForURL()) is synchronous. Once bug 1381290 is fixed, use of webRequest.onAuthRequired() won't be needed since username/password credentials can be returned from FindProxyForURL().
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
Tested again, commented all other browser.webRequest listeners -> still same. console.log inside listener of browser.webRequest.onAuthRequired is not outputed. With sync return all same. There is also this bugs in console (with sync return): 1500545343183 Toolkit.Telemetry ERROR TelemetrySend::_doPing - error making request to https://incoming.telemetry.mozilla.org/submit/telemetry/ce9f9eb2-37a2-4a7f-b4dc-cacea6e49bf9/modules/Firefox/55.0/aurora/20170717063821?v=4: eUnreachable Log.jsm:748 1500545343183 Toolkit.Telemetry ERROR TelemetrySend::sendPersistedPings - failed to send ping ce9f9eb2-37a2-4a7f-b4dc-cacea6e49bf9: {"isTrusted":true} Tested in current Firefox Developer Edition, as for 2017/07/20
All tests were in Embedded webextension. Not in pure webextension
Tested in pure webextension - problem still exist
This bug was closed because bug 1381290 changes where and how credentials are supplied by addons.
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.