[][src]Module libunftp::auth

Contains the Authenticator and UserDetails traits that are used by various implementations and also the Server to authenticate users.

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 your FTP(S) server with whatever authentication mechanism you need. For example, to define an Authenticator that will randomly decide:

use rand::prelude::*;
use libunftp::auth::{Authenticator, UserDetail};
use futures::Future;
use async_trait::async_trait;

struct RandomAuthenticator;

#[async_trait]
impl Authenticator<RandomUser> for RandomAuthenticator {
    async fn authenticate(&self, _username: &str, _password: &str) -> Result<RandomUser, Box<dyn std::error::Error + Send + Sync>> {
        Ok(RandomUser{})
    }
}

#[derive(Debug)]
struct RandomUser;

impl UserDetail for RandomUser {}

impl std::fmt::Display for RandomUser {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "RandomUser")
    }
}

Re-exports

pub use anonymous::AnonymousAuthenticator;

Modules

anonymous

This module provides an anonymous authenticator

Structs

DefaultUser

DefaultUser is a default implementation of the UserDetail trait that doesn't hold any user information. Having a default implementation like this allows for quicker prototyping with libunftp because otherwise the library user would have to implement the UserDetail trait first.

Traits

Authenticator

Defines the requirements for Authentication implementations

UserDetail

UserDetail defines the requirements for implementations that hold Security Subject information for use by the server.