Net::Squid::Auth::Plugin::UserList - A User List-Based Credentials Validation Plugin for L<Net::Squid::Auth::Engine>


Net-Squid-Auth-Plugin-UserList documentation Contained in the Net-Squid-Auth-Plugin-UserList distribution.

Index


Code Index:

NAME

Top

Net::Squid::Auth::Plugin::UserList - A User List-Based Credentials Validation Plugin for Net::Squid::Auth::Engine

VERSION

Top

Version 0.02

SYNOPSIS

Top

If you're a system administrator trying to use Net::Squid::Auth::Engine to validate your user's credentials using a user:password list as credentials repository, do as described here:

On $Config{InstallScript}/squid-auth-engine's configuration file:

    plugin = UserList
    <UserList>
      users = <<EOF
        joe_average:secret
        john_manager:terces
      EOF
    </UserList>

On your Squid HTTP Cache configuration:

    auth_param basic /usr/bin/squid-auth-engine /etc/squid-auth-engine.conf

And you're ready to use this module.

If you're a developer, you might be interested in reading through the source code of this module, in order to learn about it's internals and how it works. It may give you ideas about how to implement other plugin modules for Net::Squid::Auth::Engine.

FUNCTIONS

Top

new( $config_hash )

Constructor. Expects a hash reference with all the configuration under the section <UserList> in the $Config{InstallScript}/squid-auth-engine as parameter. Returns a plugin instance.

initialize()

Initialization function. Gets a user list from the 'users' parameter in the configuration hash passed in to new() and parses it using "\n" as user record split and ":" as user / password separator inside of every record. Returns nothing, as specified by the plugin interface.

is_valid( $username, $password )

This is the credential validation interface. It expects a username and password as parameters and returns a boolean indicating if the credentials are valid (i.e., are listed in the configuration file) or not.

OTHER IMPLEMENTATIONS

Top

Net::Squid::Auth::Plugin::SimpleLDAP

A simple LDAP-based credentials validation plugin for Net::Squid::Auth::Engine.

AUTHOR

Top

Luis Motta Campos, <lmc at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-net-squid-auth-plugin-userlist at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Squid-Auth-Plugin-UserList. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

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

    perldoc Net::Squid::Auth::Plugin::UserList




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Squid-Auth-Plugin-UserList

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Net-Squid-Auth-Plugin-UserList

* CPAN Ratings

http://cpanratings.perl.org/d/Net-Squid-Auth-Plugin-UserList

* Search CPAN

http://search.cpan.org/dist/Net-Squid-Auth-Plugin-UserList

COPYRIGHT & LICENSE

Top


Net-Squid-Auth-Plugin-UserList documentation Contained in the Net-Squid-Auth-Plugin-UserList distribution.
package Net::Squid::Auth::Plugin::UserList;

use warnings;
use strict;

our $VERSION = 0.02;

sub new {
    my ( $class, $config ) = @_;
    return unless UNIVERSAL::isa( $config, 'HASH' );
    return bless { _config => $config }, $class;
}

sub initialize {
    my $self = shift;
    my @users = split "\n", $self->{_config}{users};
    foreach my $record (@users) {
        my ( $username, $password ) = split ':', $record;
        $self->{_usermap}{$username} = $password;
    }
    return;
}

sub is_valid {
    my ( $self, $username, $password ) = @_;
    return 0 unless exists $self->{_usermap}{$username};
    no warnings;
    return $self->{_usermap}{$username} eq $password;
}

1;    # End of Net::Squid::Auth::Plugin::UserList