Struct kanidmd_lib::credential::Credential
source · [−]pub struct Credential { /* private fields */ }
Expand description
This is how we store credentials in the server. An account can have many credentials, and a credential can have many factors. Only successful auth to a credential as a whole unit will succeed. For example: A: Credential { password: aaa } B: Credential { password: bbb, otp: … } In this case, if we selected credential B, and then provided password “aaa” we would deny the auth as the password of B was incorrect. Additionally, while A only needs the “password”, B requires both the password and otp to be valid.
In this way, each Credential provides it’s own password requirements and policy, and requires some metadata to support this such as it’s source and strength etc.
Implementations
sourceimpl Credential
impl Credential
sourcepub fn new_password_only(
policy: &CryptoPolicy,
cleartext: &str
) -> Result<Self, OperationError>
pub fn new_password_only(
policy: &CryptoPolicy,
cleartext: &str
) -> Result<Self, OperationError>
Create a new credential that contains a CredentialType::Password
sourcepub fn new_generatedpassword_only(
policy: &CryptoPolicy,
cleartext: &str
) -> Result<Self, OperationError>
pub fn new_generatedpassword_only(
policy: &CryptoPolicy,
cleartext: &str
) -> Result<Self, OperationError>
Create a new credential that contains a CredentialType::GeneratedPassword
sourcepub fn new_passkey_only(label: String, cred: Passkey) -> Self
pub fn new_passkey_only(label: String, cred: Passkey) -> Self
Create a new credential that contains a CredentialType::Webauthn
sourcepub fn set_password(
&self,
policy: &CryptoPolicy,
cleartext: &str
) -> Result<Self, OperationError>
pub fn set_password(
&self,
policy: &CryptoPolicy,
cleartext: &str
) -> Result<Self, OperationError>
Update the state of the Password on this credential, if a password is present. If possible this will convert the credential to a PasswordMFA in some cases, or fail in others.
sourcepub fn append_securitykey(
&self,
label: String,
cred: SecurityKey
) -> Result<Self, OperationError>
pub fn append_securitykey(
&self,
label: String,
cred: SecurityKey
) -> Result<Self, OperationError>
Extend this credential with another alternate webauthn credential. This is especially
useful for PasswordMfa
where you can have many webauthn credentials and a password
generally so that one is a backup.
sourcepub fn remove_securitykey(&self, label: &str) -> Result<Self, OperationError>
pub fn remove_securitykey(&self, label: &str) -> Result<Self, OperationError>
Remove a webauthn token identified by label
from this Credential.
sourcepub fn update_webauthn_properties(
&self,
auth_result: &AuthenticationResult
) -> Result<Option<Self>, OperationError>
pub fn update_webauthn_properties(
&self,
auth_result: &AuthenticationResult
) -> Result<Option<Self>, OperationError>
After a successful authentication with Webauthn, we need to advance the credentials counter value to prevent certain classes of replay attacks.
sourcepub fn securitykey_ref(
&self
) -> Result<&Map<String, SecurityKey>, OperationError>
pub fn securitykey_ref(
&self
) -> Result<&Map<String, SecurityKey>, OperationError>
Get a reference to the contained webuthn credentials, if any.
pub fn passkey_ref(&self) -> Result<&Map<String, Passkey>, OperationError>
sourcepub fn password_ref(&self) -> Result<&Password, OperationError>
pub fn password_ref(&self) -> Result<&Password, OperationError>
Get a reference to the contained password, if any.
sourcepub fn to_db_valuev1(&self) -> DbCred
pub fn to_db_valuev1(&self) -> DbCred
Extract this credential into it’s Serialisable Database form, ready for persistence.
Trait Implementations
sourceimpl Clone for Credential
impl Clone for Credential
sourcefn clone(&self) -> Credential
fn clone(&self) -> Credential
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Credential
impl Debug for Credential
sourceimpl From<&Credential> for CredentialDetail
impl From<&Credential> for CredentialDetail
sourcefn from(value: &Credential) -> Self
fn from(value: &Credential) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<Credential> for Credential
impl PartialEq<Credential> for Credential
sourcefn eq(&self, other: &Credential) -> bool
fn eq(&self, other: &Credential) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Credential) -> bool
fn ne(&self, other: &Credential) -> bool
This method tests for !=
.
sourceimpl TryFrom<DbCred> for Credential
impl TryFrom<DbCred> for Credential
impl StructuralPartialEq for Credential
Auto Trait Implementations
impl RefUnwindSafe for Credential
impl Send for Credential
impl Sync for Credential
impl Unpin for Credential
impl UnwindSafe for Credential
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more