-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use electron-proxy-agent #878
Conversation
4d9918e
to
3b4f424
Compare
3b4f424
to
9bda66a
Compare
9bda66a
to
f4c3404
Compare
Codecov Report
@@ Coverage Diff @@
## master #878 +/- ##
==========================================
- Coverage 67.62% 67.28% -0.34%
==========================================
Files 33 33
Lines 2094 2094
==========================================
- Hits 1416 1409 -7
- Misses 678 685 +7
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Kudos for making this work so fast!
'Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication.') | ||
.describe('login-by-realm', 'comma-separated list of realm:user:password') | ||
.help('help') | ||
.parse() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move to main later?
gui/src/main/proxy.js
Outdated
|
||
log.warn({config}, 'argv') | ||
|
||
const printCertificate = (certif) => `Certificate(${certif.issuerName} ${certif.subjectName})` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't really print anything.. format*
? stringify
?
gui/src/main/proxy.js
Outdated
.help('help') | ||
.parse() | ||
|
||
log.warn({config}, 'argv') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.debug
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(not repeating, there are a few others below)
const https = require('https') | ||
|
||
const log = require('cozy-desktop').default.logger({ | ||
component: 'GUI:proxy' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes me think that CLI won't have proxy support. Not a priority though. We'll just need to make it clear in case we bring it back.
component: 'GUI:proxy' | ||
}) | ||
|
||
const config = require('yargs') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not reuse commander
since it was already used in CLI? Is it obsolete in some way? But same a CLI-related comment above: not a priority (just out of curiosity).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was in the CLI package and I am scared of the dark voodoo between cli & gui if they use the same package 😃
gui/src/main/proxy.js
Outdated
|
||
const printCertificate = (certif) => `Certificate(${certif.issuerName} ${certif.subjectName})` | ||
|
||
module.exports = (app, session, doneSetup) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really export anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, this cant be initialized until app.on('ready')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, we are exporting a function... Sorry, my bad :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(My brain was messing up with requirejs-like syntax...)
session.defaultSession.allowNTLMCredentialsForDomains(config['proxy-ntlm-domains']) | ||
} | ||
|
||
session.defaultSession.setCertificateVerifyProc((request, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for debug only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. Hopefully will give us more data for the bug we were speaking about tonight.
} else { | ||
options = Object.assign({}, options) | ||
} | ||
options.agent = options.agent || https.globalAgent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't https.request
need the same options.headers.host
patching as in http.request
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https.request
calls http.request
https://github.com/nodejs/node/blob/edb03cb65d51e336713d6af1134a7394c0776635/lib/https.js#L239
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for the explanation!
gui/src/main/proxy.js
Outdated
if (config['login-by-realm']) { | ||
config['login-by-realm'].split(',').forEach((lbr) => { | ||
const [realm, username, password] = lbr.split(':') | ||
loginByRealm[realm] = [username, password] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure auth doesn't break when password contains a colon?
const [realm, username, passwordParts] = lbr.split(':')
loginByRealm[realm] = [username, passwordParts.join(':')]
gui/src/main/proxy.js
Outdated
|
||
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => { | ||
log.warn({url, error, certificate: printCertificate(certificate)}, 'App Certificate Error') | ||
callback(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to callback(false) to not accept any certificate.
793e784
to
7a3d980
Compare
👍 👌 🙈 ❤️ 🎉 🚢 🚀 |
Tested on windows.