Skip to content
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

Merged
merged 3 commits into from
Nov 30, 2017
Merged

Use electron-proxy-agent #878

merged 3 commits into from
Nov 30, 2017

Conversation

aenario
Copy link
Contributor

@aenario aenario commented Nov 23, 2017

Tested on windows.

@aenario aenario force-pushed the electron-proxy-agent branch from 4d9918e to 3b4f424 Compare November 23, 2017 14:31
@aenario aenario requested a review from sebn November 23, 2017 14:36
@aenario aenario changed the title [WIP] Use electron-proxy-agent Use electron-proxy-agent Nov 23, 2017
@aenario aenario force-pushed the electron-proxy-agent branch from 3b4f424 to 9bda66a Compare November 23, 2017 15:23
@aenario aenario force-pushed the electron-proxy-agent branch from 9bda66a to f4c3404 Compare November 29, 2017 13:43
@codecov-io
Copy link

codecov-io commented Nov 29, 2017

Codecov Report

Merging #878 into master will decrease coverage by 0.33%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
cli/src/metadata.js 82.85% <0%> (-7.15%) ⬇️
cli/src/ignore.js 97.67% <0%> (-2.33%) ⬇️
cli/src/path_restrictions.js 94.91% <0%> (-1.7%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f469b4...7a3d980. Read the comment docs.

Copy link
Contributor

@sebn sebn left a 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()
Copy link
Contributor

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?


log.warn({config}, 'argv')

const printCertificate = (certif) => `Certificate(${certif.issuerName} ${certif.subjectName})`
Copy link
Contributor

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?

.help('help')
.parse()

log.warn({config}, 'argv')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.debug?

Copy link
Contributor

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'
Copy link
Contributor

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')
Copy link
Contributor

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).

Copy link
Contributor Author

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 😃


const printCertificate = (certif) => `Certificate(${certif.issuerName} ${certif.subjectName})`

module.exports = (app, session, doneSetup) => {
Copy link
Contributor

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?

Copy link
Contributor Author

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')

Copy link
Contributor

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 :)

Copy link
Contributor

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) => {
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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!

if (config['login-by-realm']) {
config['login-by-realm'].split(',').forEach((lbr) => {
const [realm, username, password] = lbr.split(':')
loginByRealm[realm] = [username, password]
Copy link
Contributor

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(':')]


app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
log.warn({url, error, certificate: printCertificate(certificate)}, 'App Certificate Error')
callback(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why false?

Copy link
Contributor Author

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.

@aenario aenario force-pushed the electron-proxy-agent branch from 793e784 to 7a3d980 Compare November 30, 2017 18:04
@sebn
Copy link
Contributor

sebn commented Nov 30, 2017

👍 👌 🙈 ❤️ 🎉 🚢 :shipit: 🚀

@sebn sebn merged commit 2ff1fc7 into master Nov 30, 2017
@sebn sebn deleted the electron-proxy-agent branch November 30, 2017 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants