[−][src]Struct pam::Authenticator
Main struct to authenticate a user
You need to create an instance of it to start an authentication process. If you
want a simple password-based authentication, you can use Authenticator::with_password
,
and to the following flow:
use pam_auth::Authenticator; let mut authenticator = Authenticator::with_password("system-auth") .expect("Failed to init PAM client."); // Preset the login & password we will use for authentication authenticator.get_handler().set_credentials("login", "password"); // actually try to authenticate: authenticator.authenticate().expect("Authentication failed!"); // Now that we are authenticated, it's possible to open a sesssion: authenticator.open_session().expect("Failed to open a session!");
If you wish to customise the PAM conversation function, you should rather create your
authenticator with Authenticator::with_handler
, providing a struct implementing the
Converse
trait. You can then mutably access your conversation handler using the
Authenticator::get_handler
method.
By default, the Authenticator
will close any opened session when dropped. If you don't
want this, you can change its close_on_drop
field to False
.
Fields
close_on_drop: bool
Flag indicating whether the Authenticator should close the session on drop
Methods
impl<'a> Authenticator<'a, PasswordConv>
[src]
pub fn with_password(
service: &str
) -> PamResult<Authenticator<'a, PasswordConv>>
[src]
service: &str
) -> PamResult<Authenticator<'a, PasswordConv>>
Create a new Authenticator
with a given service name and a password-based conversation
impl<'a, C: Converse> Authenticator<'a, C>
[src]
pub fn with_handler(
service: &str,
converse: C
) -> PamResult<Authenticator<'a, C>>
[src]
service: &str,
converse: C
) -> PamResult<Authenticator<'a, C>>
Creates a new Authenticator with a given service name and conversation callback
pub fn get_handler(&mut self) -> &mut C
[src]
Access the conversation handler of this Authenticator
pub fn authenticate(&mut self) -> PamResult<()>
[src]
Perform the authentication with the provided credentials
pub fn open_session(&mut self) -> PamResult<()>
[src]
Open a session for a previously authenticated user and initialize the environment appropriately (in PAM and regular enviroment variables).
Trait Implementations
Auto Trait Implementations
impl<'a, C> Send for Authenticator<'a, C> where
C: Send,
C: Send,
impl<'a, C> Sync for Authenticator<'a, C> where
C: Sync,
C: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,