51
|
1 package IMPL::Security::Auth::Simple;
|
|
2
|
|
3 use base qw(IMPL::Security::Auth);
|
|
4 use Digest::MD5;
|
52
|
5 import IMPL::Security::Auth qw(:Const GenSSID);
|
|
6
|
|
7 use IMPL::Class::Property;
|
|
8
|
|
9 BEGIN {
|
|
10 private property _passwordImage => prop_all;
|
|
11 private property _sessionCookie => prop_all;
|
|
12 }
|
|
13
|
|
14 sub CTOR {
|
|
15 my ($this,$secData) = @_;
|
|
16
|
|
17 $this->_passwordImage($secData);
|
|
18 }
|
51
|
19
|
|
20 sub DoAuth {
|
52
|
21 my ($this,$challenge) = @_;
|
51
|
22
|
52
|
23 if (Digest::MD5::md5_hex($challenge) eq $this->_passwordImage) {
|
|
24 return (SUCCESS,$this->_sessionCookie(GenSSID));
|
51
|
25 } elsee {
|
52
|
26 return (FAIL,undef);
|
|
27 }
|
|
28 }
|
|
29
|
|
30 sub ValidateSession {
|
|
31 my ($this,$cookie) = @_;
|
|
32
|
|
33 if ($cookie eq $this->_sessionCookie) {
|
|
34 return (SUCCESS,undef);
|
|
35 } else {
|
|
36 return (FAIL,undef);
|
51
|
37 }
|
|
38 }
|
|
39
|
|
40 1;
|
|
41
|
|
42 __END__
|
|
43
|
|
44 =pod
|
|
45
|
|
46 =head1 DESCRIPTION
|
|
47
|
|
48 Модуль простой авторизации
|
|
49
|
|
50 =cut |