pub struct PasswordAccounts { /* private fields */ }Expand description
Password accounts as an Authenticator, Directory and Accounts implementation.
The table is read again whenever it reports a change. A name that is not kept is verified against a dummy hash, so an unknown name costs the same time as a wrong password.
use coqui_access::{AccountPut, Accounts, Attempt, Authenticator, Verdict};
use coqui_access_password::PasswordAccounts;
let accounts = PasswordAccounts::builder().build().unwrap();
accounts
.put(AccountPut {
name: "alice".into(),
secret: Some("correct horse".into()),
..AccountPut::default()
})
.unwrap();
let verdict = accounts
.authenticate(Attempt {
name: Some("alice".into()),
secret: Some("correct horse".into()),
..Attempt::default()
})
.unwrap();
assert!(matches!(verdict, Verdict::Valid(_)));Implementations§
Source§impl PasswordAccounts
impl PasswordAccounts
Sourcepub fn builder() -> PasswordAccountsBuilder
pub fn builder() -> PasswordAccountsBuilder
Options for password accounts, kept in memory unless
table says otherwise.
Trait Implementations§
Source§impl Accounts for PasswordAccounts
impl Accounts for PasswordAccounts
Source§fn put(&self, account: AccountPut) -> Result<PutOutcome, ProviderError>
fn put(&self, account: AccountPut) -> Result<PutOutcome, ProviderError>
A new account needs a password; an existing one keeps its password unless one is given.
Source§fn accounts(&self) -> Result<Vec<AccountInfo>, ProviderError>
fn accounts(&self) -> Result<Vec<AccountInfo>, ProviderError>
The accounts kept, without anything that proves one.
Source§impl Authenticator for PasswordAccounts
impl Authenticator for PasswordAccounts
Source§fn authenticate(&self, attempt: Attempt) -> Result<Verdict, ProviderError>
fn authenticate(&self, attempt: Attempt) -> Result<Verdict, ProviderError>
Checks one attempt without returning person details or credential material. Read more
Source§impl Debug for PasswordAccounts
impl Debug for PasswordAccounts
Source§impl Directory for PasswordAccounts
impl Directory for PasswordAccounts
Auto Trait Implementations§
impl !Freeze for PasswordAccounts
impl !RefUnwindSafe for PasswordAccounts
impl !UnwindSafe for PasswordAccounts
impl Send for PasswordAccounts
impl Sync for PasswordAccounts
impl Unpin for PasswordAccounts
impl UnsafeUnpin for PasswordAccounts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more