Apache-AuthTicket
view release on metacpan or search on metacpan
lib/Apache/AuthTicket/Base.pm view on Meta::CPAN
my ($class, $auth_name, $conf) = @_;
$class->push_handler(PerlChildInitHandler => sub {
for (keys %$conf) {
die "bad configuration parameter $_" unless defined $DEFAULTS{$_};
$CONFIG{$auth_name}{$_} = $conf->{$_};
}
});
}
# check credentials and return a session key if valid
# return undef if invalid
sub authen_cred {
my ($class, $r, $user, $pass) = @_;
my $self = $class->new($r);
if ($self->check_credentials($user, $pass)) {
return $self->make_ticket($user);
}
else {
return undef;
}
}
# check a session key, return user id
# return undef if its not valid.
sub authen_ses_key {
lib/Apache/AuthTicket/Base.pm view on Meta::CPAN
my ($db, $user, $pass) = map {
$self->get_config($_)
} qw/TicketDB TicketDBUser TicketDBPassword/;
my $dbh = DBI->connect_cached($db, $user, $pass)
or die "DBI Connect failure: ", DBI->errstr, "\n";
return $dbh;
}
sub check_credentials {
my ($self, $user, $password) = @_;
my ($table, $user_field, $pass_field) = $self->user_table;
my ($stmt, @bind) =
$self->sql->select($table, $pass_field, {$user_field => $user});
my ($db_pass) = eval {
$self->dbh->selectrow_array($stmt, undef, @bind);
};
lib/Apache/AuthTicket/Base.pm view on Meta::CPAN
=head2 dbh
Get the database handle
=head2 dbi_connect
my $dbh = $self->dbi_connect
Returns a new connection to the database
=head2 check_credentials
my $ok = $self->check_credentials($username, $password)
Return C<true> if the credentials are valid
=head2 fetch_secret
my ($value, $version) = $self->fetch_secret;
my ($value) = $self->fetch_secret($version)
Return the secret and version of the secret. if the C<version> argument is
present, return that specific version of the secret instead of the most recent
one.
( run in 0.310 second using v1.01-cache-2.11-cpan-a5abf4f5562 )