ClearPress
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
cgi-bin/login view on Meta::CPAN
);
$decor->username(q[]);
print qq[Set-Cookie: $cookie\n];
print $decor->header();
print login_form($decor);
print $decor->footer();
return 1;
}
my $authenticator = ClearPress::authenticator::passwd->new();
my $user_info = $authenticator->authen_credentials({
username => $username,
password => $password,
});
if($user_info) {
$decor->username($username);
my $session = ClearPress::authenticator::session->new();
my $encoded = $session->encode_token($user_info);
my $auth_cookie = $cgi->cookie(
lib/ClearPress/authenticator/db.pm view on Meta::CPAN
$self->{cipher} = $v;
}
if($self->{cipher}) {
return $self->{cipher};
}
return $DEFAULT_CIPHER;
}
sub authen_credentials {
my ($self, $ref) = @_;
if(!$ref ||
!$ref->{username} ||
!$ref->{password} ) {
return;
}
my $dbh = $self->dbh();
my $table = $self->table;
t/authenticator/db.t view on Meta::CPAN
# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*-
# vim:ts=8:sw=2:et:sta:sts=2
use strict;
use warnings;
use Test::More tests => 7;
use lib qw(t/lib);
use t::util;
our $PKG = 'ClearPress::authenticator::db';
use_ok($PKG);
can_ok($PKG, qw(new authen_credentials));
my $util = t::util->new();
{
my $auth = $PKG->new();
isa_ok($auth, $PKG);
isa_ok($auth, 'ClearPress::authenticator');
}
{
my $auth = $PKG->new();
is($auth->authen_credentials(), undef, 'no creds');
}
{
my $auth = $PKG->new();
is($auth->authen_credentials({username => 'dummy'}), undef, 'no password');
}
{
my $auth = $PKG->new();
is($auth->authen_credentials({password => 'dummy'}), undef, 'no username');
}
t/authenticator/ldap.t view on Meta::CPAN
{
my $ldap = $PKG->new();
my $connector = $ldap->_ldap();
is_deeply($connector->{constructor_args}, [qw(ldaps://ldap.local:636)], 'connector construction');
is_deeply($ldap->_ldap(), $connector, 'cached connector');
}
{
my $ldap = $PKG->new;
is($ldap->authen_credentials(), undef, 'auth no args');
is($ldap->authen_credentials({username => 'bob'}), undef, 'auth no password');
is($ldap->authen_credentials({password => 'passw0rd'}), undef, 'auth no username');
}
{
no warnings qw(once);
my $ldap = $PKG->new;
eval {
local $Net::LDAP::CONSTRUCTOR_FAIL = 1;
$ldap->authen_credentials({username => 'bob', password => 'pass'});
};
like($EVAL_ERROR, qr/Failed[ ]to[ ]connect/smx, 'ldap connection failure');
}
{
my $ref = {
username => 'bob',
password => 'pass',
};
my $ldap = $PKG->new;
my $state;
eval {
local $Net::LDAP::BIND_CODE = undef;
local $Net::LDAP::BIND_ERROR = 'no bind error';
$state = $ldap->authen_credentials($ref);
};
unlike($EVAL_ERROR, qr/Failed[ ]to[ ]connect/smx, 'no ldap connection failure');
is_deeply($state, $ref, 'authentication pass');
}
{
my $ref = {
username => 'bob',
password => 'pass',
};
my $ldap = $PKG->new;
my $cap = IO::Capture::Stderr->new;
$cap->start;
my $state;
eval {
local $Net::LDAP::BIND_CODE = 1;
local $Net::LDAP::BIND_ERROR = 'bind error number 1';
$state = $ldap->authen_credentials($ref);
};
$cap->stop;
is($state, undef, 'authentication fail');
}
t/authenticator/passwd.t view on Meta::CPAN
if($name eq 'dummyuser') {
return qw(dummyuser du2M/eJoAA/Ak 1809244410 1139001599 0 Roger Pettett /Users/rpettett /bin/bash 0);
}
return ();
};
}
our $PKG = 'ClearPress::authenticator::passwd';
use_ok($PKG);
can_ok($PKG, qw(new authen_credentials));
{
my $auth = $PKG->new();
isa_ok($auth, $PKG);
isa_ok($auth, 'ClearPress::authenticator');
}
{
my $auth = $PKG->new();
is($auth->authen_credentials(), undef, 'no creds');
}
{
my $auth = $PKG->new();
is($auth->authen_credentials({username => 'dummy'}), undef, 'no password');
}
{
my $auth = $PKG->new();
is($auth->authen_credentials({password => 'dummy'}), undef, 'no username');
}
{
my $auth = $PKG->new();
is($auth->authen_credentials({
username => 'missing',
password => 'something',
}), undef, 'unknown user');
}
{
my $auth = $PKG->new();
my $ref = {
username => 'dummyuser',
password => 'dummypass',
};
my $result = $auth->authen_credentials($ref);
is_deeply($result, undef, 'valid user, bad password');
}
{
my $auth = $PKG->new();
my $ref = {
username => 'dummyuser',
password => 'dummy',
};
my $result = $auth->authen_credentials($ref);
is_deeply($result, $ref, 'valid user');
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.419 second using v1.00-cache-2.02-grep-82fe00e-cpan-fdf144b69116 )