Apache2-AuthCookieDBImg
view release on metacpan or search on metacpan
REQUIRES
Apache::DBI
Apache2::AuthCookie
Apache2::Const
Apache2::ServerUtil
Date::Calc
Digest::MD5
Apache2::Session (if using sessions)
Cipher::CBC (if using CBC Ciphers)
INSTALLATION
perl Makefile.PL
make
make test
make install
EXPORT
None by default.
lib/Apache2/AuthCookieDBImg.pm view on Meta::CPAN
use Apache2::AuthCookie;
use vars qw( @ISA );
@ISA = qw( Apache2::AuthCookie );
use Apache2::RequestRec;
use Apache::DBI;
use Apache2::Const -compile => qw( OK HTTP_FORBIDDEN );
use Apache2::ServerUtil;
use Digest::MD5 qw( md5_hex );
use Date::Calc qw( Today_and_Now Add_Delta_DHMS );
# Also uses Crypt::CBC if you're using encrypted cookies.
# Also uses Apache2::Session if you're using sessions.
#===============================================================================
# F U N C T I O N D E C L A R A T I O N S
#===============================================================================
sub _log_not_set($$);
sub _dir_config_var($$);
sub _dbi_config_vars($);
sub _now_year_month_day_hour_minute_second();
lib/Apache2/AuthCookieDBImg.pm view on Meta::CPAN
sub extra_session_info($$\@);
sub authen_cred($$\@);
sub authen_ses_key($$$);
sub group($$\@);
#===============================================================================
# P A C K A G E G L O B A L S
#===============================================================================
use vars qw( %CIPHERS );
# Stores Cipher::CBC objects in $CIPHERS{ idea:AuthName },
# $CIPHERS{ des:AuthName } etc.
our @Extra_Data; # CSA Patch - needed for keeping cookie active
#===============================================================================
# P R I V A T E F U N C T I O N S
#===============================================================================
#-------------------------------------------------------------------------------
# _log_not_set -- Log that a particular authentication variable was not set.
lib/Apache2/AuthCookieDBImg.pm view on Meta::CPAN
$c{ DBI_imgtable } = _dir_config_var( $r, 'DBI_ImgTable' ) || '';
$c{ DBI_imgkeyfield } = _dir_config_var( $r, 'DBI_ImgKeyField' ) || '';
$c{ DBI_imgwordfield } = _dir_config_var( $r, 'DBI_ImgWordField' ) || '';
$c{ DBI_encryptiontype } = _dir_config_var( $r, 'DBI_EncryptionType' ) || 'none';
$c{ DBI_sessionlifetime} = _dir_config_var( $r, 'DBI_SessionLifetime') || '00-24-00-00';
$c{ DBI_sessionmodule } = _dir_config_var( $r, 'DBI_SessionModule' );
$c{ DBI_SessionActiveReset } = _dir_config_var( $r, 'DBI_SessionActiveReset' ) || 0;
return %c;
# If we used encryption we need to pull in Crypt::CBC.
require Crypt::CBC if ( $c{ DBI_encryptiontype } ne 'none' );
return %c;
}
#-------------------------------------------------------------------------------
# _now_year_month_day_hour_minute_second -- Return a string with the time in
# this order separated by dashes.
sub _now_year_month_day_hour_minute_second()
{
lib/Apache2/AuthCookieDBImg.pm view on Meta::CPAN
unless ( $encrypted_session_key =~ /^[0-9a-fA-F]+$/ ) {
$r->log_error( "Apache2::AuthCookieDBImg: encrypted session key $encrypted_session_key doesn't look like it's properly hex-encoded for auth realm $auth_name", $r->uri );
return undef;
}
# Get the cipher from the cache, or create a new one if the
# cached cipher hasn't been created, & decrypt the session key.
my $cipher;
if ( lc $c{ DBI_encryptiontype } eq 'des' ) {
$cipher = $CIPHERS{ "des:$auth_name" }
||= Crypt::CBC->new( $secretkey, 'DES' );
} elsif ( lc $c{ DBI_encryptiontype } eq 'idea' ) {
$cipher = $CIPHERS{ "idea:$auth_name" }
||= Crypt::CBC->new( $secretkey, 'IDEA' );
} elsif ( lc $c{ DBI_encryptiontype } eq 'blowfish' ) {
$cipher = $CIPHERS{ "blowfish:$auth_name" }
||= Crypt::CBC->new( $secretkey, 'Blowfish' );
} elsif ( lc $c{ DBI_encryptiontype } eq 'blowfish_pp' ) {
$cipher = $CIPHERS{ "blowfish_pp:$auth_name" }
||= Crypt::CBC->new( $secretkey, 'Blowfish_PP' );
} else {
$r->log_error( "Apache2::AuthCookieDBImg: unknown encryption type $c{ DBI_encryptiontype } for auth realm $auth_name", $r->uri );
return undef;
}
$session_key = $cipher->decrypt_hex( $encrypted_session_key );
}
# Break up the session key.
my( $enc_user, $issue_time, $expire_time, $session_id,
$supplied_hash, @rest ) = split /:/, $session_key;
lib/Apache2/AuthCookieDBImg.pm view on Meta::CPAN
# Now we add this hash to the end of the public part.
my $session_key = "$public_part:$hash";
# Now we encrypt this and return it.
my $encrypted_session_key;
if ( $c{ DBI_encryptiontype } eq 'none' ) {
$encrypted_session_key = $session_key;
} elsif ( lc $c{ DBI_encryptiontype } eq 'des' ) {
$CIPHERS{ "des:$auth_name" }
||= Crypt::CBC->new( $secretkey, 'DES' );
$encrypted_session_key = $CIPHERS{
"des:$auth_name"
}->encrypt_hex( $session_key );
} elsif ( lc $c{ DBI_encryptiontype } eq 'idea' ) {
$CIPHERS{ "idea:$auth_name" }
||= Crypt::CBC->new( $secretkey, 'IDEA' );
$encrypted_session_key = $CIPHERS{
"idea:$auth_name"
}->encrypt_hex( $session_key );
} elsif ( lc $c{ DBI_encryptiontype } eq 'blowfish' ) {
$CIPHERS{ "blowfish:$auth_name" }
||= Crypt::CBC->new( $secretkey, 'Blowfish' );
$encrypted_session_key = $CIPHERS{
"blowfish:$auth_name"
}->encrypt_hex( $session_key );
}
return $encrypted_session_key;
}
#-------------------------------------------------------------------------------
lib/Apache2/AuthCookieDBImg.pm view on Meta::CPAN
=head1 REQUIRES
Apache::DBI
Apache2::AuthCookie
Apache2::Const
Apache2::ServerUtil
Date::Calc
Digest::MD5
Apache2::Session (if using sessions)
Cipher::CBC (if using CBC Ciphers)
=head1 SEE ALSO
Latest version: http://search.cpan.org/search?query=Apache%3A%3AAuthCookieDBImg&mode=all
Apache2::AuthCookieDBI(1)
Apache2::AuthCookie(1)
Apache2::Session(1)
( run in 1.200 second using v1.01-cache-2.11-cpan-e1769b4cff6 )