Authen::Simple - Simple Authentication


Authen-Simple documentation Contained in the Authen-Simple distribution.

Index


Code Index:

NAME

Top

Authen::Simple - Simple Authentication

SYNOPSIS

Top

    use Authen::Simple;
    use Authen::Simple::Kerberos;
    use Authen::Simple::SMB;

    my $simple = Authen::Simple->new(
        Authen::Simple::Kerberos->new( realm => 'REALM.COMPANY.COM' ),
        Authen::Simple::SMB->new( domain => 'DOMAIN', pdc => 'PDC' )
    );

    if ( $simple->authenticate( $username, $password ) ) {
        # successfull authentication
    }

DESCRIPTION

Top

Simple and consistent framework for authentication.

METHODS

Top

* new

This method takes an array of Authen::Simple adapters. Required.

* authenticate( $username, $password )

Returns true on success and false on failure.

SEE ALSO

Top

Authen::Simple::ActiveDirectory.

Authen::Simple::CDBI.

Authen::Simple::DBI.

Authen::Simple::FTP.

Authen::Simple::HTTP.

Authen::Simple::Kerberos.

Authen::Simple::LDAP.

Authen::Simple::NIS.

Authen::Simple::PAM.

Authen::Simple::Passwd.

Authen::Simple::POP3.

Authen::Simple::RADIUS.

Authen::Simple::SMB.

Authen::Simple::SMTP.

Authen::Simple::SSH.

AUTHOR

Top

Christian Hansen ch@ngmedia.com

COPYRIGHT

Top


Authen-Simple documentation Contained in the Authen-Simple distribution.

package Authen::Simple;

use strict;
use warnings;

use Params::Validate qw[];

our $VERSION = 0.4;

sub new {
    my $class = shift;

    my %adapter = (
        isa      => 'Authen::Simple::Adapter',
        type     => Params::Validate::OBJECT,
        optional => 1
    );

    my @spec     = ( { %adapter, optional => 0 }, ( \%adapter ) x @_ );
    my $adapters = Params::Validate::validate_pos( @_, @spec );

    return bless( $adapters, $class );
}

sub authenticate {
    my ( $self, $username, $password ) = @_;

    foreach ( $username, $password ) {
        return 0 unless defined($_) && !ref($_) && length($_);
    }

    foreach my $adapter ( @{$self} ) {
        return 1 if $adapter->authenticate( $username, $password );
    }

    return 0;
}

1;

__END__