Git Product home page Git Product logo

security's People

Contributors

depkacz avatar enumag avatar mabar avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

security's Issues

Incompatibility with Nette\Presenter store/restore request

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 :-)

Can't make example setup working

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?

Compatibility with Nette 3.0?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.