Coder Social home page Coder Social logo

lm-commons / lmcrbacmvc Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 5.0 2.71 MB

Role-based access control Laminas MVC module to provide additional features on top of Laminas\Permissions\Rbac

Home Page: https://lm-commons.github.io/LmcRbacMvc/

License: BSD 3-Clause "New" or "Revised" License

PHP 97.73% HTML 2.27%
laminas-mvc php rbac rbac-authorization role-based-access-control zfc-rbac

lmcrbacmvc's People

Contributors

ashatrov avatar bakura10 avatar basz avatar belgattitude avatar brunospy avatar danizord avatar davidwindell avatar dennisdobslaf avatar dependabot[bot] avatar divix1988 avatar esserj avatar jhuet avatar jmleroux avatar lasimon avatar manuakasam avatar michalbundyra avatar mparulski avatar nitecon avatar ocramius avatar ojhaujjwal avatar orkin avatar powturns avatar prolic avatar raykolbe avatar renovate[bot] avatar richardjennings avatar svycka avatar visto9259 avatar webdevilopers avatar zeineddin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lmcrbacmvc's Issues

Update documentation for V4

Update the documenation for V4
Add versioning to docs to provide V3 and V4 versions via a menu dropdown using Docusaurus versioning

Guards can not be used with api-tools-mvc-auth

Hi,

I tried using this with laminas api-tools but can not get the guards working. From my understanding, the guards have a higher priority in the execution of events.
Because they have higher priority, the guards are executed before authentication events in api-tools-mvc-auth. The authenticated identity could not be retrieved by the time the guards are executed.

Does anybody else have the same issues?

Move Doctrine Support to a separate companion library

Context:

LmcRbacMvc provide a role provider based on Doctrine ORM which forces to add dependencies to Doctrine for all application, even the ones that are not using Doctrine ORM.
It would be better to have a separate companion library just for the ORM based Role provider

Work to do:

  • Remove Doctrine ORM Role Provided from LmcRbacMvc
  • Create a companion library called LmcRbacMvcDoctrine
  • Update documentation

Move Developer Tools to a separate library

Move the developer tools to a separate library.
This will reduce the footprint of LmcRbacMvc as this is an optional package which is only required if the developer uses Laminas Developer Tools.

Drop support for PHP 7 and PHP 8.0

PHP 7 and PHP 8.0 are end of life.
Drop support for those versions:

  • Remove testing against 7.4 and 8.0
  • Update composer requirements to 8.1, 8.2

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update docusaurus monorepo to v3.4.0 (master) (@docusaurus/core, @docusaurus/module-type-aliases, @docusaurus/preset-classic, @docusaurus/types)
  • Update docusaurus monorepo to v3.4.0 (4.x) (@docusaurus/core, @docusaurus/module-type-aliases, @docusaurus/preset-classic, @docusaurus/types)
  • Update dependency laminas/laminas-serializer to v3 (4.x)
  • Update dependency laminas/laminas-servicemanager to v4 (4.x)
  • Update dependency phpunit/phpunit to v11 (4.x)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

Branch master
composer
composer.json
  • php ^7.4 || ^8.0
  • laminas/laminas-config ^3.1
  • laminas/laminas-eventmanager ^3.0
  • laminas/laminas-mvc ^3.0
  • laminas/laminas-servicemanager ^3.0
  • zfr/rbac ~1.2
  • doctrine/persistence ^2.1
  • laminas/laminas-authentication ^2.2
  • laminas/laminas-developer-tools ^2.1
  • laminas/laminas-log ^2.2
  • laminas/laminas-http ^2.2
  • laminas/laminas-i18n ^2.7
  • laminas/laminas-serializer ^2.2
  • laminas/laminas-view ^2.12
  • phpunit/phpunit 9.5.21
  • squizlabs/php_codesniffer ^3.5.5
  • php-coveralls/php-coveralls ^2.2
  • phpspec/prophecy-phpunit ^2.0
  • doctrine/doctrine-orm-module ^4.1
github-actions
.github/workflows/deploy-gh-pages.yml
  • actions/checkout v4
  • actions/setup-node v4
  • peaceiris/actions-gh-pages v4
.github/workflows/test-deploy-gh-pages.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
docs/package.json
  • @docusaurus/core 3.3.2
  • @docusaurus/preset-classic 3.3.2
  • @mdx-js/react ^3.0.0
  • clsx ^2.0.0
  • prism-react-renderer ^2.3.0
  • react ^18.0.0
  • react-dom ^18.0.0
  • @docusaurus/module-type-aliases 3.3.2
  • @docusaurus/types 3.3.2
  • node >=18.0
Branch 4.x
composer
composer.json
  • php ^8.1.0 | ^8.2.0
  • laminas/laminas-config ^3.1
  • laminas/laminas-eventmanager ^3.0
  • laminas/laminas-mvc ^3.0
  • laminas/laminas-servicemanager ^3.0
  • laminas/laminas-permissions-rbac ^3.0
  • doctrine/persistence ^2.1
  • laminas/laminas-authentication ^2.2
  • laminas/laminas-developer-tools ^2.1
  • laminas/laminas-log ^2.2
  • laminas/laminas-http ^2.2
  • laminas/laminas-i18n ^2.7
  • laminas/laminas-serializer ^2.2
  • laminas/laminas-view ^2.12
  • phpunit/phpunit 10.5.11
  • squizlabs/php_codesniffer ^3.5.5
  • php-coveralls/php-coveralls ^2.2
  • phpspec/prophecy-phpunit ^2.0
  • doctrine/doctrine-orm-module ^5.3
github-actions
.github/workflows/build_test.yml
  • shivammathur/setup-php v2
  • actions/checkout v4
  • actions/cache v4
  • coverallsapp/github-action v2
.github/workflows/deploy-gh-pages.yml
  • actions/checkout v4
  • actions/setup-node v4
  • peaceiris/actions-gh-pages v4
.github/workflows/test-deploy-gh-pages.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
docs/package.json
  • @docusaurus/core 3.3.2
  • @docusaurus/preset-classic 3.3.2
  • @mdx-js/react ^3.0.0
  • clsx ^2.0.0
  • prism-react-renderer ^2.3.0
  • react ^18.0.0
  • react-dom ^18.0.0
  • @docusaurus/module-type-aliases 3.3.2
  • @docusaurus/types 3.3.2
  • node >=18.0

  • Check this box to trigger a request for Renovate to run again on this repository

Find another provider for CI

Travis-CI is no longer free for OpenSource
Need to find another provider for CI
Look into using GiHub Actions?

use Doctrine\Common\Persistence to use Doctrine\Persistence

In ObjectRepositoryRoleProvider :
use Doctrine\Common\Persistence\ObjectRepository; is wrong.
It should be
use Doctrine\Persistence\ObjectRepository;

ObjectRepository.php has been moved
https://github.com/doctrine/persistence/blob/2.1.x/lib/Doctrine/Persistence/ObjectRepository.php

Same in ObjectRepositoryRoleProviderFactory :

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\Persistence\ObjectRepository;

Replace by :

use Doctrine\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectRepository;

AssertionInterface does not describe the context

At this very moment I cannot implememt the AssertionInterface with context, it is not described in this interface.
I tried to override the AssertionInterface with my own, thus with the $context = null parameter. But... the AssertionPluginManager is not that flexible: "Assertions must implement "LmcRbacMvc\Assertion\AssertionInterface", but "Application\Assertion\MustBeWebsiteOwner" (MustBeWebsiteOwner implements my AssertionInterface, with $context...)

So... should the AssertionInterface not be like this?

interface AssertionInterface
{
    /**
     * Check if this assertion is true
     *
     * @param  AuthorizationService $authorizationService
     * @param  mixed                $context
     * @return bool
     */
    public function assert(AuthorizationService $authorizationService, $context = null);
}

Edit: I used a quick and dirty workaround like this to get my context:

$context = \func_get_arg(1);

Proposed: Move factories to the same folder as the object they create

Factories should be closer to the object that it is created. This is will help in understanding the code as one does not have to navigate to the Factory folder.

Refactor all the factories in Factory to the folder of the object that they are creating. For example, LmcRbacMvc\Factory\RoleServiceFactory should be refactored to LmcRbacMvc\Service\RoleServiceFactory.
Have the original factory extend the new factory and mark it as deprecated
Update ConfigProvider to use the new factories

Composer 2.0 Support

Maybe someone can update laminas/laminas-dependency-plugin dependency to https://github.com/laminas/laminas-dependency-plugin/releases/tag/2.0.0beta1? It just adds composer 2.0 support.

InMemory and ObjectRepository Role providers do not have the same behavior

The InMemoryRoleProvider and the ObjectRepositoryRoleProvider do not implement the getRoles($roleNames) in the same way.

InMemoryRoleProvider::getRoles($roleNames) will return an array of roles matching the $roleNames array. If a roleName in $roleNames` is not present in the in memory config, it will create a role for that roleName with no permissions.

ObjectRepositoryRoleProvider::getRoles($roleNames) will return an array of roles matching the $roleNames array only there is a match. If a roleName in $roleNames is not present in the object repository, it will throw a RoleNotFoundException exception.

Moreover, the RoleProviderInterface interface does not state that getRoles() can throw an exception.

The Role Service, when requesting roles from the provider does not check for exceptions. This means that, in an application using ObjectRepositoryRoleProvider, if an identity has a role that does not exists in the role provider, the application will throw an exception and crash if not handled. The exception makes sense since roles assignable to identity should exist and should be enforced when creating users, roles and permissions.

On the other hand, InMemoryRoleProvider is too permissive as it will add roles in the role provider for roles that do not exist in its initial configuration. InMemoryRoleProvider was meant to be a simple solution and it is not strict in validating that a given role exist or not.

I am of the opinion, that an exception should be thrown when requesting the role provider to provide a role that does not exist.

This would be a breaking change for applications using the InMemoryRoleProvider when an unexpected exception would occur that would cause the app to crash.

Package incompatible with php 8.1

I tested using this package with php 8.1 and it generated the following error.

During inheritance of ArrayIterator: Uncaught Whoops\Exception\ErrorException: Return type of Rbac\Traversal\RecursiveRoleIterator::valid() should either be compatible with ArrayIterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/vendor/zfr/rbac/src/Rbac/Traversal/RecursiveRoleIterator.php:37 Stack trace: #0 /var/www/html/vendor/zfr/rbac/src/Rbac/Traversal/RecursiveRoleIterator.php(18): Whoops\Run->handleError() #1 /var/www/html/vendor/composer/ClassLoader.php(571): include('/var/www/html/v...') #2 /var/www/html/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile() #3 /var/www/html/vendor/lm-commons/lmc-rbac-mvc/src/Collector/RbacCollector.php(161): Composer\Autoload\ClassLoader->loadClass() #4 /var/www/html/vendor/lm-commons/lmc-rbac-mvc/src/Collector/RbacCollector.php(111): LmcRbacMvc\Collector\RbacCollector->collectIdentityRolesAndPermissions() #5 /var/www/html/vendor/laminas/laminas-developer-tools/src/Profiler.php(202): LmcRbacMvc\Collector\RbacCollector->collect() #6 /var/www/html/vendor/laminas/laminas-developer-tools/src/Listener/ProfilerListener.php(86): Laminas\DeveloperTools\Profiler->collect() #7 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Laminas\DeveloperTools\Listener\ProfilerListener->onFinish() #8 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(171): Laminas\EventManager\EventManager->triggerListeners() #9 /var/www/html/vendor/laminas/laminas-mvc/src/Application.php(334): Laminas\EventManager\EventManager->triggerEvent() #10 /var/www/html/public/index.php(41): Laminas\Mvc\Application->run() #11 {main}

Version 4 Plan - Features and Enhancements Roadmap

Version 4 Plan - Features and Enhancements Roadmap

This is to document the enhancements, features and other changes to bring to LmcRbacMvc in a forthcoming version 4.

Rationale

LmcRbacMvc v3 is a port of ZF-Commons/ZfcRbac v2 to Laminas. ZfcRbac v2 was developed several years ago and was based on Zend Framework v2 and v3. The port of ZfcRbac to Laminas has not brought significant improvements or new features to the package. New frameworks based on Laminas MVC, such as Laminas API Tools have, come along and the Laminas Components have also evolved. It is long overdue to give it a serious upgrade.

LmcRbacMvc has been installed more than 100K times according to Packagist which is a good indication that the package has its usefulness in web application. We are looking for users of the package to provide inputs into the development roadmap for Version 4.

Process

  • Comment on this issue if you want to add an enhancement or a feature to be included in Version 4.
  • Issues will be created for enhancements/features selected for inclusion in V4 and will be added to the development Backlog and will be labeled as v4
  • Development toward V4 will be done on the 4.x branch.
  • A GitHub project for LmcRbacMvc was created and issues to be added to the project so that progress can be managed
  • Issues will be assigned to contributors

Selected Enhancements

  • Remove dependency on Zfr/Rbac (#3 )
  • Move Developer Tools to a separate package (#32)
  • Add type declarations where missing (#38)
  • Drop support for PHP 7.4 and 8.0 (#39)
  • Use another CI provider (#37)
  • Add support for PHP 8.2 (#40)
  • Refactor factories (#99)

Proposed enhancements

  • Improve documentation (better guides, better class description)

Won't do

  • Move Doctrine Support to a separate library (#44)

Add support for PHP 8.3

Update dependencies to use packages supporting 8.3:

  • Need to bump doctrine/doctrine-orm-module to a later version

Add PHP 8.3 testing to CI Build

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.