cli: Improve `rad-auth` first authentication
This commit is contained in:
parent
e4b44370d3
commit
892f02bc43
|
|
@ -4,9 +4,9 @@ The example below is run with `RAD_PASSPHRASE` set.
|
||||||
```
|
```
|
||||||
$ rad auth
|
$ rad auth
|
||||||
|
|
||||||
Initializing your 🌱 profile and identity
|
Initializing your radicle 🌱 identity
|
||||||
|
|
||||||
✓ Creating your 🌱 Ed25519 keypair...
|
✓ Creating your Ed25519 keypair...
|
||||||
! Adding your radicle key to ssh-agent...
|
! Adding your radicle key to ssh-agent...
|
||||||
✓ Your Radicle ID is did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi. This identifies your device.
|
✓ Your Radicle ID is did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi. This identifies your device.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,10 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(options: Options) -> anyhow::Result<()> {
|
pub fn init(options: Options) -> anyhow::Result<()> {
|
||||||
term::headline("Initializing your 🌱 profile and identity");
|
term::headline(format!(
|
||||||
|
"Initializing your {} 🌱 identity",
|
||||||
|
term::format::highlight("radicle")
|
||||||
|
));
|
||||||
|
|
||||||
if let Ok(version) = radicle::git::version() {
|
if let Ok(version) = radicle::git::version() {
|
||||||
if version < radicle::git::VERSION_REQUIRED {
|
if version < radicle::git::VERSION_REQUIRED {
|
||||||
|
|
@ -84,9 +87,9 @@ pub fn init(options: Options) -> anyhow::Result<()> {
|
||||||
let passphrase = if options.stdin {
|
let passphrase = if options.stdin {
|
||||||
term::passphrase_stdin()
|
term::passphrase_stdin()
|
||||||
} else {
|
} else {
|
||||||
term::passphrase_confirm()
|
term::passphrase_confirm("Enter a passphrase:")
|
||||||
}?;
|
}?;
|
||||||
let spinner = term::spinner("Creating your 🌱 Ed25519 keypair...");
|
let spinner = term::spinner("Creating your Ed25519 keypair...");
|
||||||
let profile = Profile::init(home, passphrase.clone())?;
|
let profile = Profile::init(home, passphrase.clone())?;
|
||||||
spinner.finish();
|
spinner.finish();
|
||||||
|
|
||||||
|
|
@ -115,7 +118,7 @@ pub fn authenticate(profile: &Profile, options: Options) -> anyhow::Result<()> {
|
||||||
let agent = ssh::agent::Agent::connect()?;
|
let agent = ssh::agent::Agent::connect()?;
|
||||||
|
|
||||||
// TODO: Only show this if we're not authenticated.
|
// TODO: Only show this if we're not authenticated.
|
||||||
term::headline(&format!(
|
term::headline(format!(
|
||||||
"🌱 Authenticating as {}",
|
"🌱 Authenticating as {}",
|
||||||
term::format::Identity::new(profile).styled()
|
term::format::Identity::new(profile).styled()
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
let profile = ctx.profile()?;
|
let profile = ctx.profile()?;
|
||||||
let path = execute(options, &profile)?;
|
let path = execute(options, &profile)?;
|
||||||
|
|
||||||
term::headline(&format!(
|
term::headline(format!(
|
||||||
"🌱 Project checkout successful under ./{}",
|
"🌱 Project checkout successful under ./{}",
|
||||||
term::format::highlight(path.file_name().unwrap_or_default().to_string_lossy())
|
term::format::highlight(path.file_name().unwrap_or_default().to_string_lossy())
|
||||||
));
|
));
|
||||||
|
|
@ -105,7 +105,7 @@ pub fn execute(options: Options, profile: &Profile) -> anyhow::Result<PathBuf> {
|
||||||
anyhow::bail!("the local path {:?} already exists", path.as_path());
|
anyhow::bail!("the local path {:?} already exists", path.as_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
term::headline(&format!(
|
term::headline(format!(
|
||||||
"Initializing local checkout for 🌱 {} ({})",
|
"Initializing local checkout for 🌱 {} ({})",
|
||||||
term::format::highlight(options.id),
|
term::format::highlight(options.id),
|
||||||
payload.name(),
|
payload.name(),
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
&delegates,
|
&delegates,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
term::headline(&format!(
|
term::headline(format!(
|
||||||
"🌱 Project successfully cloned under {}",
|
"🌱 Project successfully cloned under {}",
|
||||||
term::format::highlight(Path::new(".").join(path).display())
|
term::format::highlight(Path::new(".").join(path).display())
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
|
||||||
let path = path.as_path().canonicalize()?;
|
let path = path.as_path().canonicalize()?;
|
||||||
let interactive = options.interactive;
|
let interactive = options.interactive;
|
||||||
|
|
||||||
term::headline(&format!(
|
term::headline(format!(
|
||||||
"Initializing local 🌱 project in {}",
|
"Initializing local 🌱 project in {}",
|
||||||
if path == cwd {
|
if path == cwd {
|
||||||
term::format::highlight(".").to_string()
|
term::format::highlight(".").to_string()
|
||||||
|
|
@ -286,7 +286,7 @@ pub fn setup_signing(
|
||||||
.ok_or(anyhow!("cannot setup signing in bare repository"))?;
|
.ok_or(anyhow!("cannot setup signing in bare repository"))?;
|
||||||
let key = ssh::fmt::fingerprint(node_id);
|
let key = ssh::fmt::fingerprint(node_id);
|
||||||
let yes = if !git::is_signing_configured(repo)? {
|
let yes = if !git::is_signing_configured(repo)? {
|
||||||
term::headline(&format!(
|
term::headline(format!(
|
||||||
"Configuring 🌱 signing key {}...",
|
"Configuring 🌱 signing key {}...",
|
||||||
term::format::tertiary(key)
|
term::format::tertiary(key)
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ pub fn run(
|
||||||
))?;
|
))?;
|
||||||
let head_branch = try_branch(workdir.head()?)?;
|
let head_branch = try_branch(workdir.head()?)?;
|
||||||
|
|
||||||
term::headline(&format!(
|
term::headline(format!(
|
||||||
"🌱 Creating patch for {}",
|
"🌱 Creating patch for {}",
|
||||||
term::format::highlight(project.name())
|
term::format::highlight(project.name())
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ pub fn run(
|
||||||
// `HEAD`; This is what we are proposing as a patch.
|
// `HEAD`; This is what we are proposing as a patch.
|
||||||
let head_branch = try_branch(workdir.head()?)?;
|
let head_branch = try_branch(workdir.head()?)?;
|
||||||
|
|
||||||
term::headline(&format!(
|
term::headline(format!(
|
||||||
"🌱 Updating patch for {}",
|
"🌱 Updating patch for {}",
|
||||||
term::format::highlight(project.name())
|
term::format::highlight(project.name())
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ pub fn columns() -> Option<usize> {
|
||||||
termion::terminal_size().map(|(cols, _)| cols as usize).ok()
|
termion::terminal_size().map(|(cols, _)| cols as usize).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn headline(headline: &str) {
|
pub fn headline(headline: impl fmt::Display) {
|
||||||
println!();
|
println!();
|
||||||
println!("{}", style(headline).bold());
|
println!("{}", style(headline).bold());
|
||||||
println!();
|
println!();
|
||||||
|
|
@ -214,16 +214,17 @@ pub fn passphrase() -> Result<Passphrase, anyhow::Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn passphrase_confirm() -> Result<Passphrase, anyhow::Error> {
|
pub fn passphrase_confirm(prompt: &str) -> Result<Passphrase, anyhow::Error> {
|
||||||
if let Some(p) = profile::env::passphrase() {
|
if let Some(p) = profile::env::passphrase() {
|
||||||
Ok(p)
|
Ok(p)
|
||||||
} else {
|
} else {
|
||||||
Ok(Passphrase::from(
|
Ok(Passphrase::from(
|
||||||
Password::new("Passphrase:")
|
Password::new(prompt)
|
||||||
.with_render_config(*CONFIG)
|
.with_render_config(*CONFIG)
|
||||||
.with_display_mode(inquire::PasswordDisplayMode::Masked)
|
.with_display_mode(inquire::PasswordDisplayMode::Masked)
|
||||||
.with_custom_confirmation_message("Repeat passphrase:")
|
.with_custom_confirmation_message("Repeat passphrase:")
|
||||||
.with_custom_confirmation_error_message("The passphrases don't match.")
|
.with_custom_confirmation_error_message("The passphrases don't match.")
|
||||||
|
.with_help_message("This passphrase protects your radicle identity")
|
||||||
.prompt()?,
|
.prompt()?,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue