1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/// 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:
///
/// ```rust
/// # extern crate rand;
/// # extern crate firetrap;
/// 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())
/// }
/// }
/// ```
/// [`Server`]: ../server/struct.Server.html
/// [`Authenticator`] implementation that authenticates against [`PAM`].
///
/// [`Authenticator`]: trait.Authenticator.html
/// [`PAM`]: https://en.wikipedia.org/wiki/Pluggable_authentication_module
/// Authenticator implementation that simply allows everyone.
///
/// # Example
///
/// ```rust
/// use firetrap::auth::{Authenticator, AnonymousAuthenticator};
///
/// let my_auth = AnonymousAuthenticator{};
/// assert_eq!(my_auth.authenticate("Finn", "I ❤️ PB").unwrap(), true);
/// ```
;