annotate Lib/IMPL/Security/Role.pm @ 326:793cc7f0a7e7

IMPL::Web::AutoLocator added Sibling method for locating sibling resources
author sergey
date Wed, 29 May 2013 17:58:45 +0400
parents 6d8092d8ce1b
children 69a1f1508696
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
1 package IMPL::Security::Role;
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
2 use strict;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
3
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
4 use IMPL::require {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
5 AbstractRole => 'IMPL::Security::AbstractRole'
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
6 };
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
7
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
8 use IMPL::declare {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
9 base => [
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
10 'IMPL::Object' => undef,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
11 'IMPL::Security::AbstractRole' => undef
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
12 ],
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
13 props => [
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
14 @{AbstractRole->abstractProps()}
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
15 ]
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
16 };
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
17
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
18 __PACKAGE__->abstractProps([]);
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
19
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
20
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
21 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
22 my ($this,$name,$parentRoles) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
23
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
24 $this->roleName($name) if $name;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
25 $this->parentRoles($parentRoles) if $parentRoles;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
26 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
27
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
28 1;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
29
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
30 __END__
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
31
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
32 =pod
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
33
73
wizard
parents: 51
diff changeset
34 =head1 NAME
wizard
parents: 51
diff changeset
35
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
36 C<IMPL::Security::Role> - стандартная реализация роли безопасности.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
37
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
38 =head1 SYNOPSIS
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
39
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
40 =begin code
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
41
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
42 # create the megarole
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
43 my $role = IMPL::Security::Role->new(megarole => [ $adminRole, $directorRole ] );
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
44
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
45 #use it in context
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
46 my $context = IMPL::Security::Context->new(
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
47 principal => $user,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
48 assignedRoles => [$user->roles, $megarole]
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
49 );
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
50
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
51 $context->Impersonate( sub {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
52 # do something forbidden
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
53 });
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
54
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
55 =end code
73
wizard
parents: 51
diff changeset
56
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
57 =head1 DESCRIPTION
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
58
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
59 Позволяет создавать объекты ролей без привязки к источникам данных и модулям
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
60 авторизации. Чаще всего используется при реализации каких либо механизмов
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
61 безопасности, где требуется создать временную роль.
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
62
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
63 C<IMPL::Security::AbstractRole>
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
64
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
65 =cut