ailloli_ui_fs/auth.rs
1//! Authentication challenges emitted by interactive filesystem providers.
2
3use crate::FileUri;
4
5/// Credential or trust decision requested by a provider.
6///
7/// # Examples
8///
9/// ```
10/// use ailloli_ui_fs::AuthKind;
11/// assert_ne!(AuthKind::UserPassword, AuthKind::HostKeyVerification);
12/// ```
13#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
14pub enum AuthKind {
15 /// Request a user name/password credential flow.
16 UserPassword,
17 /// Request the passphrase needed to unlock a private key.
18 PrivateKeyPassphrase,
19 /// Ask the user or policy layer to accept or reject a remote host key.
20 HostKeyVerification,
21}
22
23/// Provider authentication challenge associated with one filesystem URI.
24///
25/// `message == None` means the provider supplied no additional prompt. An empty
26/// string is distinct and is preserved by serialization.
27///
28/// # Examples
29///
30/// ```
31/// use ailloli_ui_fs::{AuthKind, AuthRequest, FileUri};
32/// let request = AuthRequest { uri: FileUri::parse("sftp://host/home")?, kind: AuthKind::UserPassword, message: None };
33/// assert_eq!(request.message, None);
34/// # Ok::<(), ailloli_ui_fs::FileError>(())
35/// ```
36#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
37pub struct AuthRequest {
38 /// Resource whose provider requires authentication.
39 pub uri: FileUri,
40 /// Credential or trust decision being requested.
41 pub kind: AuthKind,
42 /// Optional provider-facing prompt or context; `None` means absent.
43 pub message: Option<String>,
44}