Authen-Pluggable
view release on metacpan or search on metacpan
an example with two different password files
It always return the object itself.
authen($username, $password, [opt] $providers)
Call all configured providers, or only $providers if configured, and
return the first with a valid authentication.
The structure returned is usually something like this
{ provider => $provider, user => $user, cn => $cn, gid => $gid };
where $provider is the alias of the provider which return the valid
authentication and $cn is the common name of the user.
If no plugins return a valid authentication, this method returns undef.
EXAMPLE FOR CONFIGURING PROVIDERS
There are various methods to select the providers where autenticate and
to configure it. Here some example using chaining.
lib/Authen/Pluggable.pm view on Meta::CPAN
It always return the object itself.
=head2 authen($username, $password, [opt] $providers)
Call all configured providers, or only $providers if configured, and return
the first with a valid authentication.
The structure returned is usually something like this
{ provider => $provider, user => $user, cn => $cn, gid => $gid };
where C<$provider> is the alias of the provider which return the valid
authentication and C<$cn> is the common name of the user.
If no plugins return a valid authentication, this method returns undef.
=head1 EXAMPLE FOR CONFIGURING PROVIDERS
There are various methods to select the providers where autenticate and to configure it.
Here some example using chaining.
lib/Authen/Pluggable/AD.pm view on Meta::CPAN
my $ret = { user => $user };
for ( my $i = 0; $i < $res_count; $i++ ) {
my $entry = $results->entry($i);
foreach my $attr ( $entry->attributes ) {
$ret->{$attr} = $entry->get_value($attr);
}
}
#return { user => $user, cn => $cn, gid => $gid, uid => $uid };
return $ret;
}
sub cfg ( $s, %cfg ) {
if (%cfg) {
while (my ($k, $v) = each %cfg) {
$s->_cfg->{$k} = $v;
}
}
return $s->parent;
lib/Authen/Pluggable/Passwd.pm view on Meta::CPAN
use Authen::Simple::Passwd;
has 'parent' => undef, weak => 1;
has _cfg => sub { return { file => '/etc/passwd' } };
sub authen ( $s, $user, $pass ) {
my $auth = Authen::Simple::Passwd->new( path => $s->_cfg->{file} );
return undef unless $auth->authenticate($user, $pass);
# SU $_ c'è la riga autenticata
my (undef,undef,$uid, $gid, $cn, $home, $shell) = split /:/;
return { user => $user, cn => $cn, gid => $gid, uid => $uid };
}
sub cfg ($s, %cfg) {
if (%cfg) {
while (my ($k, $v) = each %cfg) {
$s->_cfg->{$k} = $v;
}
}
return $s->parent;
( run in 2.487 seconds using v1.01-cache-2.11-cpan-5735350b133 )