annotate Lib/IMPL/Web/Security.pm @ 232:5c82eec23bb6

Fixed degradations due refactoring
author sergey
date Tue, 09 Oct 2012 20:12:47 +0400
parents ff1e8fa932f2
children 3cebcf6fdb9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
52
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
1 package IMPL::Web::Security;
81
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 79
diff changeset
2 use strict;
73
wizard
parents: 66
diff changeset
3
81
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 79
diff changeset
4 use IMPL::Security::Auth qw(:Const);
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
5 use IMPL::declare {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
6 require => {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
7 Exception => 'IMPL::Exception',
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
8 NotImplementedException => '-IMPL::NotImplementedException',
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
9 SecurityContext => 'IMPL::Security::AbstractContext'
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
10 },
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
11 };
107
0e72ad99eef7 Updated Web::TT
wizard
parents: 97
diff changeset
12
81
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 79
diff changeset
13 sub AuthUser {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
14 my ($this,$name,$package,$challenge) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
15
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
16 my $user = $this->FindUserByName($name)
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
17 or return { status => AUTH_FAIL, answer => "Can't find a user '$name'" };
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
18
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
19 my $auth;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
20 if ( my $secData = $user->GetSecData($package) ) {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
21 $auth = $package->new($secData);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
22 } else {
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
23 return {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
24 status => AUTH_FAIL,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
25 user => $user
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
26 };
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
27 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
28
232
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
29 my $status = SecurityContext->current->authority->InitSession(
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
30 $user,
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
31 $auth,
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
32 [$user->roles]
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
33 );
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
34
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
35 return {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
36 status => $status,
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
37 user => $user
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
38 };
73
wizard
parents: 66
diff changeset
39 }
wizard
parents: 66
diff changeset
40
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
41 sub FindUserByName {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
42 die NotImplementedException->new();
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
43 }
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
44
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
45 sub CreateSession {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
46 die NotImplementedException->new();
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
47 }
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
48
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
49 sub GetSession {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
50 die NotImplementedException->new();
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
51 }
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
52
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
53 sub SaveSession {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 194
diff changeset
54 die NotImplementedException->new();
73
wizard
parents: 66
diff changeset
55 }
wizard
parents: 66
diff changeset
56
52
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
57 1;
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
58
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
59 __END__
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
60
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
61 =pod
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
62
73
wizard
parents: 66
diff changeset
63 =head1 NAME
wizard
parents: 66
diff changeset
64
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
65 C<IMPL::Web::Security> Модуль для аутентификации и авторизации веб запроса.
73
wizard
parents: 66
diff changeset
66
52
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
67 =head1 DESCRIPTION
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
68
232
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
69 Текущий модуль обеспечивает функции верхнего уровня для работы с системой
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
70 безопасности. Поскольку модуль является абстрактым, конкретные функции
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
71 хранения и реализацию объектов модели безопасности должно обеспечить само
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
72 приложение.
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
73
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
74 Сама система безопасности в веб приложении состоит из двух частей
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
75
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
76 =over
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
77
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
78 =item Модель системы безопасности
52
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
79
232
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
80 Предоставляет такие объкты безопасности, как пользователь, сессия роль,
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
81 определяет правила проверки прав доступа субъекта к объекту.
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
82
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
83 =item Модуль безопасности
52
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
84
232
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
85 Как правило встраивается в транспортный уровеь в виде обработчика
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
86 C<IMPL::Web::Handler> и реализует непосредственно протокол аутентификации и
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
87 обмена с пользователем.
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
88
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
89 Также модуль безопасности использует модель для хранения сессий и данных
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
90 аутентификции. Контекст безопасности создается именно этим модулем.
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
91
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 231
diff changeset
92 =back
52
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
93
73
wizard
parents: 66
diff changeset
94 =head1 MEMBERS
52
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
95
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
96 =cut