Only re-prove identity when credentials change
Dependencies
- [2]
6FRPUHWKFix identity tests - [3]
YJXRCXOSDisallow overwriting existing identities via `pijul id edit` - [4]
QKBU6HCDPrevent illegal characters in identity name - [5]
4KJ45IJLImplement new identity management - [6]
4OJWMSOWFully replace crate::Identity
Change contents
- edit in pijul/src/identity/repair.rs at line 1
use super::create::IdentityCreateError; - replacement in pijul/src/identity/repair.rs at line 66
// match create_identity(Some(old_identity.clone()), no_prompt).await {if let Err(e) = old_identity.clone().create(no_prompt, true).await {match e {IdentityCreateError::ProveFailed(name) => writeln!(stderr, "Failed to prove identity. You will still be able to create & sign patches, but until you run `pijul identity prove --name {name}` they will not be linked to your personal details. If you are on an enterprise network, perhaps try running with `--no-cert-check`")?,IdentityCreateError::Other(err) => return Err(err),}};old_identity.clone().create(no_prompt, true).await?; - replacement in pijul/src/identity/create.rs at line 13
use log::{debug, warn};use log::{debug, error, warn}; - edit in pijul/src/identity/create.rs at line 15
use thiserror::Error; - edit in pijul/src/identity/create.rs at line 18
#[derive(Error, Debug)]pub enum IdentityCreateError {#[error("Could not prove identity {0}. Please check your credentials & network connection. If you are on an enterprise network, perhaps try running with `--no-cert-check`")]ProveFailed(String),#[error(transparent)]Other(#[from] anyhow::Error),} - replacement in pijul/src/identity/create.rs at line 26
replace_current: Option<&String>,to_replace: Option<&String>, - replacement in pijul/src/identity/create.rs at line 36
.with_initial_text(if replace_current.is_some() {.with_initial_text(if to_replace.is_some() { - replacement in pijul/src/identity/create.rs at line 48
if let Some(name) = replace_current {if let Some(name) = to_replace { - replacement in pijul/src/identity/create.rs at line 109
new_identity.prompt_remote(link_remote).await?;new_identity.prompt_remote().await?;// There are 3 cases that require re-proving:// 1: new identity (replace_current == None)// 2: new secret key// 3. new username/originif to_replace.is_none()|| 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,){// Prove the identity to the serverif link_remote&& new_identity.prove(*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);}} - replacement in pijul/src/identity/create.rs at line 182
async fn prompt_remote(&mut self, link_remote: bool) -> Result<(), IdentityCreateError> {async fn prompt_remote(&mut self) -> Result<(), anyhow::Error> { - edit in pijul/src/identity/create.rs at line 213
}// Prove the identity to the serverif link_remote&& self.prove(*NO_CERT_CHECK.get_or_init(|| false)).await.is_err(){return Err(IdentityCreateError::ProveFailed(self.name.clone())); - replacement in pijul/src/identity/create.rs at line 303
"Linking identity {}@{}",&self.config.author.username, &self.config.author.origin"Linking identity `{}` with {}@{}",&self.name, &self.config.author.username, &self.config.author.origin - replacement in pijul/src/identity/create.rs at line 346[4.38529]→[4.38529:38554](∅→∅),[4.38554]→[4.13960:13975](∅→∅),[4.13975]→[4.38568:38620](∅→∅),[4.38568]→[4.38568:38620](∅→∅),[4.38620]→[4.13976:14019](∅→∅)
pub async fn create(&self,no_prompt: bool,link_remote: bool,) -> Result<(), IdentityCreateError> {pub async fn create(&self, no_prompt: bool, link_remote: bool) -> Result<(), anyhow::Error> {