Coder Social home page Coder Social logo

Comments (10)

spiffyjr avatar spiffyjr commented on August 18, 2024

You can use the IsGranted (https://github.com/ZF-Commons/ZfcRbac/blob/master/src/ZfcRbac/Controller/Plugin/IsGranted.php) controller plugin inside actions.

from zfc-rbac.

carpanta avatar carpanta commented on August 18, 2024

Yes, I've seen this plugin but still I don't know how to implement it and even more how to get the permissions. My idea would be somehow to call this plugin in the 'Module.php' with the 'onBootstrap' method, in the main module 'Application' passing the permissions, which I don't know how to obtain.

from zfc-rbac.

carpanta avatar carpanta commented on August 18, 2024

in my module.config.php ()

module/Test/config/module.config.php

'controller_plugins' => array(
    'invokables' => array(
        'TestPlugin' => 'Test\Controller\Plugin\TestPlugin',
    )
), 

module/Test/src/Test/Controller/Plugin/TestPlugin.php

namespace Tam\Controller\Plugin;

class TestPlugin extends \ZfcRbac\Controller\Plugin\IsGranted{ }

module/Test/src/Test/Controller/IndexController.php

class IndexController extends AbstractActionController
{
public function indexAction()
{
$bool = $this->TestPlugin('test');
\Zend\Debug\Debug::dump($bool ); //bool(false)
}
}

Well that's my attempt (I know it's awful) which doesn't work and neither was my aim, just testing .. but at least I can reach somehow the IsGranted Plugin... like I said before I want to do it inside the Module.php all that stuff..

And when I changed the standard_identity to zfcuser_auth_service as explained in this link (https://github.com/ZF-Commons/ZfcRbac/wiki/How-to-use-with-zfcuser) after login with ZfcUser Module I get this message ( 'Identity must be null, a string, or an instance of ZfcRbac\Identity\IdentityInterface' ).

Thanks,

from zfc-rbac.

curtiskelsey avatar curtiskelsey commented on August 18, 2024

You have to modify the zfcuser user entity for zfcrbac. These are the additions I made for the first step of integration:

class User implements UserInterface, \ZfcRbac\Identity\IdentityInterface
...
/** 
* @var array 
*/
protected $roles;
...
/* 
* Get roles.
* 
* @return Roles
*/
public function getRoles()
{
    return array();
}

Documentation is pretty scarce. I'm working through trying to load persisted role/permission information and using it in navigation menus right now. For me its a bear. Hopefully the community can work up some more documentation.

from zfc-rbac.

carpanta avatar carpanta commented on August 18, 2024

Thanks for your answer, I will check asap. I'm agree with the lack of documentation, unfortunately this is a common problem developing web apps, they usually are not properly documented. Always would be design the app with UML before write code, but this USUALLY not happens... Anyway thanks to the community, it helps also to learn ZF2, but I'm not going to continue reading tons of code before understand how it should work

from zfc-rbac.

starx avatar starx commented on August 18, 2024

@kelsey9649 Why are returning empty array when roles are called?

from zfc-rbac.

curtiskelsey avatar curtiskelsey commented on August 18, 2024

The empty array should be your identity's array of roles.

from zfc-rbac.

bakura10 avatar bakura10 commented on August 18, 2024

Hi @carpanta ,

Next version of ZfcRbac is going to be available soon. It currently is in the "refactor" branch. It now has a lot of docs.

It should be pretty simple to use any User module, as you only need to implement the "IdentityInterface". I'm closing this :).

from zfc-rbac.

yarpo avatar yarpo commented on August 18, 2024

HI @bakura10 you meant
https://github.com/ZF-Commons/ZfcRbac/blob/master/docs/01.%20Introduction.md

Your link is broken.

from zfc-rbac.

bakura10 avatar bakura10 commented on August 18, 2024

Yes, sorry :)

from zfc-rbac.

Related Issues (20)

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.