Skip to main content

bitwarden_importers/importers/onepassword/access/
credentials.rs

1//! The credentials a password login needs.
2
3use zeroize::Zeroize;
4
5use super::sign_in::SignInAddress;
6
7/// The credentials for a password + Secret Key login.
8///
9/// Deliberately not `Debug`: it holds the master password and Secret Key.
10#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
11#[derive(Clone)]
12pub struct Credentials {
13    /// The account's email address.
14    pub username: String,
15    /// The account's master password.
16    pub password: String,
17    /// The account's Secret Key (Account Key), such as `A3-XXXXXX-...`.
18    pub account_key: String,
19    /// Where the account signs in, such as `my.1password.com`.
20    pub sign_in_address: SignInAddress,
21}
22
23impl Zeroize for Credentials {
24    fn zeroize(&mut self) {
25        self.password.zeroize();
26        self.account_key.zeroize();
27    }
28}
29
30// UniFFI records are lowered by moving out their fields, which Rust does not allow for a type that
31// implements `Drop`. The access client owns the lowered record in a zeroizing guard instead.
32#[cfg(not(feature = "uniffi"))]
33impl Drop for Credentials {
34    fn drop(&mut self) {
35        self.zeroize();
36    }
37}