Struct pam_client::conv_mock::Conversation
source · [−]Expand description
Non-interactive implementation of ConversationHandler
When a PAM module asks for a non-secret string, username
will be returned and when a secret string is asked for,
password
will be returned.
All info and error messages will be recorded in log
.
Limitations
This is enough to handle many authentication flows non-interactively, but
flows with two-factor-authentication and things like
chauthok()
will most definitely fail.
Please also note that UTF-8 encoding is assumed for both username and password, so this handler may fail to authenticate on legacy non-UTF-8 systems when one of the strings contains non-ASCII characters.
Fields
username: String
The username to use
password: String
The password to use
log: Vec<LogEntry>
All received info/error messages
Implementations
sourceimpl Conversation
impl Conversation
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new CLI conversation handler
If username
isn’t manually set to a non-empty
string, it will be automatically set to the Context
s default
username on context initialization.
sourcepub fn with_credentials(
username: impl Into<String>,
password: impl Into<String>
) -> Self
pub fn with_credentials(
username: impl Into<String>,
password: impl Into<String>
) -> Self
Creatse a new CLI conversation handler with preset credentials
sourcepub fn errors(&self) -> impl Iterator<Item = &CString> + FusedIterator
pub fn errors(&self) -> impl Iterator<Item = &CString> + FusedIterator
Lists only errors from the log
sourcepub fn infos(&self) -> impl Iterator<Item = &CString> + FusedIterator
pub fn infos(&self) -> impl Iterator<Item = &CString> + FusedIterator
Lists only info messages from the log
Trait Implementations
sourceimpl Clone for Conversation
impl Clone for Conversation
sourcefn clone(&self) -> Conversation
fn clone(&self) -> Conversation
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 ConversationHandler for Conversation
impl ConversationHandler for Conversation
sourcefn prompt_echo_on(&mut self, _msg: &CStr) -> Result<CString, ErrorCode>
fn prompt_echo_on(&mut self, _msg: &CStr) -> Result<CString, ErrorCode>
Obtains a string whilst echoing text (e.g. username) Read more
sourcefn prompt_echo_off(&mut self, _msg: &CStr) -> Result<CString, ErrorCode>
fn prompt_echo_off(&mut self, _msg: &CStr) -> Result<CString, ErrorCode>
Obtains a string without echoing any text (e.g. password) Read more
sourceimpl Debug for Conversation
impl Debug for Conversation
Auto Trait Implementations
impl RefUnwindSafe for Conversation
impl Send for Conversation
impl Sync for Conversation
impl Unpin for Conversation
impl UnwindSafe for Conversation
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