Apache-AxKit-Plugin-Session
view release on metacpan or search on metacpan
- better interoperability
- a few new features
0.94
- fix /redirect
- fix login/logout sequence
- added sample login/logout XSP pages
- don't parse input if not neccessary (so a later module can
pass own options, like Apache::AxKit::Plugin::Upload)
- removed dependency on Apache::RequestNotes (no longer
provides $r->pnotes('INPUT'))
0.93
- several bug fixes
- added sample script for cleaning session dirs
- updated for AxKit 1.6.1 (you definitely need it!)
0.92
- fixed timeout bug (sessions didn't time out)
- fixed AxAddPlugin bug (plugin usage didn't work)
lib/Apache/AxKit/Plugin/Session.pm view on Meta::CPAN
# save args of original request so it can be replayed after a redirect
#=====================
sub orig_save_params ($$) {
#---------------------
my ($self, $uri) = @_;
$self->debug(3,"======= save_params(".join(',',@_).")");
my $r = Apache->request();
parse_input(1);
$uri = new URI($uri);
$uri->query_form(%{$r->pnotes('INPUT')||{}});
return $uri->as_string;
}
# ____ End of save_params ____
# restore args of original request in $r->pnotes('INPUT')
#=======================
sub orig_restore_params ($) {
#-----------------------
my ($self) = @_;
$self->debug(3,"======= restore_params(".join(',',@_).")");
my $r = Apache->request();
parse_input();
}
# ____ End of restore_params ____
lib/Apache/AxKit/Plugin/Session.pm view on Meta::CPAN
#================
sub parse_input {
#----------------
my ($full) = @_;
my $or = my $r = Apache->request();
while ($r->prev) {
$r = $r->prev;
$r = $r->main || $r;
}
if ($r->pnotes('INPUT') && $r ne $or) {
$or->pnotes('INPUT',$r->pnotes('INPUT'));
$or->pnotes('UPLOADS',$r->pnotes('UPLOADS'));
$or->pnotes('COOKIES',$r->pnotes('COOKIES'));
$or->pnotes('COOKIES',{}) unless $or->pnotes('COOKIES');
return;
}
my %cookies;
my %cookiejar = Apache::Cookie->new($r)->parse;
foreach (sort keys %cookiejar) {
my $cookie = $cookiejar{$_};
$cookies{$cookie->name} = $cookie->value;
}
$or->pnotes('COOKIES',\%cookies);
$r->pnotes('COOKIES',$or->pnotes('COOKIES')) if ($r ne $or);
# avoid parsing the input so later modules can modify it
return if (!$full);
return if $r->pnotes('INPUT');
# from Apache::RequestNotes
my $maxsize = $r->dir_config('MaxPostSize') || 1024;
my $uploads = $r->dir_config('DisableUploads') =~ m/Off/i ? 0 : 1;
my $apr = Apache::Request->instance($r,
POST_MAX => $maxsize,
DISABLE_UPLOADS => $uploads,
);
$r->pnotes('INPUT',$apr->parms);
$r->pnotes('UPLOADS',[ $apr->upload ]);
if ($r ne $or) {
$or->pnotes('INPUT',$r->pnotes('INPUT'));
$or->pnotes('UPLOADS',$r->pnotes('UPLOADS'));
}
}
# ____ End of parse_input ____
#===========================
sub external_redirect ($$) {
#---------------------------
lib/Apache/AxKit/Plugin/Session.pm view on Meta::CPAN
$self->debug(3,"======= fixup_redirect(".join(',',@_).")");
parse_input(1);
my $mr = $r;
while ($mr->prev) {
$mr = $mr->prev;
$mr = $mr->main || $mr;
}
$mr = $mr->main || $mr;
$r->pnotes('INPUT')->{'url'} = $1 if ($r->uri =~ m{^/[a-z]+(/.*)$});
$r->pnotes('INPUT')->{'url'} =~ s{^/([a-z0-9]+://)}{$1};
if (!$r->header_out('Location') && (!$r->prev || !$r->prev->header_out('Location')) && !$r->pnotes('INPUT')->{'url'}) {
$self->debug(1,'called without location header or url paramater');
return SERVER_ERROR;
}
my $session = $r->notes('SESSION_URLPREFIX') || $mr->notes('SESSION_URLPREFIX') || '';
my $uri;
$uri = Apache::URI->parse($r, $r->header_out('Location') || ($r->prev?$r->prev->header_out('Location'):undef) || $r->pnotes('INPUT')->{'url'});
if (!$uri->hostname) {
$uri->hostname($r->hostname);
$uri->port($r->get_server_port);
}
$self->debug(6,"Session: $session, uri: ".$uri->unparse);
my $same_host = (lc($uri->hostname) eq lc($r->hostname) && ($uri->port||80) == $r->server->port);
# we have not been internally redirected - show the refresh page, or redirect to
# ourselves first, if session id is still present
if ($same_host) {
lib/Apache/AxKit/Plugin/Session.pm view on Meta::CPAN
# In that case, be sure to validate the login in authen_cred above!
#===============
sub login ($$) {
#---------------
my ($self, $r, $destination ) = @_;
$self->debug(3,"======= login(".join(',',@_).")");
my $auth_name = $r->auth_name || 'AxKitSession';
my $auth_type = $r->auth_type || __PACKAGE__;
parse_input(1);
my $args = $r->pnotes('INPUT');
$destination = $$args{'destination'} if @_ < 3;
if ($destination) {
$destination = URI->new_abs($destination, $r->uri);
} else {
my $mr = $r;
$mr = $mr->prev while ($mr->prev);
$mr = $mr->main while ($mr->main);
$destination = $mr->uri;
}
lib/Apache/AxKit/Plugin/Session.pm view on Meta::CPAN
$$session{'auth_location'};
}
sub save_params ($$) {
my ($self, $uri) = @_;
$self->debug(3,"--------- save_params(".join(',',@_).")");
my $r = Apache->request();
my $session = $r->pnotes('SESSION') || return $self->orig_save_params($uri);
parse_input(1);
my $in = $r->pnotes('INPUT');
my @out = ();
while(my($key,$val) = each %$in) {
push @out, $key, $val;
}
$$session{'auth_params'} = \@out;
return $uri;
}
sub restore_params ($) {
lib/Apache/AxKit/Plugin/Session.pm view on Meta::CPAN
my $r = Apache->request();
my $session = $r->pnotes('SESSION') || return $self->orig_restore_params();
return $self->orig_restore_params() unless $$session{'auth_params'};
my @in = @{$$session{'auth_params'}};
my $out = new Apache::Table($r);
while (@in) {
$out->add($in[0],$in[1]);
shift @in; shift @in;
}
$r->pnotes('INPUT',$out);
delete $$session{'auth_params'};
}
sub _cleanup_session ($$) {
my ($self, $session) = @_;
$self->debug(3,"--------- _cleanup_session(".join(',',@_).")");
untie %{$session};
undef %{$session};
}
( run in 0.329 second using v1.01-cache-2.11-cpan-4e96b696675 )