AnyEve...e::Auth(3pm)
π AnyEvent::FTP::Server::Role::Auth β the auth glow-up β¨
okay so bestie, this is a page from the User Contributed Perl Documentation section of the manual, and the whole vibe is: it's AnyEvent::FTP::Server::Role::Auth(3pm), a role that handles the "who even are you" part of an FTP server. Let's get into it π
πΈ VERSION
version 0.20 π
β¨ SYNOPSIS
So in your context, you're gonna do this whole thing:
package AnyEvent::FTP::Server::Context::MyContext;
use Moo;
extends 'AnyEvent::FTP::Server::Context';
with 'AnyEvent::FTP::Server::Role::Auth';
has '+unauthenticated_safe_commands' => (
default => sub { [ qw( USER PASS HELP QUIT FOO ) ] },
);
# this command is deemed safe pre auth by
# unauthenticated_safe_commands
sub cmd_foo
{
my($self, $con, $req) = @_;
$con->send_response(211 => 'Here to stay');
$self->done;
}
# this command can pnly be executed after
# authentication
sub cmd_bar
{
my($self, $con, $req) = @_;
$con->send_response(211 => 'And another thing');
$self->done;
}
Then when you actually create your server object, you go:
use AnyEvent:FTP::Server;
my $server = AnyEvent::FTP::Server->new;
$server->on_connect(sub {
# $con isa AnyEvent::FTP::Server::Connection
my $con = shift;
# $context isa AnyEvent::FTP::Server::Context::MyContext
my $context = $con->context;
# allow login from user 'user' with password 'secret'
$context->authenticator(sub {
my($user, $pass) = @_;
return $user eq 'user' && $pass eq 'secret';
});
# make the client wait 5 seconds if they enter a
# bad username / password
$context->bad_authentication_delay(5);
});
like, that's it. that's the whole setup. you're a server now π
π DESCRIPTION
This role hands you an authentication interface for your AnyEvent::FTP::Server context. it's giving "bouncer at the club door" energy and honestly? iconic.
π¦ ATTRIBUTES
user
The user that the last FTP "USER" command asked for. (note the quotes, they're quotes-quotes.)
authenticated
True if the user has successfully logged in. slay.
authenticator
A sub ref used to check username + password combos. By default all authentication requests are refused. so yeah, default behavior is lowkey a locked door β no cap, you have to set this yourself.
bad_authentication_delay
Number of seconds to wait after a bad login attempt. the "go sit in the corner and think about what you did" timer π
unauthenticated_safe_commands
The list of commands it's safe to execute before the user has authenticated. The default is USER, PASS, HELP and QUIT. everything else has to wait its turn, bestie.
π METHODS
auth_command_check_hook
$context->auth_command_check_hook($connection, $command);
This hook checks that any commands executed by the client before authentication are in the "authenticated_safe_commands" list. (yes, that's the name in the original, we don't touch the lore.)
fr fr β if a pre-auth command isn't on that list, this hook is the one catching it. keep your list tight.
π COMMANDS
USERPASS
those are the commands, that's the list, periodt β¨
π«Ά AUTHOR
Author: Graham Ollis <plicease@cpan.org>
Contributors:
- Ryo Okamoto
- Shlomi Fish
- JosΓ© JoaquΓn Atria
shoutout to the whole squad, we love a collaborative queen π
π COPYRIGHT AND LICENSE
This software is copyright (c) 2017-2022 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's a wrap, bestie π this page was perl v5.40.1, dated 2026-02-16, from the AnyEve...e::Auth(3pm) man page. go forth and authenticate responsibly π π§
π¦ where this page comes from
- ubuntu stonking: libanyevent-ftp-perl 0.20-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms