Gantry-Plugins-Uaf
view release on metacpan or search on metacpan
lib/Gantry/Plugins/Uaf.pm view on Meta::CPAN
@parts = split('::', $uaf_authn);
$filename = File::Spec->catfile(@parts) . ".pm";
eval {
require $filename;
$uaf_authn->import();
$gobj->{_UAF_AUTHN_} = $uaf_authn->new($gobj);
}; if ($@) { warn "authn died $@\n"; die "Unable to load $uaf_authn; $@"; }
@parts = split('::', $uaf_authz);
$filename = File::Spec->catfile(@parts) . ".pm";
eval {
require $filename;
$uaf_authz->import();
$gobj->{_UAF_AUTHZ_} = $uaf_authz->new($gobj);
}; if ($@) { warn "authz died $@\n"; die "Unable to load $uaf_authz; $@"; }
$gobj->uaf_inited(1);
}
sub uaf_authenticate {
my $gobj = shift;
my $user;
my $regex = $gobj->uaf_authn->filter;
# authenticate the session, this happens with each access
return if ($gobj->uri =~ /^$regex/);
if ($gobj->uaf_authn->avoid()) {
if ($gobj->session_lock()) {
if (defined($user = $gobj->uaf_authn->is_valid())) {
#
# Uncomment this line of code and you will get an everchanging
# security token. Some internet pundits consider this a
# "good thing". But in an xhr async environment you will get
# a rather nasty race condition. i.e. The browsers don't
# consistently update the cookies from xhr requests. While a
# standard page loads work quite nicely.
#
# --> $gobj->uaf_authn->set_token($user);
#
$gobj->uaf_user($user);
$gobj->session_unlock();
} else {
$gobj->session_unlock();
$gobj->uaf_authn->relocate($gobj->uaf_authn->login_rootp);
}
}
}
}
sub do_login {
my ($gobj, $action) = @_;
$gobj->uaf_authn->login($action);
}
sub do_logout {
my $gobj = shift;
$gobj->uaf_authn->logout();
}
# ---------------------------------------------------------------------
# Accessors
# ---------------------------------------------------------------------
sub uaf_authn {
my $gobj = shift;
return $gobj->{_UAF_AUTHN_};
}
sub uaf_authz {
my $gobj = shift;
return $gobj->{_UAF_AUTHZ_};
}
sub uaf_user {
my ($gobj, $p) = @_;
$gobj->{_UAF_USER_} = $p if (defined($p));
return $gobj->{_UAF_USER_};
}
sub uaf_inited {
my ($gobj, $p) = @_;
$gobj->{_UAF_INITED_} = $p if (defined($p));
return $gobj->{_UAF_INITED_};
}
1;
__END__
( run in 0.904 second using v1.01-cache-2.11-cpan-63c85eba8c4 )