49
|
1 use strict;
|
|
2 package Engine::Security;
|
|
3 use Security::Auth;
|
|
4 use Security;
|
|
5 use Engine::Security::Auth;
|
|
6
|
|
7 our @AuthMethods;
|
|
8 my $AuthResult;
|
|
9 my $AuthMod;
|
|
10 my $AuthMethod;
|
|
11
|
|
12 # use last auth method as default
|
|
13 $AuthMethod = Engine::Security::Auth->new(%{$AuthMethods[$#AuthMethods]}) if @AuthMethods;
|
|
14
|
|
15 sub AuthenticateContext {
|
|
16 Security->CurrentSession(undef); #prevent previous session from closing
|
|
17 foreach my $method (@AuthMethods) {
|
|
18 my $AuthObj = Engine::Security::Auth->new(%$method);
|
|
19 $AuthResult = $AuthObj->DoAuth();
|
|
20 # обновить текущий контекст безопасности, только если это необходимо
|
|
21 $AuthObj->SetAuthResult($AuthResult) if $AuthResult->State == Security::AUTH_FAILED or $AuthResult->State == Security::AUTH_SUCCESS;
|
|
22 $AuthMethod = $AuthObj and last if $AuthResult->State != Security::AUTH_FAILED and $AuthResult->State != Security::AUTH_NOAUTH;
|
|
23 }
|
|
24 $AuthMod = $AuthMethod->AuthMod if $AuthMethod;
|
|
25 }
|
|
26
|
|
27 sub SetAuthResult {
|
|
28 shift;
|
|
29 $AuthMethod->SetAuthResult(@_) if $AuthMethod;
|
|
30 }
|
|
31
|
|
32 sub AuthMod {
|
|
33 return $AuthMethod ? $AuthMethod->AuthMod : undef;
|
|
34 }
|
|
35
|
|
36 1;
|