Authen-Challenge-Basic
view release on metacpan or search on metacpan
=head1 NAME
Authen::Challenge::Basic - A Basic challenge/response authentication scheme.
=head1 SYNOPSIS
use Authen::Challenge::Basic;
$server = Authen::Challenge->new ('Secret' => 'known2us',
'Timeout' => 30,
'Sync' => 10);
$client = Authen::Challenge->new ('Secret' => 'known2us',
'Timeout' => 30,
'Sync' => 10);
$challenge = $server->Challenge;
$response = $client->Response($challenge);
if ($server->Validate($challenge, $response)) {
print "Hi master\n";
}
else {
print "Impostor!\n";
secret.
The following functions are provided by this class.
new()
Creates a new instance of a challenge/response endpoint. It has three
parameters that influence its behavior. Those can be seen next
$server = Authen::Challenge::Basic->new ('Secret' => 'known2us',
'Timeout' => 30,
'Sync' => 10);
'Secret' is used to indicate the shared secret to use in this session.
'Timeout' specifies the lifespan, in seconds, for this transaction.
This means that a succesful Validate() must occur within this many
seconds to have a chance to be acknowledged. Reducing this value
too much can cause problems as a slight ammount of load can make the
session fail. 30 seconds is a reasonable default for many uses. If
left unspecified, no timeout is enforced.
'Sync' indicates how strict are we with regard to the clock in our
peer. The parameter contains the maximum offset in seconds between the
clocks of the peers. The more strict we are (ie, the smaller the number),
the less tolerant we are. If left unspecified, we'll allow any ammount
use Authen::Challenge::Basic;
$|=1;
print "1..2\n";
$server = Authen::Challenge::Basic->new ('Secret' => 'tanganyika',
'Timeout' => 20,
'Sync' => 10);
$client = Authen::Challenge::Basic->new ('Secret' => 'tanganyika',
'Timeout' => 20,
'Sync' => 10);
$c = $server->Challenge;
$r = $client->Response($c);
if ($server->Validate($c, $r)) {
print "ok 1\n";
}
else
( run in 0.253 second using v1.01-cache-2.11-cpan-4d50c553e7e )