Mercurial > pub > Impl
comparison lib/IMPL/Security/Role.pm @ 407:c6e90e02dd17 ref20150831
renamed Lib->lib
author | cin |
---|---|
date | Fri, 04 Sep 2015 19:40:23 +0300 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
406:f23fcb19d3c1 | 407:c6e90e02dd17 |
---|---|
1 package IMPL::Security::Role; | |
2 use strict; | |
3 | |
4 use IMPL::require { | |
5 AbstractRole => 'IMPL::Security::AbstractRole' | |
6 }; | |
7 | |
8 use IMPL::declare { | |
9 base => [ | |
10 'IMPL::Object' => undef, | |
11 'IMPL::Security::AbstractRole' => undef | |
12 ], | |
13 _implement => 1 | |
14 }; | |
15 | |
16 sub CTOR { | |
17 my ($this,$name,$parentRoles) = @_; | |
18 | |
19 $this->roleName($name) if $name; | |
20 $this->parentRoles($parentRoles) if $parentRoles; | |
21 } | |
22 | |
23 1; | |
24 | |
25 __END__ | |
26 | |
27 =pod | |
28 | |
29 =head1 NAME | |
30 | |
31 C<IMPL::Security::Role> - стандартная реализация роли безопасности. | |
32 | |
33 =head1 SYNOPSIS | |
34 | |
35 =begin code | |
36 | |
37 # create the megarole | |
38 my $role = IMPL::Security::Role->new(megarole => [ $adminRole, $directorRole ] ); | |
39 | |
40 #use it in context | |
41 my $context = IMPL::Security::Context->new( | |
42 principal => $user, | |
43 assignedRoles => [$user->roles, $megarole] | |
44 ); | |
45 | |
46 $context->Impersonate( sub { | |
47 # do something forbidden | |
48 }); | |
49 | |
50 =end code | |
51 | |
52 =head1 DESCRIPTION | |
53 | |
54 Позволяет создавать объекты ролей без привязки к источникам данных и модулям | |
55 авторизации. Чаще всего используется при реализации каких либо механизмов | |
56 безопасности, где требуется создать временную роль. | |
57 | |
58 C<IMPL::Security::AbstractRole> | |
59 | |
60 =cut |