annotate Lib/IMPL/Security/Auth/Simple.pm @ 75:915df8fcd16f

docs small fixes
author wizard
date Tue, 30 Mar 2010 20:31:36 +0400
parents 2f31ecabe9ea
children 077357224bec
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::Simple;
71
wizard
parents: 68
diff changeset
2 use strict;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
3
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
4 use base qw(IMPL::Security::Auth);
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
5 use Digest::MD5;
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
6
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
7 use IMPL::Class::Property;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
8
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
9 BEGIN {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
10 private property _passwordImage => prop_all;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
11 private property _sessionCookie => prop_all;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
12 }
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
13
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
14 sub CTOR {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
15 my ($this,$secData) = @_;
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 $this->_passwordImage($secData);
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
18 }
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
19
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
20 sub DoAuth {
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
21 my ($this,$challenge) = @_;
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
22
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
23 if (Digest::MD5::md5_hex($challenge) eq $this->_passwordImage) {
72
wizard
parents: 71
diff changeset
24 return (AUTH_SUCCESS,$this->_sessionCookie($this->GenSSID));
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
25 } elsee {
72
wizard
parents: 71
diff changeset
26 return (AUTH_FAIL,undef);
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
27 }
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
28 }
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
29
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
30 sub ValidateSession {
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
31 my ($this,$cookie) = @_;
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
32
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
33 if ($cookie eq $this->_sessionCookie) {
72
wizard
parents: 71
diff changeset
34 return (AUTH_SUCCESS,undef);
52
15d720913562 security in work
wizard@linux-odin.local
parents: 51
diff changeset
35 } else {
72
wizard
parents: 71
diff changeset
36 return (AUTH_FAIL,undef);
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
37 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
38 }
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
39
71
wizard
parents: 68
diff changeset
40 sub CreateSecData {
wizard
parents: 68
diff changeset
41 my ($self,%args) = @_;
wizard
parents: 68
diff changeset
42
wizard
parents: 68
diff changeset
43 die new IMPL::InvalidArgumentException("The parameter is required",'password') unless $args{password};
wizard
parents: 68
diff changeset
44
wizard
parents: 68
diff changeset
45 return md5_hex($args{password});
wizard
parents: 68
diff changeset
46 }
wizard
parents: 68
diff changeset
47
wizard
parents: 68
diff changeset
48 sub SecDataArgs {
72
wizard
parents: 71
diff changeset
49 password => 'SCALAR'
71
wizard
parents: 68
diff changeset
50 }
wizard
parents: 68
diff changeset
51
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
52 1;
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
53
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
54 __END__
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
55
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
56 =pod
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
57
71
wizard
parents: 68
diff changeset
58 =head1 NAME
wizard
parents: 68
diff changeset
59
wizard
parents: 68
diff changeset
60 C<IMPL::Security::Auth::Simple> Модуль простой авторизации.
wizard
parents: 68
diff changeset
61
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
62 =head1 DESCRIPTION
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
63
72
wizard
parents: 71
diff changeset
64 Использует алгоритм MD5 для хранения образа пароля.
71
wizard
parents: 68
diff changeset
65
72
wizard
parents: 71
diff changeset
66 =head1 MEMBERS
71
wizard
parents: 68
diff changeset
67
72
wizard
parents: 71
diff changeset
68 =over
wizard
parents: 71
diff changeset
69
wizard
parents: 71
diff changeset
70 =item C<DoAuth($challenge)>
wizard
parents: 71
diff changeset
71
wizard
parents: 71
diff changeset
72 Аутентифицирует пользователя. Используется один этап. C<$challenge>
wizard
parents: 71
diff changeset
73 открытый пароль пользователя.
wizard
parents: 71
diff changeset
74
wizard
parents: 71
diff changeset
75 Возвращает C<($status,$challenge)>
wizard
parents: 71
diff changeset
76
wizard
parents: 71
diff changeset
77 =over
wizard
parents: 71
diff changeset
78
wizard
parents: 71
diff changeset
79 =item C<$status>
wizard
parents: 71
diff changeset
80
wizard
parents: 71
diff changeset
81 Результат либо C<AUTH_SUCCESS>, либо C<AUTH_FAIL>
wizard
parents: 71
diff changeset
82
73
wizard
parents: 72
diff changeset
83 =item C<$challenge>
wizard
parents: 72
diff changeset
84
wizard
parents: 72
diff changeset
85 В случае успеха возвращает cookie (уникальный номер) сессии
wizard
parents: 72
diff changeset
86
wizard
parents: 72
diff changeset
87 =back
wizard
parents: 72
diff changeset
88
wizard
parents: 72
diff changeset
89 =item C<ValidateSession($challenge)>
wizard
parents: 72
diff changeset
90
wizard
parents: 72
diff changeset
91 Проверяет аутентичность сессии. Использует один этап. C<$challenge> cookie
wizard
parents: 72
diff changeset
92 сессии, полученный при выполнении метода C<DoAuth>.
wizard
parents: 72
diff changeset
93
wizard
parents: 72
diff changeset
94 Возвращает C<($status,$challenge)>
wizard
parents: 72
diff changeset
95
wizard
parents: 72
diff changeset
96 =over
wizard
parents: 72
diff changeset
97
wizard
parents: 72
diff changeset
98 =item C<$status>
wizard
parents: 72
diff changeset
99
wizard
parents: 72
diff changeset
100 Результат либо C<AUTH_SUCCESS>, либо C<AUTH_FAIL>
wizard
parents: 72
diff changeset
101
wizard
parents: 72
diff changeset
102 =item C<$challenge>
wizard
parents: 72
diff changeset
103
wizard
parents: 72
diff changeset
104 Всегда C<undef>
72
wizard
parents: 71
diff changeset
105
wizard
parents: 71
diff changeset
106 =back
wizard
parents: 71
diff changeset
107
wizard
parents: 71
diff changeset
108 =back
51
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
109
a1498298d3ee Security in progress
wizard@linux-odin.local
parents:
diff changeset
110 =cut