Give permission to bjyauthorize to run the mvc ZF2 application from the CLI

I have a fully running mvc application on ZF2. I want to run some actions from the command line. I correctly configured my console routes and other environments. When I run my application from the CLI, I got a Permission denied exception like this:

'You are not authorized to access GeneratePdf\Controller\GeneratePdf\GeneratePdf:generate-all' in /var/www/zf2-reporting/module/BjyAuthorize/src/BjyAuthorize/Guard/Controller.phpβ€Œβ€‹:172

I already have a user in my database. How can I use these credentials to authorize the CLI user to trigger actions?

Edit :

The following is an array of guards in bjyauthorize.global.php for the specified controller.

'guards' => array(
'BjyAuthorize\Guard\Controller' => array(array('controller' => 'GeneratePdf\Controller\GeneratePdf', 'roles' => array('admin', 'letters_admin'))

I also used ZfcUser. How can I pass user credentials from CLI. Or if there is any way to use a user session from cli.

thanks

+4
1

. cli, , bjyAuthorize CLI.

: BjyAuthorize CLI ZF2?

, :

bjyAuthorize cli, , application.config.php.

"BjyAuthorize" "BjyProfiler" application.config.php. , , $config array.

if (!Console::isConsole()) {
    array_unshift($config['modules'], 'BjyAuthorize');
    array_unshift($config['modules'], 'BjyProfiler');
}
return $config;

/Module.php onBootstrap,

if (!Console::isConsole()) {
        $authorize = $sm->get('BjyAuthorize\Service\Authorize');
        $acl = $authorize->getAcl();
        $role = $authorize->getIdentity();
    }

, : :

use Zend\Console\Console;
+4

All Articles