How to write a custom Squid authenticator

An authenticator that you can use in Squid is pretty simple. So if you find you need to use an authentication scheme that is not yet supported you can pretty easily write one yourself. All you need is some basic knowledge of scripting languages (bash, Perl, Python, whatever).

The authentication requests are passed to the external authenticator like this:

This is an example framework for an authenticator in Perl:

#!/usr/bin/perl -w

use strict;

while (<STDIN>)
{
        chomp;
        my ($username, $password) = split;
        &authenticate($username, $password);
}

sub authenticate
{
        my ($username, $password) = @_;
        if (...)        # authentication ok
        {
                print "OK\n";
        }
        else    # authentication failed
        {
                print "ERR\n";
        }
}

Of course you need to add your own authentication mechanism in the &authenticate sub where the "..." are.

Christoph Haas

WorkaroundOrg: WritingSquidAuthenticators (last edited 2005-06-26 18:40:55 by ChristophHaas)