Apache-AuthDigest
view release on metacpan or search on metacpan
contrib/AuthDigestDBI.pm view on Meta::CPAN
'Auth_DBI_uidcasesensitive' => 'on',
'Auth_DBI_pwdcasesensitive' => 'on',
'Auth_DBI_placeholder' => 'off',
);
# stores the configuration of current URL.
# initialized during authentication, eventually re-used for authorization.
my $Attr = { };
# global cache: all records are put into one string.
# record separator is a newline. Field separator is $;.
# every record is a list of id, time of last access, password, groups (authorization only).
# the id is a comma separated list of user_id, data_source, pwd_table, uid_field.
# the first record is a timestamp, which indicates the last run of the CleanupHandler followed by the child counter.
my $Cache = time . "$;0\n";
# unique id which serves as key in $Cache.
# the id is generated during authentication and re-used for authorization.
my $ID;
contrib/AuthDigestDBI.pm view on Meta::CPAN
# sets CleanupTime to a user defined value.
sub setCleanupTime {
my $class = shift;
my $cleanup_time = shift;
# sanity check
$CleanupTime = $cleanup_time if ($cleanup_time =~ /\-*\d+/);
}
# optionally the string with the global cache can be stored in a shared memory segment.
# the segment will be created from the first child and it will be destroyed if the last child exits.
# the reason for not handling everything in the main server is simply, that there is no way to setup
# an ExitHandler which runs in the main server and which would remove the shared memory and the semaphore.
# hence we have to keep track about the number of children, so that the last one can do all the cleanup.
# creating the shared memory in the first child also has the advantage, that we don't have to cope
# with changing the ownership.
# if a shm-function fails, the global cache will automatically fall back to one string per process.
my $SHMKEY = 0; # unique key for shared memory segment and semaphore set
my $SEMID = 0; # id of semaphore set
my $SHMID = 0; # id of shared memory segment
my $SHMSIZE = 50000; # default size of shared memory segment
# shortcuts for semaphores
my $obtain_lock = pack("sss", 0, 0, 0) . pack("sss", 0, 1, 0);
my $release_lock = pack("sss", 0, -1, 0);
contrib/AuthDigestDBI.pm view on Meta::CPAN
#return $res if $res; # e.g. HTTP_UNAUTHORIZED
return AUTH_REQUIRED unless $passwd_sent;
}
# get username
my ($user_sent) = $r->connection->user;
print STDERR "$prefix user sent = >$user_sent<\n" if $Apache::AuthDigestDBI::DEBUG > 1;
# do we use shared memory for the global cache ?
print STDERR "$prefix cache in shared memory, shmid $SHMID, shmsize $SHMSIZE, semid $SEMID \n" if ($SHMID and $Apache::AuthDigestDBI::DEBUG > 1);
# get configuration
while(($key, $val) = each %Config) {
$val = $r->dir_config($key) || $val;
$key =~ s/^Auth_DBI_//;
$Attr->{$key} = $val;
printf STDERR "$prefix Config{ %-16s } = %s\n", $key, $val if $Apache::AuthDigestDBI::DEBUG > 1;
}
( run in 0.425 second using v1.01-cache-2.11-cpan-1d5ca39e368 )