rename client id -> client key

This commit is contained in:
Dustin J. Mitchell 2020-12-28 21:31:02 +00:00
parent e555af8895
commit 92d629522b
11 changed files with 124 additions and 122 deletions

View file

@ -20,8 +20,8 @@ pub enum ServerConfig {
/// Sync server "origin"; a URL with schema and hostname but no path or trailing `/`
origin: String,
/// Client ID to identify this replica to the server
client_id: Uuid,
/// Client Key to identify and authenticate this replica to the server
client_key: Uuid,
/// Private encryption secret used to encrypt all data sent to the server. This can
/// be any suitably un-guessable string of bytes.

View file

@ -18,8 +18,8 @@ pub fn from_config(config: ServerConfig) -> Fallible<Box<dyn Server>> {
ServerConfig::Local { server_dir } => Box::new(LocalServer::new(server_dir)?),
ServerConfig::Remote {
origin,
client_id,
client_key,
encryption_secret,
} => Box::new(RemoteServer::new(origin, client_id, encryption_secret)),
} => Box::new(RemoteServer::new(origin, client_key, encryption_secret)),
})
}

View file

@ -8,7 +8,7 @@ use crypto::{HistoryCiphertext, HistoryCleartext, Secret};
pub struct RemoteServer {
origin: String,
client_id: Uuid,
client_key: Uuid,
encryption_secret: Secret,
agent: ureq::Agent,
}
@ -17,13 +17,13 @@ pub struct RemoteServer {
/// taskchampion-sync-server).
impl RemoteServer {
/// Construct a new RemoteServer. The `origin` is the sync server's protocol and hostname
/// without a trailing slash, such as `https://tcsync.example.com`. Pass a client_id to
/// without a trailing slash, such as `https://tcsync.example.com`. Pass a client_key to
/// identify this client to the server. Multiple replicas synchronizing the same task history
/// should use the same client_id.
pub fn new(origin: String, client_id: Uuid, encryption_secret: Vec<u8>) -> RemoteServer {
/// should use the same client_key.
pub fn new(origin: String, client_key: Uuid, encryption_secret: Vec<u8>) -> RemoteServer {
RemoteServer {
origin,
client_id,
client_key,
encryption_secret: encryption_secret.into(),
agent: ureq::agent(),
}
@ -58,7 +58,7 @@ impl Server for RemoteServer {
) -> Fallible<AddVersionResult> {
let url = format!(
"{}/client/{}/add-version/{}",
self.origin, self.client_id, parent_version_id
self.origin, self.client_key, parent_version_id
);
let history_cleartext = HistoryCleartext {
parent_version_id,
@ -89,7 +89,7 @@ impl Server for RemoteServer {
fn get_child_version(&mut self, parent_version_id: VersionId) -> Fallible<GetVersionResult> {
let url = format!(
"{}/client/{}/get-child-version/{}",
self.origin, self.client_id, parent_version_id
self.origin, self.client_key, parent_version_id
);
let resp = self
.agent