pub struct PasswordStore { /* private fields */ }Expand description
Password store for managing user authentication
Implementations§
Source§impl PasswordStore
impl PasswordStore
Sourcepub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load passwords from a file
File format: username:password (one per line) Password formats supported:
- Argon2 PHC format:
username:$argon2id$v=19$m=...(recommended, secure storage) - Cleartext:
username:mysecret(will be hashed with Argon2 on load) - MD5 for wire protocol:
username:{MD5}hash(for PostgreSQL MD5 wire protocol compatibility)
Comments start with # and empty lines are ignored.
Security note: Cleartext passwords will be automatically hashed with Argon2. For PostgreSQL MD5 wire protocol, use {MD5} prefix (less secure storage).
Sourcepub fn add_user(&mut self, username: String, password: &str) -> Result<()>
pub fn add_user(&mut self, username: String, password: &str) -> Result<()>
Add a user with a password (will be hashed with Argon2)
Sourcepub fn add_user_hashed(&mut self, username: String, password_hash: String)
pub fn add_user_hashed(&mut self, username: String, password_hash: String)
Add a user with an already-hashed password
Sourcepub fn get_password(&self, username: &str) -> Option<&String>
pub fn get_password(&self, username: &str) -> Option<&String>
Get the stored password for a user
Sourcepub fn verify_cleartext(&self, username: &str, password: &str) -> bool
pub fn verify_cleartext(&self, username: &str, password: &str) -> bool
Verify a cleartext password for a user This works with Argon2 hashes (recommended) but not with {MD5} format
Trait Implementations§
Source§impl Clone for PasswordStore
impl Clone for PasswordStore
Source§fn clone(&self) -> PasswordStore
fn clone(&self) -> PasswordStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PasswordStore
impl Debug for PasswordStore
Auto Trait Implementations§
impl Freeze for PasswordStore
impl RefUnwindSafe for PasswordStore
impl Send for PasswordStore
impl Sync for PasswordStore
impl Unpin for PasswordStore
impl UnsafeUnpin for PasswordStore
impl UnwindSafe for PasswordStore
Blanket Implementations§
impl<T> Allocation for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request