Кирилл Мязин > POE-Component-SASLAuthd-0.03 > POE::Component::SASLAuthd

Download:
POE-Component-SASLAuthd-0.03.tgz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

POE::Component::SASLAuthd - Implement the Cyrus SASL authdaemond daemon.

VERSION ^

Version 0.03

SYNOPSIS ^

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();

METHODS ^

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.

AUTHOR ^

Kirill Miazine, <km@krot.org>

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc POE::Component::SASLAuthd

You can also look for information at:

COPYRIGHT & LICENSE ^

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.

syntax highlighting: