Skip to main content

AuthenticationError

Enum AuthenticationError 

Source
pub enum AuthenticationError {
    EmptyPassword,
    EmptyUsername,
    NoSuchUser,
    InvalidPassword,
    Ambiguous {
        matched: usize,
    },
    AccountUnusable {
        reason: AccountProblem,
        diagnostic: String,
    },
    Unreachable(Error),
    ServiceAccount(Error),
    Directory(LdapResult),
}
Expand description

Why an authentication attempt did not succeed.

Every variant is distinguishable so that a log can say what happened. Not every variant may be shown to the person logging in — see AuthenticationError::is_credential_failure.

Variants§

§

EmptyPassword

The password field was empty.

Its own variant rather than an InvalidPassword, because this one never touched the network: LDAP would have answered it with success, and this is the client refusing to ask.

§

EmptyUsername

The username field was empty, or held a NUL.

§

NoSuchUser

The search found nobody.

§

InvalidPassword

The entry exists and the password is wrong.

§

Ambiguous

More than one entry has that username. Refused rather than resolved: picking one means picking somebody arbitrary to log in as.

Fields

§matched: usize
§

AccountUnusable

The password may well be right, but a policy says no.

Fields

§diagnostic: String
§

Unreachable(Error)

The directory could not be reached, or the connection failed part way.

§

ServiceAccount(Error)

The client’s own service account could not bind. Not the user’s problem, and worth paging somebody about.

§

Directory(LdapResult)

The directory refused for a reason this package does not model.

Implementations§

Source§

impl AuthenticationError

Source

pub fn is_credential_failure(&self) -> bool

Whether this is “the credentials were wrong” in any of its forms.

Show one identical message for every case where this is true. A form that distinguishes “no such user” from “wrong password” tells an attacker which usernames are real, one guess at a time — and it does it for free, at any rate they like.

Everything this returns false for is an operational problem, and saying “we could not reach the directory” for those is both honest and safe.

Source

pub fn is_directory_failure(&self) -> bool

Whether the directory itself is at fault rather than the credentials.

Trait Implementations§

Source§

impl Debug for AuthenticationError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for AuthenticationError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for AuthenticationError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<AuthenticationError> for Error

Source§

fn from(error: AuthenticationError) -> Error

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.