sos_platform_authenticator/
lib.rs1#![deny(missing_docs)]
4#![forbid(unsafe_code)]
5#![cfg_attr(all(doc, CHANNEL_NIGHTLY), feature(doc_auto_cfg))]
6use secrecy::SecretString;
7
8mod error;
9
10pub mod keyring_password;
11pub mod local_auth;
12
13pub use error::Error;
14
15pub(crate) type Result<T> = std::result::Result<T, Error>;
17
18pub async fn find_account_credential(
24 account_id: &str,
25) -> Result<SecretString> {
26 if local_auth::supported() {
27 if local_auth::authenticate(Default::default()) {
28 if keyring_password::supported() {
29 match keyring_password::find_account_password(account_id) {
30 Ok(password) => Ok(SecretString::new(password.into())),
31 Err(e) => Err(e),
32 }
33 } else {
34 Err(Error::Unauthorized)
35 }
36 } else {
37 Err(Error::Forbidden)
38 }
39 } else {
40 Err(Error::Unauthorized)
41 }
42}