Authenticator

Trait Authenticator 

Source
pub trait Authenticator {
    // Required method
    fn authenticate(&self, username: &str, password: &str) -> Result<bool, ()>;
}
Expand description

Defines the common interface that can be implemented for a multitude of authentication backends, e.g. LDAP or PAM. It is used by Server to authenticate users.

You can define your own implementation to integrate the FTP server with whatever authentication mechanism you need. For example, to define an Authenticator that will randomly decide:

use rand::prelude::*;
use firetrap::auth::Authenticator;

struct RandomAuthenticator;

impl Authenticator for RandomAuthenticator {
    fn authenticate(&self, _username: &str, _password: &str) -> Result<bool, ()> {
        Ok(rand::random())
    }
}

Required Methods§

Source

fn authenticate(&self, username: &str, password: &str) -> Result<bool, ()>

Authenticate the given user with the given password.

Implementors§