Private
Public Access
1
0

auth: try switching to platform agnostic auth store

This commit is contained in:
2025-08-25 00:56:03 -07:00
parent f82123a454
commit c30330a444
3 changed files with 54 additions and 31 deletions

View File

@@ -10,7 +10,7 @@ chrono = "0.4.38"
directories = "6.0.0"
env_logger = "0.11.6"
futures-util = "0.3.31"
keyring = { version = "3.6.2", features = ["sync-secret-service"] }
keyring = { version = "3.6.3", features = ["apple-native", "sync-secret-service"] }
kordophone = { path = "../kordophone" }
kordophone-db = { path = "../kordophone-db" }
log = "0.4.25"

View File

@@ -21,10 +21,7 @@ impl DatabaseAuthenticationStore {
#[async_trait]
impl AuthenticationStore for DatabaseAuthenticationStore {
#[cfg(target_os = "linux")]
async fn get_credentials(&mut self) -> Option<Credentials> {
use keyring::secret_service::SsCredential;
self.database
.lock()
.await
@@ -38,15 +35,14 @@ impl AuthenticationStore for DatabaseAuthenticationStore {
match username {
Some(username) => {
let credential = SsCredential::new_with_target(
None,
"net.buzzert.kordophonecd",
&username,
)
.unwrap();
let password: Result<String> =
Entry::new_with_credential(Box::new(credential)).get_password();
let credential_res = Entry::new("net.buzzert.kordophonecd", &username);
let password: Result<String> = match credential_res {
Ok(credential) => credential.get_password(),
Err(e) => {
log::error!("error creating keyring credential: {}", e);
return None;
}
};
match password {
Ok(password) => Some(Credentials { username, password }),
@@ -62,11 +58,6 @@ impl AuthenticationStore for DatabaseAuthenticationStore {
.await
}
#[cfg(not(target_os = "linux"))]
async fn get_credentials(&mut self) -> Option<Credentials> {
None
}
async fn get_token(&mut self) -> Option<String> {
self.database
.lock()