Leser: 1
1 Eintrag, 1 Seite |
1
2
3
4
Public: No authentication, only session management
Private: Authenticate once, go everywhere
Restricted: Authenticate and reauthorize with a ticket for every
request (best used in a post form as hidden input)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use base qw(Apache::MVC Maypole::Authentication::Abstract);
sub authenticate {
my $r = shift;
if ( $r->{table} eq 'openforall' ) {
$r->public;
}
elsif ( $r->{table} eq 'membersonly' ) {
$r->private;
$r->{template} = 'login' unless $r->{user};
}
elsif ( $r->{table} eq 'topsecret' ) {
$r->restricted;
$r->{template} = 'login' unless $r->{user};
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use base qw(Apache::MVC Maypole::Authentication::Abstract);
MyApp->config->{auth} = {
user_class => 'MyApp::Customer',
user_field => 'email',
session_class => 'Apache::Session::Postgres',
session_args => {
DataSource => 'dbi:Pg:dbname=myapp',
UserName => 'postgres',
Password => '',
Commit => 1
}
};
sub authenticate {
my $r = shift;
if ( $r->{table} eq 'products' && $r->{action} eq 'list' ) {
$r->public;
}
elsif ( $r->{table} eq 'products' && $r->{action} eq 'search' ) {
$r->private;
$r->{template} = 'login' unless $r->{user};
}
elsif ( $r->{table} eq 'products' && $r->{action} eq 'edit' ) {
$r->restricted;
$r->{template} = 'login' unless $r->{user};
}
}
1 Eintrag, 1 Seite |