Apache-SiteControl
view release on metacpan or search on metacpan
lib/Apache/SiteControl.pm view on Meta::CPAN
model. You obtain a user object and permission manager from the SiteControl
system. These are intended to be opaque data types to the page designer,
and are defined elsewhere (see USERS). The actual web page component
should carry these objects around without implementing anything in the way of
policy.
For example, your mason component might look like this:
<HTML>
<HEAD> ... </HEAD>
% if($manager->can($currentUser, "edit", $table)) {
<FORM METHOD=POST ACTION="...">
<P><INPUT TYPE=TEXT NAME="x" VALUE="<% $table->{x} %>">
...
</FORM>
% } else {
<P>x is <% $table->{x} %>
% }
<%init>
my $currentUser = Apache::SiteControl->getCurrentUser($r);
lib/Apache/SiteControl/Rule.pm view on Meta::CPAN
use base qw(Apache::SiteControl::Rule);
sub grants($$$$)
{
my $this = shift;
my $user = shift;
my $action = shift;
my $resource = shift;
if($action eq "edit" && $resource->isa("sample::Record")) {
return 1 if($user{name} eq "root");
}
return 0;
}
sub denies($$$$)
{
return 0;
}
sample/EditControlRule.pm view on Meta::CPAN
# might get missed; the latter is a bug that gets quickly reported.
sub grants($$$$)
{
return 0;
}
sub denies($$$$)
{
my ($this, $user, $action, $resource) = @_;
return 1 if($action eq "edit" && $user->getUsername ne "admin");
return 0;
}
1;
sample/README view on Meta::CPAN
read/write access to them.
2) Edit apache_modperlinit.pl and apache_sitecontrol.conf file and update the
relevant paths and fields (location mappings). Use the Directory and Alias
lines in this file to create a mapping for apache to this directory as
/sample.
3) Restart apache and check logs.
4) Try to access /sample/page.html.
- You should be sent to the login page.
The valid logins are: admin/test and user/test.
- You should see the page. If you are logged in as "admin", then you
should have editable fields. If not, you should just see data.
5) Go to /sample/logout.html
- You should see a logout message
6) Try to access /sample/page.html again.
- You should see the login screen again.
Debugging is turned on in the default configuration, so check error_log in
apache if you have problems.
sample/site/index.html view on Meta::CPAN
<HTML>
<HEAD><TITLE>Test Page</TITLE></HEAD>
<BODY>
<P> This is a sample page.
<p><a href="/sample/site/logout.html">Logout</a></p>
% if($manager->can($currentUser, "edit", $preferences)) {
<FORM ACTION="null" METHOD=POST>
<TABLE>
<TR>
<TD>Name:</TD><TD><% $currentUser %></TD>
</TR><TR>
<TD>Favorite color:</TD>
<TD>
<SELECT NAME="color">
<% colorList($preferences) %>
</SELECT>
( run in 0.434 second using v1.01-cache-2.11-cpan-de7293f3b23 )