POE::Component::SASLAuthd - Implement the Cyrus SASL authdaemond daemon.
Version 0.04
The authdaemond provides authenticaiton services for various network services. Cyrus IMAP server, Exim, Postfix and probably several other products support authentication via the authdaemon interface.
A simple authentication daemon is provided below as an example:
use strict; use POE::Session; use POE::Wheel::SocketFactory; use Socket; use POE::Component::SASLAuthd; POE::Session->create( inline_states => { _start => sub { my ($kernel, $heap) = @_[KERNEL, HEAP]; my $sock = '/var/state/saslauthd/mux'; unlink $sock if -e $sock; $heap->{'server'} = POE::Wheel::SocketFactory->new( BindAddress => $sock, SocketDomain => AF_UNIX, SocketType => SOCK_STREAM, SuccessEvent => 'handle_accept', FailureEvent => 'handle_error', ); chmod 0777, $sock; }, _stop => sub { my ($kernel, $heap) = @_[KERNEL, HEAP]; warn "stop! ($heap->{'server'})\n" }, handle_accept => sub { my ($kernel, $heap, $handle) = @_[KERNEL, HEAP, ARG0]; POE::Component::SASLAuthd->spawn($handle, sub { my $username = shift; my $password = shift; my $service = shift; my $realm = shift; return 0 if $password eq 'snakk'; return 1 if $username eq 'snik'; return 0; }); }, handle_error => sub { ### do something } } ); POE::Kernel->run();
This is a class method, invoked as
POE::Component::SASLAuthd->spawn($handle, $code)
This method accepts two arguments - the first one is the socket handle that cares the connection to the client, the second one is a code reference that performs the authentication itself. The code is called with following arguments
$username, $password, $service, $realm
The authentication will be allowed if the code returns true and denied otherwise.
Kirill Miazine, <km@krot.org>
<km@krot.org>
You can find documentation for this module with the perldoc command.
perldoc POE::Component::SASLAuthd
You can also look for information at:
Copyright 2008 Kirill Miazine, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install POE::Component::SASLAuthd, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::SASLAuthd
CPAN shell
perl -MCPAN -e shell install POE::Component::SASLAuthd
For more information on module installation, please visit the detailed CPAN module installation guide.