Ben Kennedy wrote:
> Modified to:
> 
> '^Received: from .*\s+\(.*\)\s+\((.* )?AUTH\:\ '

This is how Courier::Message[1] from Courier::Filter does it:

sub authenticated {
    my ($message) = @_;

    return $message->{authenticated}
        if defined($message->{authenticated});

    TRY: {
        # Get first "Received" header (and only the first!):
        my $received = $message->header('received');

        last TRY if not defined($received);
        last TRY if not $received =~ /^from\s+\S+\s+\(.*?\)\s+\((.*?)\)\s+by/i;
                                     # from   HELO  (HOST+IP)  (PARAMS)   by ...
        my %params = map(
            /^([\w-]+):\s*(.*)$/ ? (lc($1) => $2) : (),
            split(/,\s+/, $1)
        );

        return $message->{authenticated} = $params{auth}
            # Authenticated!
            if defined($params{auth});
    }

    return $message->{authenticated} = '';
        # Not authenticated.
}

I guess this is as generic as it gets.

> What would make this cleaner and funkier would be to have the
> authentication details available in an environment variable.

A courierfilter runs as a continuous process, and as such does have a
static environment.  The right way to pass the authentication information
to courierfilters would be in the message control file, but Courier does
not support that at the moment.

References:
 1. http://search.cpan.org/dist/Courier-Filter/lib/Courier/Message.pm



-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to