[][src]Struct pam::Authenticator

pub struct Authenticator<'a, C: Converse> {
    pub close_on_drop: bool,
    // some fields omitted
}

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]

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]

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

impl<'a, C: Converse> Drop for Authenticator<'a, C>[src]

Auto Trait Implementations

impl<'a, C> Send for Authenticator<'a, C> where
    C: Send

impl<'a, C> Sync for Authenticator<'a, C> where
    C: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]