-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checks if there is a profile to be loaded, if the ssh agent is running and if there is a Radicle identity stored in the ssh-agent.
- Loading branch information
1 parent
1222278
commit 21841b4
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use anyhow::anyhow; | ||
use radicle::crypto::ssh; | ||
|
||
use crate::{error::Error, AppState}; | ||
|
||
#[tauri::command] | ||
pub fn authenticate(ctx: tauri::State<AppState>) -> Result<(), Error> { | ||
let profile = &ctx.profile; | ||
|
||
if !profile.keystore.is_encrypted()? { | ||
return Ok(()); | ||
} | ||
match ssh::agent::Agent::connect() { | ||
Ok(mut agent) => { | ||
if agent.request_identities()?.contains(&profile.public_key) { | ||
return Ok(()); | ||
} else { | ||
Err(Error::WithHint { | ||
err: anyhow!("Not able to find your keys in the ssh agent"), | ||
hint: "Make sure to run <code>rad auth</code> in your terminal to add your keys to the ssh-agent.", | ||
})? | ||
} | ||
} | ||
Err(e) if e.is_not_running() => Err(Error::WithHint { err: anyhow!("SSH Agent is not running"), hint: "For now we require the user to have an ssh agent running, since we don't have passphrase inputs yet." })?, | ||
Err(e) => Err(e)?, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters