Page MenuHomePhabricator

[backup] Implement download latest endpoints
ClosedPublic

Authored by michal on Aug 28 2023, 2:01 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 7:59 AM
Unknown Object (File)
Fri, Nov 1, 10:36 PM
Unknown Object (File)
Sun, Oct 27, 5:01 PM
Unknown Object (File)
Oct 1 2024, 3:14 PM
Unknown Object (File)
Sep 27 2024, 11:26 PM
Unknown Object (File)
Sep 27 2024, 11:26 PM
Unknown Object (File)
Sep 27 2024, 11:26 PM
Unknown Object (File)
Sep 27 2024, 11:20 PM
Subscribers

Details

Summary

ENG-4501

Endpoints for downloading backup_id and user_keys for the latest backup for a user. They will be used in the restoration flow in the future. They don't require authorization (because the primary device can't authenticate with identity service before it restores itself from backup). For now we treat username just as userID, in the future we will ask identity service to do this conversion for us (because the primary device also won't know it's userID only username provided by the user).

Depends on D8964

Test Plan

Run:

GET http://127.0.0.1:50052/backups/latest/1/backup_id
GET http://127.0.0.1:50052/backups/latest/1/user_keys

Check if the returned data is correct. Check if it returns 404 for user without backups.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

services/backup/src/database/mod.rs
100 ↗(On Diff #30423)

This function previously incorrectly assumed that the global index contained all the fields of backup table

services/comm-services-lib/src/backup/mod.rs
4–7 ↗(On Diff #30423)

This will be also used in tests

Rust LGTM, just a few questions

services/backup/src/http/handlers/backup.rs
259–261 ↗(On Diff #30423)

Are we going to query by usernames and not user IDs directly? If so, what's the advantage?

Also, if we launch the "query by ID" version now, how can we migrate to usernames without breaking changes?

services/comm-services-lib/src/lib.rs
2 ↗(On Diff #30423)

What, besides commtest, is going to use the backup module?
If Rust clients, maybe it's worth propagating it to some crate in shared/?

services/backup/src/http/handlers/backup.rs
259–261 ↗(On Diff #30423)

During primary device restoration the only information available to us is username and password or eth signing information. We could query the identity service for username->userID mapping on device but it's better for the backup service to do it.

As for the breaking changes: the initial backup version is only going to be released for staff users. The idea was to just make the breaking change and gracefully handle it on the older clients.

While we are in the period where there are still staff with older devices, we could fallback to using "username" (user id) directly if we couldn't find it in the identity and remove that fallback later.

services/comm-services-lib/src/lib.rs
2 ↗(On Diff #30423)

There are plans for moving the mobile client backup logic to native code (not sure if C++ or Rust). In that case we should probably write a whole BackupClient for ergonomic use. We can move the response struct then

Thanks for explanations! I see you've already anticipated things that I was concerned about

services/backup/src/http/handlers/backup.rs
259–261 ↗(On Diff #30423)

One solution would be that backup service can handle both username and user id, using fallback approach

services/comm-services-lib/src/lib.rs
2 ↗(On Diff #30423)

Makes sense, thanks for answering

This revision is now accepted and ready to land.Aug 28 2023, 6:58 AM