pub struct DelegatingPasswordEncoder { /* private fields */ }Expand description
Delegating password encoder that supports multiple encoding formats.
§Spring Security Equivalent
DelegatingPasswordEncoder
This encoder can verify passwords encoded with different algorithms by detecting the encoding format from a prefix in the stored hash.
Supported formats:
{argon2}hash- Argon2 encoded password{bcrypt}hash- BCrypt encoded password{noop}plain- Plain text (for testing only!)
§Feature Flag
Requires the argon2 feature (enabled by default).
§Example
use actix_security_core::http::security::crypto::{PasswordEncoder, DelegatingPasswordEncoder};
let encoder = DelegatingPasswordEncoder::new();
// Encode with default (argon2)
let hash = encoder.encode("password");
assert!(hash.starts_with("{argon2}"));
// Can verify both formats
assert!(encoder.matches("password", &hash));
assert!(encoder.matches("plain", "{noop}plain"));Implementations§
Source§impl DelegatingPasswordEncoder
impl DelegatingPasswordEncoder
Sourcepub fn new() -> DelegatingPasswordEncoder
pub fn new() -> DelegatingPasswordEncoder
Creates a new delegating password encoder. Default encoding is Argon2.
Sourcepub fn default_encoder(
self,
encoder: DefaultEncoder,
) -> DelegatingPasswordEncoder
pub fn default_encoder( self, encoder: DefaultEncoder, ) -> DelegatingPasswordEncoder
Set the default encoder to use for new passwords.
Sourcepub fn use_bcrypt(self) -> DelegatingPasswordEncoder
pub fn use_bcrypt(self) -> DelegatingPasswordEncoder
Use BCrypt as the default encoder.
Trait Implementations§
Source§impl Clone for DelegatingPasswordEncoder
impl Clone for DelegatingPasswordEncoder
Source§fn clone(&self) -> DelegatingPasswordEncoder
fn clone(&self) -> DelegatingPasswordEncoder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for DelegatingPasswordEncoder
Available on crate feature argon2 only.
impl Default for DelegatingPasswordEncoder
Available on crate feature
argon2 only.Source§fn default() -> DelegatingPasswordEncoder
fn default() -> DelegatingPasswordEncoder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DelegatingPasswordEncoder
impl RefUnwindSafe for DelegatingPasswordEncoder
impl Send for DelegatingPasswordEncoder
impl Sync for DelegatingPasswordEncoder
impl Unpin for DelegatingPasswordEncoder
impl UnwindSafe for DelegatingPasswordEncoder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more