Migrate `pijul::identity::Complete::prove` to `pijul::remote::prove`
Dependencies
- [2]
ABQDWHNGMigrate from `pijul::repository` to `pijul-repository` - [3]
Y2Y4OOIEMove `pijul::DEFAULT_CHANNEL` to `libpijul` - [4]
32G3GOK7Migrate from `dialoguer` to `pijul-interaction` - [5]
44RUBHREOnly re-prove identity when credentials change - [6]
YV63XF6ZFixing a conflict - [7]
6FRPUHWKFix identity tests - [8]
LZOGKBJXnew command `pijul client` for authenticating to a HTTP server - [9]
Y6TBQN7MAutomatically format `pijul` crate - [10]
4KJ45IJLImplement new identity management - [11]
MEK57BADOptional user in ssh_remote, allows to fix the key proof in `pijul id ed` - [12]
BV4PLHOVRemove dependency on `once_cell` - [13]
4RV7T4SRMigrate from `pijul::config` to `pijul-config` - [14]
4OJWMSOWFully replace crate::Identity - [15]
IKZBGTGQHandle absence of keyring as warning rather than error - [*]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [*]
MU5GSJAWPartial push and pull (WARNING: breaks the existing protocol) - [*]
L4JXJHWXpijul/*: reorganize imports and remove extern crate
Change contents
- edit in pijul/src/remote/mod.rs at line 2[18.884][19.406]
use std::io::Write; - edit in pijul/src/remote/mod.rs at line 17[19.457][5.246]
use crate::identity::Complete; - edit in pijul/src/remote/mod.rs at line 63
}/// Associate a generated key with a remote identity. Patches authored/// by unproven keys will only display the key as the author.pub async fn prove(identity: &Complete,origin: Option<&str>,no_cert_check: bool,) -> Result<(), anyhow::Error> {let remote = origin.unwrap_or(&identity.config.author.origin);let mut stderr = std::io::stderr();writeln!(stderr,"Linking identity `{}` with {}@{}",&identity.name, &identity.config.author.username, remote)?;let mut remote = if let Ok(repo) = Repository::find_root(None) {repository(&repo,None,Some(&identity.config.author.username),&remote,libpijul::DEFAULT_CHANNEL,no_cert_check,false,).await?} else {unknown_remote(None,Some(&identity.config.author.username),&remote,libpijul::DEFAULT_CHANNEL,no_cert_check,false,).await?};let (key, _password) = identity.credentials.clone().unwrap().decrypt(&identity.name)?;remote.prove(key).await?;Ok(()) - edit in pijul/src/identity/mod.rs at line 41
pub use create::NO_CERT_CHECK; - replacement in pijul/src/identity/mod.rs at line 173
credentials: Option<Credentials>,pub credentials: Option<Credentials>, - edit in pijul/src/identity/create.rs at line 3
use crate::remote;use pijul_repository::Repository; - replacement in pijul/src/identity/create.rs at line 9
use log::{debug, error, warn};use log::{debug, warn}; - edit in pijul/src/identity/create.rs at line 11
use std::sync::OnceLock; - edit in pijul/src/identity/create.rs at line 12[5.50]→[5.28571:28572](∅→∅),[5.483]→[5.28571:28572](∅→∅),[5.8770]→[5.28571:28572](∅→∅),[5.28571]→[5.28571:28572](∅→∅),[5.28572]→[5.353:413](∅→∅)
pub static NO_CERT_CHECK: OnceLock<bool> = OnceLock::new(); - edit in pijul/src/identity/create.rs at line 97[5.10536]→[5.10536:10537](∅→∅),[5.10537]→[4.1991:2018](∅→∅),[4.2018]→[5.10585:10660](∅→∅),[5.10585]→[5.10585:10660](∅→∅),[5.10660]→[4.2019:2051](∅→∅),[4.2051]→[5.10687:10722](∅→∅),[5.10687]→[5.10687:10722](∅→∅),[5.10722]→[5.256:305](∅→∅)
if Confirm::new()?.with_prompt("Do you want to link this identity to a remote?").with_default(true).interact()?{new_identity.prompt_remote().await?; - replacement in pijul/src/identity/create.rs at line 98[5.306]→[5.306:492](∅→∅),[5.492]→[4.2052:2081](∅→∅),[4.2081]→[5.528:841](∅→∅),[5.528]→[5.528:841](∅→∅)
// There are 3 cases that require re-proving:// 1: new identity (replace_current == None)// 2: new secret key// 3. new username/originif !will_replace|| self.secret_key() != new_identity.secret_key()|| (&self.config.author.origin, &self.config.author.username)!= (&new_identity.config.author.origin,&new_identity.config.author.username,)if link_remote {if Confirm::new()?.with_prompt("Do you want to link this identity to a remote?").with_default(true).interact()? - replacement in pijul/src/identity/create.rs at line 104[5.855]→[5.855:974](∅→∅),[5.974]→[5.3418:3493](∅→∅),[5.3493]→[5.1043:1505](∅→∅),[5.1043]→[5.1043:1505](∅→∅)
// Prove the identity to the serverif link_remote&& new_identity.prove(None, *NO_CERT_CHECK.get_or_init(|| false)).await.is_err(){error!("Could not prove identity `{}`. Please check your credentials & network connection. If you are on an enterprise network, perhaps try running with `--no-cert-check`. Your data is safe but will not be connected to {} without runnning `pijul identity prove {}`", new_identity.name, new_identity.config.author.origin, new_identity.name);}new_identity.prompt_remote().await?;} else {// The user wants an 'offline' identity, so make sure not to store login infonew_identity.config.key_path = None;new_identity.config.author.username = String::new();new_identity.config.author.origin = String::new(); - edit in pijul/src/identity/create.rs at line 111
} else {// The user wants an 'offline' identity, so make sure not to store login infonew_identity.config.key_path = None;new_identity.config.author.username = String::new();new_identity.config.author.origin = String::new(); - edit in pijul/src/identity/create.rs at line 264[5.36754]→[5.36754:36755](∅→∅),[5.36755]→[5.36755:36896](∅→∅),[5.36896]→[5.3494:3696](∅→∅),[5.3696]→[5.36978:37060](∅→∅),[5.36978]→[5.36978:37060](∅→∅),[5.37060]→[5.1590:1638](∅→∅),[5.1638]→[5.3697:3758](∅→∅),[5.1719]→[5.37154:37166](∅→∅),[5.3758]→[5.37154:37166](∅→∅),[5.4661]→[5.37154:37166](∅→∅),[5.13814]→[5.37154:37166](∅→∅),[5.37154]→[5.37154:37166](∅→∅)
/// Associate a generated key with a remote identity. Patches authored/// by unproven keys will only display the key as the author.pub async fn prove(&self,origin: Option<&str>,no_cert_check: bool,) -> Result<(), anyhow::Error> {let remote = origin.unwrap_or(&self.config.author.origin);let mut stderr = std::io::stderr();writeln!(stderr,"Linking identity `{}` with {}@{}",&self.name, &self.config.author.username, remote)?; - edit in pijul/src/identity/create.rs at line 265[5.13871]→[5.37218:37291](∅→∅),[5.37218]→[5.37218:37291](∅→∅),[5.37291]→[2.866:921](∅→∅),[2.921]→[5.3784:3883](∅→∅),[5.3784]→[5.3784:3883](∅→∅),[5.3883]→[3.0:43](∅→∅),[3.43]→[5.3923:4011](∅→∅),[5.3923]→[5.3923:4011](∅→∅),[5.4011]→[5.38042:38059](∅→∅),[5.38042]→[5.38042:38059](∅→∅),[5.38059]→[5.4012:4154](∅→∅),[5.4154]→[3.44:87](∅→∅),[3.87]→[5.4194:4282](∅→∅),[5.4194]→[5.4194:4282](∅→∅),[5.4282]→[5.38107:38119](∅→∅),[5.38107]→[5.38107:38119](∅→∅),[5.38119]→[5.13872:13959](∅→∅),[5.13959]→[5.38194:38228](∅→∅),[5.38194]→[5.38194:38228](∅→∅),[5.38228]→[5.38228:38251](∅→∅)
let mut remote = if let Ok(repo) = Repository::find_root(None) {remote::repository(&repo,None,Some(&self.config.author.username),&remote,libpijul::DEFAULT_CHANNEL,no_cert_check,false,).await?} else {crate::remote::unknown_remote(None,Some(&self.config.author.username),&remote,libpijul::DEFAULT_CHANNEL,no_cert_check,false,).await?};let (key, _password) = self.credentials.clone().unwrap().decrypt(&self.name)?;remote.prove(key).await?;Ok(())} - edit in pijul/src/commands/identity.rs at line 2
use crate::remote; - replacement in pijul/src/commands/identity.rs at line 11
use log::warn;use log::{info, warn}; - edit in pijul/src/commands/identity.rs at line 245
crate::identity::NO_CERT_CHECK.set(self.no_cert_check).unwrap(); - edit in pijul/src/commands/identity.rs at line 260
if let Err(_) = remote::prove(&identity, None, self.no_cert_check).await {warn!("Could not prove identity `{}`. Please check your credentials & network connection. If you are on an enterprise network, perhaps try running with `--no-cert-check`. Your data is safe but will not be connected to {} without runnning `pijul identity prove {}`", identity.name, identity.config.author.origin, identity.name);} else {info!("Identity `{}` was proved to the server", identity);} - replacement in pijul/src/commands/identity.rs at line 273[5.49589]→[5.49589:49687](∅→∅),[5.49687]→[5.4467:4533](∅→∅),[5.4533]→[5.49734:49763](∅→∅),[5.49734]→[5.49734:49763](∅→∅)
Complete::load(&identity_name.unwrap_or(choose_identity_name(no_prompt).await?))?.prove(server.as_deref(), self.no_cert_check).await?;let identity_name =&identity_name.unwrap_or(choose_identity_name(no_prompt).await?);let loaded_identity = Complete::load(identity_name)?;remote::prove(&loaded_identity, server.as_deref(), self.no_cert_check).await?; - replacement in pijul/src/commands/identity.rs at line 409
old_identity.replace_with(new_identity)?;old_identity.clone().replace_with(new_identity.clone())?;// There are 2 cases that require re-proving:// 1: new secret key// 2. new username/originif !options.no_link {if new_identity.secret_key() != old_identity.secret_key()|| old_identity.config.author != new_identity.config.author{let prove_result =remote::prove(&new_identity, None, self.no_cert_check).await;if let Err(_) = prove_result {warn!("Could not prove identity `{}`. Please check your credentials & network connection. If you are on an enterprise network, perhaps try running with `--no-cert-check`. Your data is safe but will not be connected to {} without runnning `pijul identity prove {}`", new_identity.name, new_identity.config.author.origin, new_identity.name);} else {info!("Identity `{}` was proved to the server", new_identity);}}}