# HG changeset patch # User wizard # Date 1272493287 -14400 # Node ID 67eb8eaec3d4291b05cb2003a265fa798df6cb68 # Parent 79bf75223afef8137742f050d5179713e850e015 Added a security authority property to the Context and Security classes Added a WriteResponse method to the SecureCookie class Added a setCookie method to the Response class diff -r 79bf75223afe -r 67eb8eaec3d4 Lib/IMPL/Security.pm --- a/Lib/IMPL/Security.pm Thu Apr 29 01:31:27 2010 +0400 +++ b/Lib/IMPL/Security.pm Thu Apr 29 02:21:27 2010 +0400 @@ -6,6 +6,8 @@ \&IMPL::Security::Rule::RoleCheck::SatisfyAll ); +our $authority = undef; + sub AccessCheck { my ($self, $object, $desiredAccess, $context) = @_; @@ -36,6 +38,10 @@ return \@rules; } +sub authority { + return $authority; +} + 1; __END__ @@ -202,6 +208,11 @@ =end code +=item C<[static,get] authority> + +Метод, позволяющий получить текущий источник системы безопасности. Источник безопасности, это модуль, +который получает входные данные и использует их для работы системы безопасности. + =back =cut \ No newline at end of file diff -r 79bf75223afe -r 67eb8eaec3d4 Lib/IMPL/Security/Context.pm --- a/Lib/IMPL/Security/Context.pm Thu Apr 29 01:31:27 2010 +0400 +++ b/Lib/IMPL/Security/Context.pm Thu Apr 29 02:21:27 2010 +0400 @@ -17,6 +17,7 @@ public property principal => prop_get; public property rolesAssigned => prop_all | prop_list; public property auth => prop_all; + public property authority => prop_all; } sub CTOR { diff -r 79bf75223afe -r 67eb8eaec3d4 Lib/IMPL/Web/Application/Response.pm --- a/Lib/IMPL/Web/Application/Response.pm Thu Apr 29 01:31:27 2010 +0400 +++ b/Lib/IMPL/Web/Application/Response.pm Thu Apr 29 02:21:27 2010 +0400 @@ -112,6 +112,18 @@ } } +sub setCookie { + my ($this,$name,$value) = @_; + + unless ($this->cookies) { + $this->cookies({$name,$value}); + } else { + $this->_checkHeaderPrinted(); + $this->cookies->{$name} = $value; + } + return $value; +} + sub getStreamBody { my ($this) = @_; diff -r 79bf75223afe -r 67eb8eaec3d4 Lib/IMPL/Web/QueryHandler/SecureCookie.pm --- a/Lib/IMPL/Web/QueryHandler/SecureCookie.pm Thu Apr 29 01:31:27 2010 +0400 +++ b/Lib/IMPL/Web/QueryHandler/SecureCookie.pm Thu Apr 29 02:21:27 2010 +0400 @@ -1,10 +1,12 @@ package IMPL::Web::QueryHandler::SecureCookie; +use strict; use base qw(IMPL::Web::QueryHandler); use Digest::MD5 qw(md5_hex); use IMPL::Class::Property; use IMPL::Security::Auth qw(:Const); +use IMPL::Security; BEGIN { public property salt => prop_all; @@ -40,6 +42,7 @@ $this->salt ) ) { + local $IMPL::Security::authority = $this; my $context = $action->application->security->sourceSession->find( { id => $sid } @@ -48,6 +51,7 @@ my ($result,$challenge) = $context->auth->ValidateSession($cookie); if ($result == AUTH_SUCCESS) { + $context->authority($this); return $context->Impersonate($nextHandler); } else { return $nextHandler->(); @@ -58,6 +62,22 @@ } } +sub WriteResponse { + my ($this,$response,$sid,$cookie,$method) = @_; + + my $sign = md5_hex( + $this->salt, + $sid, + $cookie, + $this->salt + ); + + $this->setCookie(sid => $sid); + $this->setCookie(sdata => $cookie); + $this->setCookie(sign => $sign); + $this->setCookie(method => $method) if $method; +} + 1; __END__