oxedyne/fe2o3/fe2o3_net/src/mail/user.rs
1.3 KiB, 20 runs
created by r1870400018:9852, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | //! User authentication trait used by SMTP submission and IMAP login. |
| 2 | //! |
| 3 | //! Implementations look up an account by its full email address and |
| 4 | //! verify the supplied password, returning a [`MailUser`] handle that the |
| 5 | //! `MailStore` then consumes to address the right mailbox. |
| 6 | //! |
| 7 | //! [Written with AI entirely](https://need2know.ai/entirely-ai/code)\ |
| 8 | //! Anthropic Claude |
| 9 | |
| 10 | use crate::mail::store::MailUser; |
| 11 | |
| 12 | use oxedyne_fe2o3_core::prelude::*; |
| 13 | |
| 14 | |
| 15 | /// Implementations are expected to be cheap to clone, typically via an internal |
| 16 | /// `Arc`, so a single store can be handed to every server task without |
| 17 | /// contention. |
| 18 | pub trait UserStore: Clone + Send + Sync + 'static { |
| 19 | /// The address is the full RFC 5321 `local@domain` form, matched |
| 20 | /// case-insensitively in the local part where the underlying system permits |
| 21 | /// it, and always with the domain lowercased. An error means a |
| 22 | /// transport-level failure only; a wrong password is a successful lookup |
| 23 | /// that yields `Ok(None)`. |
| 24 | fn authenticate( |
| 25 | &self, |
| 26 | address: &str, |
| 27 | password: &str, |
| 28 | ) |
| 29 | -> Outcome<Option<MailUser>>; |
| 30 | |
| 31 | /// No password check; the SMTP receive path on port 25 uses this to route |
| 32 | /// inbound mail to a local mailbox. |
| 33 | fn lookup(&self, address: &str) -> Outcome<Option<MailUser>>; |
| 34 | } |