Кирилл Мязин


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;

        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



spawn($socket, sub { ... })

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>


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.