51
|
1 package IMPL::Security::Auth::Simple;
|
71
|
2 use strict;
|
51
|
3
|
|
4 use base qw(IMPL::Security::Auth);
|
|
5 use Digest::MD5;
|
52
|
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) {
|
72
|
24 return (AUTH_SUCCESS,$this->_sessionCookie($this->GenSSID));
|
51
|
25 } elsee {
|
72
|
26 return (AUTH_FAIL,undef);
|
52
|
27 }
|
|
28 }
|
|
29
|
|
30 sub ValidateSession {
|
|
31 my ($this,$cookie) = @_;
|
|
32
|
|
33 if ($cookie eq $this->_sessionCookie) {
|
72
|
34 return (AUTH_SUCCESS,undef);
|
52
|
35 } else {
|
72
|
36 return (AUTH_FAIL,undef);
|
51
|
37 }
|
|
38 }
|
|
39
|
71
|
40 sub CreateSecData {
|
|
41 my ($self,%args) = @_;
|
|
42
|
|
43 die new IMPL::InvalidArgumentException("The parameter is required",'password') unless $args{password};
|
|
44
|
|
45 return md5_hex($args{password});
|
|
46 }
|
|
47
|
|
48 sub SecDataArgs {
|
72
|
49 password => 'SCALAR'
|
71
|
50 }
|
|
51
|
51
|
52 1;
|
|
53
|
|
54 __END__
|
|
55
|
|
56 =pod
|
|
57
|
71
|
58 =head1 NAME
|
|
59
|
|
60 C<IMPL::Security::Auth::Simple> Модуль простой авторизации.
|
|
61
|
51
|
62 =head1 DESCRIPTION
|
|
63
|
72
|
64 Использует алгоритм MD5 для хранения образа пароля.
|
71
|
65
|
72
|
66 =head1 MEMBERS
|
71
|
67
|
72
|
68 =over
|
|
69
|
|
70 =item C<DoAuth($challenge)>
|
|
71
|
|
72 Аутентифицирует пользователя. Используется один этап. C<$challenge>
|
|
73 открытый пароль пользователя.
|
|
74
|
|
75 Возвращает C<($status,$challenge)>
|
|
76
|
|
77 =over
|
|
78
|
|
79 =item C<$status>
|
|
80
|
|
81 Результат либо C<AUTH_SUCCESS>, либо C<AUTH_FAIL>
|
|
82
|
|
83 =item
|
|
84
|
|
85 =back
|
|
86
|
|
87 =back
|
51
|
88
|
|
89 =cut |