arachne / security Goto Github PK
View Code? Open in Web Editor NEWAuthentication and authorization for Nette framework. Deals with cases that are difficult to implement with nette/security.
License: MIT License
Authentication and authorization for Nette framework. Deals with cases that are difficult to implement with nette/security.
License: MIT License
Pull request here:
Is it possible that the entity loader is not compatible with the Nette Presenter's store/restore request? Looks like request now contains whole documents (that can have closures in them) and I get Serialization of 'Closure' is not allowed error. Any idea what to do with this. I guess that: Do not use storeRequest will fix that :-)
I read article https://pehapkari.cz/blog/2017/08/21/arachne-security-simplified-authorizator-and-fixed-acl-callbacks/ and wanted to test your lib, but can't get it working. It will return error:
Interface Arachne\Security\Authorization\AuthorizatorInterface used in service 'admin.authorizator' must have just one non-static method create() or get().
config.neon
extensions:
arachne.serviceCollections: Arachne\ServiceCollections\DI\ServiceCollectionsExtension
arachne.security: Arachne\Security\DI\SecurityExtension
arachne.security:
firewalls:
admin: App\Libs\Security\AdminFirewall
services:
admin.authorizator:
implement: Arachne\Security\Authorization\AuthorizatorInterface
factory: App\Libs\Security\AuthorizatorFactory::create
tags:
arachne.security.authorizator: admin
admin.identityValidator:
class: App\Libs\Security\AdminIdentityValidator
tags:
arachne.security.identityValidator: admin
AdminFirewall.php
<?php
declare(strict_types=1);
namespace App\Libs\Security;
use Arachne\Security\Authentication\Firewall;
final class AdminFirewall extends Firewall
{
}
AdminIdentityValidator.php
<?php
declare(strict_types=1);
namespace App\Libs\Security;
use App\Model\Entities\User;
use Arachne\Security\Authentication\IdentityValidatorInterface;
use Kdyby\Doctrine\EntityManager;
use Nette\Security\Identity;
use Nette\Security\IIdentity;
final class AdminIdentityValidator implements IdentityValidatorInterface
{
/**
* @var EntityManager
*/
private $entityManager;
public function __construct(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
}
public function validateIdentity(IIdentity $identity): ?IIdentity
{
$user = $this->entityManager->getRepository(User::class)->find($identity->getId());
if (!$user) {
return NULL;
}
return new Identity(
$user->userId,
$user->roles,
[
'login' => $user->login,
'name' => $user->name,
]
);
}
}
AuthroizationFactory.php
<?php
declare(strict_types=1);
namespace App\Libs\Security;
use Arachne\Security\Authorization\AuthorizatorInterface;
use Arachne\Security\Authorization\Permission;
use Arachne\Security\Authorization\PermissionAuthorizator;
final class AuthorizatorFactory
{
/**
* @var AdminFirewall
*/
private $firewall;
public function __construct(AdminFirewall $adminFirewall)
{
$this->firewall = $adminFirewall;
}
public function create(): AuthorizatorInterface
{
$permission = new Permission;
$permission->addRole('admin');
$permission->addResource('datacenter');
$permission->addResource('ipAddress');
$permission->addResource('ipRange');
$permission->addResource('macAddress');
$permission->allow('admin', ['datacenter', 'ipAddress', 'ipRange', 'macAddress'], 'view');
return new PermissionAuthorizator($this->firewall, $permission);
}
}
Am I doing something wrong?
when I use
->isAllowed('resource', Nette\Security\IAuthorizator::ALL);
I have TypeError:: isAllowed() must be of the type string, null given
https://github.com/Arachne/Security/blob/v0.4.0/src/Authorization/AuthorizatorInterface.php#L17
https://github.com/nette/security/blob/v2.4.2/src/Security/IAuthorizator.php#L18
Are there any plans to upgrade Arachne Security for Nette 3.0? I might give it a quick shot and see if there are some serious issues.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.