Apache-AxKit-Plugin-Session
view release on metacpan or search on metacpan
lib/Apache/AxKit/Plugin/Session.pm view on Meta::CPAN
$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;
}
$self->debug(1,"destination = '$destination'");
# Get the credentials from the data posted by the client, if any.
my @credentials;
while (exists $$args{"credential_" . ($#credentials + 1)}) {
$self->debug(2,"credential_" . ($#credentials + 1) . "= '" .$$args{"credential_" . ($#credentials + 1)} . "'");
push(@credentials, $$args{"credential_" . ($#credentials + 1)});
}
# convert post to get
if ($r->method eq 'POST') {
$r->method('GET');
$r->method_number(M_GET);
$r->headers_in->unset('Content-Length');
}
$r->no_cache(1) unless $r->dir_config($auth_name.'Cache');
# Exchange the credentials for a session key.
my ($ses_key, $error_message) = $self->authen_cred($r, @credentials);
# Get the uri so can adjust path, and to redirect including the query string
unless ($ses_key) {
$self->debug(2,"No session returned from authen_cred: $error_message" );
$self->save_reason($error_message) if ($r->is_main());
} else {
lib/Apache/AxKit/Plugin/Session.pm view on Meta::CPAN
tie(%$globals, $tie, @tie) || die "Could tie ${auth_name}Global: $@";
$r->register_cleanup(sub { _cleanup_session($self, $globals) });
}
}
$r->pnotes('GLOBAL',$globals);
return $session;
}
# this is a NO-OP! Don't use this one (or ->login) directly,
# unless you have verified the credentials yourself or don't
# want user logins
sub authen_cred($$\@) {
my ($self, $r, @credentials) = @_;
$self->debug(3,"--------- authen_cred(".join(',',@_).")");
my ($session, $err) = $self->_get_session($r);
return (undef, $err) if $err;
$$session{'auth_access_user'} = $credentials[0] if defined $credentials[0];
$r->pnotes('SESSION',$session);
return $$session{'_session_id'};
}
sub authen_ses_key($$$) {
my ($self, $r, $session_id) = @_;
$self->debug(3,"--------- authen_ses_key(".join(',',@_).")");
my ($session, $err) = $self->_get_session($r, $session_id);
return (undef, $err) if $err;
return ($session_id eq $$session{'_session_id'})?$$session{'auth_access_user'}:undef;
( run in 0.245 second using v1.01-cache-2.11-cpan-4d50c553e7e )