#ftp #authorization #libunftp #storage #wrapper #unftp #back-end

unftp-sbe-restrict

A libunftp wrapper storage back-end that restricts FTP operations

3 releases

0.1.2 May 18, 2024
0.1.1 Sep 17, 2023
0.1.0 Sep 13, 2023

#921 in Network programming

Download history 17/week @ 2024-06-30 30/week @ 2024-07-07 2/week @ 2024-07-14 7/week @ 2024-07-28 1/week @ 2024-08-04 13/week @ 2024-08-11 22/week @ 2024-08-18 14/week @ 2024-08-25 28/week @ 2024-09-01 4/week @ 2024-09-08 16/week @ 2024-09-15 37/week @ 2024-09-22 18/week @ 2024-09-29 17/week @ 2024-10-06 9/week @ 2024-10-13

82 downloads per month
Used in unftp

Apache-2.0

13KB
225 lines

unftp-sbe-restrict

Crate Version API Docs Crate License Follow on Telegram

A libunftp wrapper storage back-end that restricts FTP operations and in so doing provide some form of authorization. See the docs to get started.


lib.rs:

A libunftp wrapper storage back-end that restricts FTP operations and in so doing provide some form of authorization.

Quick start

Start by implementing the libunftp UserDetail trait and then follow that by implementing UserWithPermissions.

Finally call the RestrictingVfs::new() method.

use libunftp::auth::UserDetail;
use unftp_sbe_restrict::{UserWithPermissions, VfsOperations};
use std::fmt::Formatter;

#[derive(Debug, PartialEq, Eq)]
pub struct User {
    pub username: String,
    // e.g. this can be something like
    // `VfsOperations::all() - VfsOperations::PUT - VfsOperations::DEL`
    pub permissions: VfsOperations,
}

impl UserDetail for User {
    fn account_enabled(&self) -> bool {
        true
    }
}

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

impl UserWithPermissions for User {
    fn permissions(&self) -> VfsOperations {
        self.permissions
    }
}

// Return type omited for brevity.
fn create_restricted_storage_backend() {
    use unftp_sbe_fs::{Filesystem, Meta};
    let _backend = Box::new(move || {
        unftp_sbe_restrict::RestrictingVfs::<Filesystem, User, Meta>::new(Filesystem::new("/srv/ftp"))
    });
}

Dependencies

~21–31MB
~576K SLoC