This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 975
Remove keytar and gnome-keyring deps #10514
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,3 @@ addons: | |
packages: | ||
- xvfb | ||
- g++-4.8 | ||
- libgnome-keyring-dev | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,83 +4,18 @@ | |
|
||
'use strict' | ||
|
||
const keytar = require('keytar') | ||
const appConstants = require('../../../js/constants/appConstants') | ||
const appActions = require('../../../js/actions/appActions') | ||
const CryptoUtil = require('../../../js/lib/cryptoUtil') | ||
const locale = require('../../locale') | ||
const messages = require('../../../js/constants/messages') | ||
const {getWebContents} = require('../webContentsCache') | ||
const {makeImmutable} = require('../../common/state/immutableUtil') | ||
const Immutable = require('immutable') | ||
const {ipcMain} = require('electron') | ||
const autofill = require('../../autofill') | ||
|
||
const unsafeTestMasterKey = 'c66af15fc6555ebecf7cee3a5b82c108fd3cb4b587ab0b299d28e39c79ecc708' | ||
|
||
// Don't show the keytar prompt more than once per 24 hours | ||
let throttleKeytar = false | ||
|
||
// Map of password notification bar messages to their callbacks | ||
const passwordCallbacks = {} | ||
|
||
let masterKey | ||
|
||
/** | ||
* Gets the master key for encrypting login credentials from the OS keyring. | ||
*/ | ||
const getMasterKey = () => { | ||
if (throttleKeytar) { | ||
return null | ||
} | ||
|
||
if (process.env.NODE_ENV === 'test') { | ||
// workaround for https://travis-ci.org/brave/browser-laptop/builds/132700770 | ||
return (new Buffer(unsafeTestMasterKey, 'hex')).toString('binary') | ||
} | ||
|
||
const appName = 'Brave' | ||
// Previously the master key was binary encoded, which caused compatibility | ||
// issues with various keyrings. In 0.8.3, switch to hex encoding for storage. | ||
const oldAccountName = 'login master key' | ||
const accountName = 'login master key v2' | ||
let oldMasterKey = keytar.getPassword(appName, oldAccountName) | ||
let masterKey = keytar.getPassword(appName, accountName) | ||
|
||
let success = false | ||
|
||
if (masterKey === null) { | ||
if (typeof oldMasterKey === 'string') { | ||
// The user made a v1 (binary) key. Try converting it to hex if it | ||
// appears to be 32 bytes. | ||
let oldBuffer = new Buffer(oldMasterKey, 'binary') | ||
if (oldBuffer.length === 32) { | ||
success = keytar.addPassword(appName, accountName, oldBuffer.toString('hex')) | ||
} | ||
} | ||
|
||
// Either the user denied access or no master key has ever been created. | ||
// We can't tell the difference so try making a new master key. | ||
success = success || keytar.addPassword(appName, accountName, CryptoUtil.getRandomBytes(32).toString('hex')) | ||
|
||
if (success) { | ||
// A key should have been created | ||
masterKey = keytar.getPassword(appName, accountName) | ||
} | ||
} | ||
|
||
if (typeof masterKey === 'string') { | ||
// Convert from hex to binary | ||
return (new Buffer(masterKey, 'hex')).toString('binary') | ||
} else { | ||
throttleKeytar = true | ||
setTimeout(() => { | ||
throttleKeytar = false | ||
}, 1000 * 60 * 60 * 24) | ||
return null | ||
} | ||
} | ||
|
||
const init = () => { | ||
ipcMain.on(messages.NOTIFICATION_RESPONSE, (e, message, buttonIndex, persist) => { | ||
if (passwordCallbacks[message]) { | ||
|
@@ -190,53 +125,20 @@ const clearPasswords = () => { | |
autofill.clearLogins() | ||
} | ||
|
||
const migrate = (state) => { | ||
const passwords = state.get('passwords') | ||
if (passwords.size) { | ||
masterKey = masterKey || getMasterKey() | ||
if (!masterKey) { | ||
console.log('Could not access master password; aborting') | ||
return | ||
} | ||
passwords.forEach((password) => { | ||
let decrypted = CryptoUtil.decryptVerify(password.get('encryptedPassword'), | ||
password.get('authTag'), | ||
masterKey, | ||
password.get('iv')) | ||
if (decrypted) { | ||
let form = {} | ||
form['origin'] = password.get('origin') | ||
form['signon_realm'] = password.get('origin') + '/' | ||
form['action'] = password.get('action') | ||
form['username'] = password.get('username') | ||
form['password'] = decrypted | ||
autofill.addLogin(form) | ||
} | ||
}) | ||
state = state.set('legacyPasswords', state.get('passwords')) | ||
state = state.set('passwords', new Immutable.List()) | ||
} | ||
const allSiteSettings = state.get('siteSettings') | ||
const blackedList = allSiteSettings.filter((setting) => setting.get('savePasswords') === false) | ||
if (blackedList.size) { | ||
blackedList.forEach((entry, index) => { | ||
let form = {} | ||
form['origin'] = index | ||
form['signon_realm'] = index + '/' | ||
form['blacklisted_by_user'] = true | ||
autofill.addLogin(form) | ||
appActions.deletePasswordSite(index) | ||
}) | ||
} | ||
return state | ||
} | ||
|
||
const passwordManagerReducer = (state, action, immutableAction) => { | ||
action = immutableAction || makeImmutable(action) | ||
switch (action.get('actionType')) { | ||
case appConstants.APP_SET_STATE: | ||
init() | ||
state = migrate(state) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
// Log a warning if they are updating from <0.15.300 to 0.21 or higher | ||
if (state.getIn(['passwords', 0])) { | ||
console.log('Warning: unable to migrate old passwords.') | ||
} | ||
// legacyPasswords was added in 0.15.300 to backup old passwords in case | ||
// the migration failed | ||
if (state.get('legacyPasswords')) { | ||
state = state.delete('legacyPasswords') | ||
} | ||
break | ||
case appConstants.APP_SAVE_PASSWORD: | ||
savePassword(action.get('username'), action.get('origin'), action.get('tabId')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,8 +38,6 @@ | |
"libxtst6", | ||
"libxss1", | ||
"python", | ||
"xdg-utils", | ||
"gir1.2-gnomekeyring-1.0", | ||
"libgnome-keyring0" | ||
"xdg-utils" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
gnome-keyring is needed at runtime by muon, not sure if removing this will cause issues.
see: #10448
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.
gnome-keyring is deprecated by libsecret
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.
unless you happened to be the 3%
https://bugs.chromium.org/p/chromium/issues/detail?id=466975
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.
And I think this is the deps for keytar use not for muon which will be precompiled before browser-laptop can use it.