In between commit implementing security layer

This commit is contained in:
Kevin Frantz
2018-09-22 02:12:03 +02:00
parent bbcf369347
commit d255623f85
8 changed files with 129 additions and 38 deletions

View File

@@ -1,27 +1,25 @@
<?php
namespace App\Structur\Facade\Security;
namespace App\Structur\Facade\Security\Source;
use App\Entity\NodeInterface;
use App\Entity\SourceInterface;
use App\Entity\User;
use App\DBAL\Types\RightType;
use App\DBAL\Types\LayerType;
use App\Structur\Facade\Security\Source\interfaces\SourceFacadeInterface;
/**
*
* @author kevinfrantz
*
*/
abstract class AbstractSourceFasade implements SourceInterface
abstract class AbstractSourceFacade implements SourceFacadeInterface
{
/**
*
* @var User
*/
protected static $user;
/**
*
* @var SourceInterface
*/
protected $source;
@@ -30,7 +28,7 @@ abstract class AbstractSourceFasade implements SourceInterface
{
self::$user = $user;
}
public function __construct(SourceInterface $source)
{
$this->source = $source;
@@ -48,24 +46,27 @@ abstract class AbstractSourceFasade implements SourceInterface
public function getId(): int
{
if($this->isGranted(RightType::READ)){
if ($this->isGranted(RightType::READ)) {
return $source->getId();
}
}
public function getNode(): NodeInterface
{
if($this->isGranted(RightType::READ,LayerType::NODE)){
return $source->getId();
if ($this->isGranted(RightType::READ, LayerType::NODE)) {
return $source->getNode();
}
}
protected function isGranted(string $right,string $layer): bool
protected function isGranted(string $right, string $layer): bool
{
return $this->getNode()
->getLaw()
->isGranted(self::$user->getSource()
->getNode(), self::$layer, $right);
}
}
protected function lazyLoadSourceFacade(SourceInterface $source)
{
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Structur\Facade\Security\Source;
use App\Entity\NameSourceInterface;
use App\Entity\User;
use App\Entity\UserSourceInterface;
use App\DBAL\Types\RightType;
use App\DBAL\Types\LayerType;
/**
* @author kevinfrantz
*/
class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterface
{
/**
* @var UserSourceInterface
*/
protected $source;
public function setNameSource(NameSourceInterface $nameSource): void
{
throw new \Exception('The name source cant be changed!');
}
public function getNameSource(): NameSourceInterface
{
if ($this->isNameSourceGranted(RightType::READ, LayerType::SOURCE)) {
//FILL! :)
}
}
private function isNameSourceGranted(string $right, string $layer): bool
{
$nameSource = $this->source->getNameSource();
$law = $nameSource->getNode()->getLaw();
$userSourceNode = $this->source->getNode();
return $this->isGranted($right, $layer) && $law->isGranted($userSourceNode, $layer, $right);
}
public function getUser(): User
{
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Structur\Facade\Security\Source\interfaces;
use App\Entity\SourceInterface;
/**
* @author kevinfrantz
*/
interface SourceFacadeInterface extends SourceInterface
{
}