Mercurial > pub > Impl
changeset 95:67eb8eaec3d4
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
author | wizard |
---|---|
date | Thu, 29 Apr 2010 02:21:27 +0400 |
parents | 79bf75223afe |
children | 4c55aed00ff2 |
files | Lib/IMPL/Security.pm Lib/IMPL/Security/Context.pm Lib/IMPL/Web/Application/Response.pm Lib/IMPL/Web/QueryHandler/SecureCookie.pm |
diffstat | 4 files changed, 44 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 {
--- 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) = @_;
--- 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__