veloren_voxygen_credentialstore/
lib.rs1mod fake;
2#[cfg(target_os = "linux")] mod linux;
3
4use thiserror::Error;
5
6#[cfg(not(target_os = "linux"))]
7pub type SecureService = fake::SecretService;
8#[cfg(target_os = "linux")]
9pub type SecureService = linux::SecretService;
10
11pub struct Credentials {
12 pub auth_server: String,
13 pub username: String,
14 pub password: String,
15}
16
17#[derive(Debug, Error)]
18pub enum CredentialError {
19 #[error("Failed to connect to credential store")]
20 Connection,
21 #[error("Failed to get credential store collection")]
22 Collection,
23 #[error("Failed to determine credential store collection lock state")]
24 State,
25 #[error("Failed to search credentials in credential store")]
26 Search,
27 #[error("Failed to unlock stored credentials")]
28 Unlock,
29 #[error("No stored credentials found in credential store")]
30 Empty,
31 #[error("Failed to get stored credential secret")]
32 Secret,
33 #[error("Stored credential secret is not valid UTF-8")]
34 Utf8,
35 #[error("Failed to save credentials to credential store")]
36 Save,
37}
38
39#[derive(Clone, Copy, PartialEq, PartialOrd)]
40pub enum CredentialStatus {
41 Disabled,
43 Locked,
45 Ready,
47}
48
49pub trait CredentialStore {
50 fn is_supported(&self) -> bool;
52 fn status(&self) -> impl Future<Output = CredentialStatus>;
54 fn load(
56 &self,
57 auth_server: String,
58 username: String,
59 ) -> impl Future<Output = Result<String, CredentialError>>;
60 fn save(&self, credentials: Credentials) -> impl Future<Output = Result<(), CredentialError>>;
62}