annotate Lib/IMPL/Security/Auth.pm @ 219:c477f24f1980

sync
author sergey
date Tue, 21 Aug 2012 17:13:47 +0400
parents 4d0e1962161c
children 6d8092d8ce1b
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::Auth;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
2
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
3 use Digest::MD5 qw(md5_hex);
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
4
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
5 use constant {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
6 AUTH_SUCCESS => 1,
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
7 AUTH_INCOMPLETE => 2,
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
8 AUTH_FAIL => 3
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
9 };
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
10
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 87
diff changeset
11 use parent qw(Exporter);
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
12
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
13 our @EXPORT_OK = qw(&AUTH_SUCCESS &AUTH_INCOMPLETE &AUTH_FAIL &GenSSID);
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
14 our %EXPORT_TAGS = (Const => [qw(&AUTH_SUCCESS &AUTH_INCOMPLETE &AUTH_FAIL)]);
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
15
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
16 {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
17 my $i = 0;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
18 sub GenSSID() {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
19 return md5_hex(time,rand,$i++);
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
20 }
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
21 }
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
22
69
8c7b88bdb663 Cookie Simple auth support
wizard
parents: 68
diff changeset
23 sub DoAuth {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
24 die new IMPL::NotImplementedException;
69
8c7b88bdb663 Cookie Simple auth support
wizard
parents: 68
diff changeset
25 }
8c7b88bdb663 Cookie Simple auth support
wizard
parents: 68
diff changeset
26
8c7b88bdb663 Cookie Simple auth support
wizard
parents: 68
diff changeset
27 sub ValidateSession {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
28 die new IMPL::NotImplementedException;
69
8c7b88bdb663 Cookie Simple auth support
wizard
parents: 68
diff changeset
29 }
8c7b88bdb663 Cookie Simple auth support
wizard
parents: 68
diff changeset
30
73
wizard
parents: 72
diff changeset
31 sub isTrusted {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
32 0;
73
wizard
parents: 72
diff changeset
33 }
wizard
parents: 72
diff changeset
34
87
6d3bca490556 small fixes in the security moodules
wizard
parents: 81
diff changeset
35 sub Create {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
36 my ($self,%args) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
37
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
38 return $self->new($self->CreateSecData(%args));
87
6d3bca490556 small fixes in the security moodules
wizard
parents: 81
diff changeset
39 }
6d3bca490556 small fixes in the security moodules
wizard
parents: 81
diff changeset
40
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
41 1;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
42
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
43 __END__
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
44
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
45 =pod
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
46
71
wizard
parents: 70
diff changeset
47 =head1 NAME
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
48
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
49 C<IMPL::Security::Auth> Базовыйы класс для пакетов аутентификации.
71
wizard
parents: 70
diff changeset
50
wizard
parents: 70
diff changeset
51 =head1 DESCRIPTION
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
52
81
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 73
diff changeset
53 C<[Abstract]>
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 73
diff changeset
54
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
55 Аутентификация носит итеративный характер, для чего создается объект аутентификации который
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
56 сохраняет состояние между итерациями.
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
57
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
58 Результатом аутентификации является сессия, состояние этой сессии также хранит объект
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
59 аутентификации.
70
2dfb0b0ad12f More docs
wizard
parents: 69
diff changeset
60
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
61 В процессе авторизации клиент и сервер обмениеваются данными безопасности C<$challenge>.
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
62 И результатом каждой итерации является либо упех (C<AUTH_SUCCESS>), либо запрос на продолжение
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
63 (C<AUTH_INCOMPLETE>), либо неудача (C<AUTH_FAIL>). Количество итераций может быть разным,
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
64 зависит от пакета аутентификации.
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
65
71
wizard
parents: 70
diff changeset
66 =head1 EXPORT
wizard
parents: 70
diff changeset
67
wizard
parents: 70
diff changeset
68 =over
wizard
parents: 70
diff changeset
69
wizard
parents: 70
diff changeset
70 =item C<:Const>
wizard
parents: 70
diff changeset
71
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
72 Константы результата аутентификации
71
wizard
parents: 70
diff changeset
73
wizard
parents: 70
diff changeset
74 =over
wizard
parents: 70
diff changeset
75
wizard
parents: 70
diff changeset
76 =item C<AUTH_SUCCESS>
wizard
parents: 70
diff changeset
77
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
78 Успешная аутентификация
71
wizard
parents: 70
diff changeset
79
wizard
parents: 70
diff changeset
80 =item C<AUTH_INCOMPLETE>
wizard
parents: 70
diff changeset
81
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
82 Требуются дополнительные шаги
71
wizard
parents: 70
diff changeset
83
72
wizard
parents: 71
diff changeset
84 =item C<AUTH_FAIL>
71
wizard
parents: 70
diff changeset
85
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
86 Аутентификация неуспешна.
71
wizard
parents: 70
diff changeset
87
wizard
parents: 70
diff changeset
88 =back
wizard
parents: 70
diff changeset
89
wizard
parents: 70
diff changeset
90 =back
wizard
parents: 70
diff changeset
91
wizard
parents: 70
diff changeset
92 =head1 MEMBERS
wizard
parents: 70
diff changeset
93
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
94 =over
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
95
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
96 =item C<CTOR($SecData)>
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
97
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
98 Создает пакет для авторизации на основе данных безопасности для пользователя.
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
99 C<$SecData> - Зависит от пакета аутентификации.
71
wizard
parents: 70
diff changeset
100
73
wizard
parents: 72
diff changeset
101 =item C<[get] isTrusted>
wizard
parents: 72
diff changeset
102
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
103 Флаг того, что аутентификация закончена успешно.
73
wizard
parents: 72
diff changeset
104
81
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 73
diff changeset
105 =item C<DoAuth($challenge)>
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
106
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
107 Производит аутентификацию пользователя и инициализацию сессии,
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
108 возвращает результат аутентификации, в виде массива ($status,$challenge).
71
wizard
parents: 70
diff changeset
109
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
110 После успешной аутентификации пользователь получает данные C<$challenge>
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
111 для аутентификации сессии.
81
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 73
diff changeset
112
077357224bec IMPL::Web::Security alpha version
Sergey
parents: 73
diff changeset
113 =item C<ValidateSession($challenge)>
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
114
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
115 Производит аутентификацию сессии, возвращает результат аутентификации,
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
116 в виде массива ($status,$challenge).
71
wizard
parents: 70
diff changeset
117
wizard
parents: 70
diff changeset
118 =item C<[static] CreateSecData(%args)>
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
119
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
120 Создает данные безопасности, на основе параметров. Параметры зависят от пакета аутентификации.
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
121
87
6d3bca490556 small fixes in the security moodules
wizard
parents: 81
diff changeset
122 =item C<[static] Create(%args)>
6d3bca490556 small fixes in the security moodules
wizard
parents: 81
diff changeset
123
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
124 Создает объект аутентификации, на основе параметров. Параметры зависят от пакета аутентификации.
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
125 Внутри вызывает метод C<CreateSecData(%args)>.
87
6d3bca490556 small fixes in the security moodules
wizard
parents: 81
diff changeset
126
71
wizard
parents: 70
diff changeset
127 =item C<[static] SecDataArgs()>
wizard
parents: 70
diff changeset
128
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
129 Возвращает хеш с описанием параметров для функции C<CreateSecData>. Ключами являются
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
130 имена параметров, значениями - типы.
73
wizard
parents: 72
diff changeset
131
wizard
parents: 72
diff changeset
132 =back
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
133
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
134 =cut