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§
source§impl Credential
impl Credential
pub fn try_from_repl_v1( rc: &ReplCredV1 ) -> Result<(String, Self), OperationError>
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 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.
sourcepub fn to_repl_v1(&self, tag: String) -> ReplCredV1
pub fn to_repl_v1(&self, tag: String) -> ReplCredV1
Extract this credential into it’s Serialisable Replication form
Trait Implementations§
source§impl Clone for Credential
impl Clone for Credential
source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Credential
impl Debug for Credential
source§impl From<&Credential> for CredentialDetail
impl From<&Credential> for CredentialDetail
source§fn from(value: &Credential) -> Self
fn from(value: &Credential) -> Self
source§impl PartialEq<Credential> for Credential
impl PartialEq<Credential> for Credential
source§fn eq(&self, other: &Credential) -> bool
fn eq(&self, other: &Credential) -> bool
self
and other
values to be equal, and is used
by ==
.