-
Notifications
You must be signed in to change notification settings - Fork 879
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
Sync v2 #5294
Sync v2 #5294
Conversation
668915c
to
3b5392f
Compare
de74c2a
to
4fb0a66
Compare
5697bb2
to
02023d0
Compare
patches/chrome-browser-resources-settings-people_page-sync_browser_proxy.js.patch
Outdated
Show resolved
Hide resolved
4f791a2
to
08eb047
Compare
|
||
bool IsSyncSubpage(const GURL& current_url) { | ||
+ BRAVE_IS_SYNC_SUBPAGE | ||
return current_url == chrome::GetSettingsUrl(chrome::kSyncSetupSubPage); |
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.
GetSettingsUrl
looks like something we could easily override
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.
fixed in b2fdf8c
|
||
+ BRAVE_PROFILE_SYNC_SERVICE_H_ |
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.
see https://github.com/brave/brave-browser/wiki/Patching-Chromium#making-methods-virtual for adding a method without patching
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.
fixed b2fdf8c
void ResetRequestAccessTokenBackoffForTest(); | ||
|
||
private: | ||
+ BRAVE_SYNC_AUTH_MANAGER_H_ |
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.
I believe the technique in https://github.com/brave/brave-browser/wiki/Patching-Chromium#making-methods-virtual can also be used here
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.
fixed b2fdf8c
defines = [ "SYNC_USER_AGENT_PRODUCT=$sync_user_agent_product" ] | ||
|
||
configs += [ "//build/config/compiler:wexit_time_destructors" ] | ||
+ |
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.
don't add extra newlines in patches
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.
fixed in b2fdf8c
const syncCode = await this.braveBrowserProxy_.getSyncCode() | ||
syncPrefs.setNewPassphrase = false; | ||
syncPrefs.passphrase = syncCode; | ||
console.debug('sync set encryption', syncPrefs) |
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.
won't this leak the passphrase into the console (and potentially the log)?
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.
cc @petemill
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.
fixed in 247a37c
return | ||
} | ||
const data = await this.syncBrowserProxy_.getQRCode(this.syncCode) | ||
console.log('qr code', data) |
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.
I don't think we should be outputting this kind of data on the console (and potentially logging to disk)
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.
fixed in 247a37c
|
||
std::vector<uint8_t> seed; | ||
if (!brave_sync::crypto::PassphraseToBytes32(sync_code->GetString(), &seed)) { | ||
LOG(ERROR) << "invalid sync code:" << sync_code->GetString(); |
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.
this is only logging invalid codes, but a user might just be using the wrong sync chain or something so we probably should log this
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.
yea i think this could be sensitive info and shouldn't be logged
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.
fixed in 247a37c
|
||
std::vector<uint8_t> seed; | ||
if (!brave_sync::crypto::PassphraseToBytes32(sync_code->GetString(), &seed)) { | ||
LOG(ERROR) << "invalid sync code:" << sync_code->GetString(); |
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.
same as above
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.
fixed in 247a37c
base::Time time; | ||
if (network_time_tracker_->GetNetworkTime(&time, nullptr) != | ||
network_time::NetworkTimeTracker::NETWORK_TIME_AVAILABLE) { | ||
LOG(WARNING) << "Network time not available, using local time"; |
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.
this seems like it should be a vlog
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.
fixed in b2fdf8c
CHECK(args->Get(1, &sync_code)); | ||
|
||
if (sync_code->GetString().empty()) { | ||
LOG(ERROR) << "No sync code parameter provided!"; |
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.
seems like all of these should be VLOG
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.
This one I think should stay as error since our code doesn't supply the wrong number of parameters so if it errors it will be a one off dev error when making a change
@petemill there are some html checks failed in sonar cloud |
app/brave_generated_resources.grd
Outdated
Sync Settings | ||
</message> | ||
<message name="IDS_SETTINGS_BRAVE_SYNC_SETTINGS_SUBTITLE" desc="Brave Sync settings subtitle"> | ||
Manage what information you would like to sync between devices. These settings only effect this device. |
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.
affect not effect
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.
fixed in 4f4fa65
app/brave_generated_resources.grd
Outdated
To start, you will need Brave installed on all the devices you plan to sync. Then, securely link them together with a sync code. | ||
</message> | ||
<message name="IDS_SETTINGS_BRAVE_SYNC_MANAGE_ACTION_LABEL" desc="Brave Sync manage action label"> | ||
Manage your sync'd devices |
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.
i think synced
instead of sync'd
looks more correct?
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.
fixed in 4f4fa65
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.
FYI @bradleyrichter sync'd
-> synced
base::Base64Encode(access_token, &encoded_access_token); | ||
DCHECK(!encoded_access_token.empty()); | ||
|
||
VLOG(1) << "access_token= " << encoded_access_token; |
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.
did you mean to keep this VLOG? (access token is sensitive info)
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.
fixed in 5e3cc37
@@ -158,7 +172,7 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) { | |||
|
|||
// Brave's sync protocol does not use the sync service url | |||
command_line.AppendSwitchASCII(switches::kSyncServiceURL, | |||
"https://no-thanks.invalid"); | |||
kBraveSyncServiceURL); |
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.
we should check to make sure the sync url is empty before setting it, otherwise you can't override
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.
void BraveCommandLineHelper::AppendSwitch(const char* switch_key) {
if (!command_line_.HasSwitch(switch_key))
command_line_.AppendSwitch(switch_key);
}
our BraveCommandLineHelper already checks it
and add BRAVE_SERVICES_KEY header for sync request Also remove access token VLOG
…ith how to add BraveServiceKeys in http_bridge.cc
The infobar displays a notice that sync v2 must be setup in order to continue syncing. In this infobar, the user can - perform an action to begin sync v2 setup, or; - dismiss the infobar.
[sync-v2 base] Sync: Show an infobar at startup for sync v1 users
@petemill mentioned we can ignore the only error from SonarCloud |
Resolves brave/brave-browser#9989
Resolves brave/brave-browser#9241
This PR
2.1. Setup flow concept inherited from v1 will be in
brave:///settings/braveSync
as subpage2.2. Brings back
about:sync-internals
2.3.
brave://sync
will be redirect tobrave:///settings/braveSync
2.4. Client encryption is enforced in UI using bip39 seed.
3.1. Seed is encrypted using OSCrypt when stored in prefs
3.2.
ProfileSyncService
monitor seed changes to decide reset sync chain or tell SyncAuthManger to derive signing key3.3.
BraveSyncAuthManager
will have a dummySyncAccountInfo
and create access tokenbase64(timestamp_hex|signed_timestamp_hex|public_key_hex)
, timestamp is from network time, if network time is not available, local time will be used. Each server response will update the network time by headerSane-Time-Millis
4.1. Strip off bookmark meta info used by v1 in
BookmarkModel
4.2 Stop engine to have a clean engine state in
ProfileSyncService
5.1. upstream
sync_auth_manager_unittest.cc
5.2
brave_sync_auth_manager_unittest.cc
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Note that Sync v1 and v2 are incompatible so DONOT try to connect v1 and v2 devices, it won't work
Upgrade from v1
Migration
profile/Default/Bookmarks
and each bookmark will no longer have sync v1 meta infoFeature flag
brave://flags/#brave-sync
in v1brave:///settings/braveSync
brave://flags
and there will only bebrave://flags/#brave-sync-v2
andbrave://flags/#brave-sync
is goneInfobar
#5804 (comment)
v2 test
Single device
about:sync-internals
2.1. Make sure
Passphrase Type
isPassphraseType::kCustomPassphrase
2.2.
Encrypted Types
include every types we support2.3.
Has Token
istrue
profile/Default/Preferences
3.1.
seed
inbrave_sync_v2
should not be your sync code (it is encrypted)3.2.
v1_meta_info_cleared
is true3.3.
v1_migrated
is truebrave://sync/
in URL bar should take you tobrave:///settings/braveSync
about:sync-internals
, sync engine should stopMultiple devices
about:sync-internals
Always show bookmarks
(Type Bookmarks & Preferences)Offline sync chain creation
about:sync-internals
Client clock out of date
about:sync-internals
Feature flag
about:sync-internals
and make sure sync engine is runningbrave://flags/#brave-sync-v2
and disable itabout:sync-internals
should showTransport State
isSync service does not exist
brave:///settings/
brave://flags/#brave-sync-v2
and enable itabout:sync-internals
will show sync engine is runningUI test
Reviewer Checklist:
After-merge Checklist:
changes has landed on.