diff options
author | Alex Auvolat <alex@adnab.me> | 2022-05-31 15:30:32 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-05-31 15:30:32 +0200 |
commit | d53cf1d220ef08c0b9368cfe91bee7660b7f5a3b (patch) | |
tree | 59e9b4b311553f5feb5a533ddc994074ccde6f6e /src/login/mod.rs | |
parent | 8192d062baf7f783af9519b9419647dc907a3c8c (diff) | |
download | aerogramme-d53cf1d220ef08c0b9368cfe91bee7660b7f5a3b.tar.gz aerogramme-d53cf1d220ef08c0b9368cfe91bee7660b7f5a3b.zip |
Implement public_login
Diffstat (limited to 'src/login/mod.rs')
-rw-r--r-- | src/login/mod.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/login/mod.rs b/src/login/mod.rs index 2640a58..c0e9032 100644 --- a/src/login/mod.rs +++ b/src/login/mod.rs @@ -24,6 +24,9 @@ pub trait LoginProvider { /// The login method takes an account's password as an input to decypher /// decryption keys and obtain full access to the user's account. async fn login(&self, username: &str, password: &str) -> Result<Credentials>; + /// The public_login method takes an account's email address and returns + /// public credentials for adding mails to the user's inbox. + async fn public_login(&self, email: &str) -> Result<PublicCredentials>; } /// The struct Credentials represent all of the necessary information to interact @@ -36,6 +39,13 @@ pub struct Credentials { pub keys: CryptoKeys, } +#[derive(Clone, Debug)] +pub struct PublicCredentials { + /// The storage credentials are used to authenticate access to the underlying storage (S3, K2V) + pub storage: StorageCredentials, + pub public_key: PublicKey, +} + /// The struct StorageCredentials contains access key to an S3 and K2V bucket #[derive(Clone, Debug)] pub struct StorageCredentials { @@ -396,7 +406,7 @@ impl CryptoKeys { Ok((salt_ct, public_ct)) } - async fn load_salt_and_public(k2v: &K2vClient) -> Result<([u8; 32], PublicKey)> { + pub async fn load_salt_and_public(k2v: &K2vClient) -> Result<([u8; 32], PublicKey)> { let mut params = k2v .read_batch(&[ k2v_read_single_key("keys", "salt", false), |