Skip to content

Instantly share code, notes, and snippets.

@apoca
Created May 1, 2014 16:45
Show Gist options
  • Save apoca/08f14a43dd4ba30731e4 to your computer and use it in GitHub Desktop.
Save apoca/08f14a43dd4ba30731e4 to your computer and use it in GitHub Desktop.
ERROR:
Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'ZfcRbac\Role\RoleProviderPluginManager::get was unable to fetch or create an instance for ' in /Applications/MAMP/htdocs/RadiusCheck/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:529 Stack trace: #0 /Applications/MAMP/htdocs/RadiusCheck/vendor/zendframework/zendframework/library/Zend/ServiceManager/AbstractPluginManager.php(103): Zend\ServiceManager\ServiceManager->get(NULL, true) #1 /Applications/MAMP/htdocs/RadiusCheck/vendor/zf-commons/zfc-rbac/src/ZfcRbac/Factory/RoleServiceFactory.php(51): Zend\ServiceManager\AbstractPluginManager->get(NULL, false) #2 [internal function]: ZfcRbac\Factory\RoleServiceFactory->createService(Object(Zend\ServiceManager\ServiceManager), 'zfcrbacservicer...', 'ZfcRbac\Service...') #3 /Applications/MAMP/htdocs/RadiusCheck/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(902): call_user_func(Array, Object(Zend\ServiceManage in /Applications/MAMP/htdocs/RadiusCheck/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 529
zfc-rbac.global.php
return [
'zfc_rbac' => [
/**
* Key that is used to fetch the identity provider
*
* Please note that when an identity is found, it MUST implements the ZfcRbac\Identity\IdentityProviderInterface
* interface, otherwise it will throw an exception.
*/
'identity_provider' => 'Zend\Authentication\AuthenticationService',
/**
* Set the guest role
*
* This role is used by the authorization service when the authentication service returns no identity
*/
'guest_role' => 'guest',
/**
* Set the guards
*
* You must comply with the various options of guards. The format must be of the following format:
*
* 'guards' => [
* 'ZfcRbac\Guard\RouteGuard' => [
* // options
* ]
* ]
*/
'guards' => [
'ZfcRbac\Guard\RouteGuard' => [
'login' => ['guest'],
'admin' => ['admin']
]
],
/**
* As soon as one rule for either route or controller is specified, a guard will be automatically
* created and will start to hook into the MVC loop.
*
* If the protection policy is set to DENY, then any route/controller will be denied by
* default UNLESS it is explicitly added as a rule. On the other hand, if it is set to ALLOW, then
* not specified route/controller will be implicitly approved.
*
* DENY is the most secure way, but it is more work for the developer
*/
'protection_policy' => \ZfcRbac\Guard\GuardInterface::POLICY_ALLOW,
/**
* Configuration for role provider
*
* It must be an array that contains configuration for the role provider. The provider config
* must follow the following format:
*
* 'ZfcRbac\Role\InMemoryRoleProvider' => [
* 'role1' => [
* 'children' => ['children1', 'children2'], // OPTIONAL
* 'permissions' => ['edit', 'read'] // OPTIONAL
* ]
* ]
*
* Supported options depend of the role provider, so please refer to the official documentation
*/
'role_provider' => [],
/**
* Configure the unauthorized strategy. It is used to render a template whenever a user is unauthorized
*/
'unauthorized_strategy' => [
/**
* Set the template name to render
*/
'template' => 'error/403'
],
/**
* Configure the redirect strategy. It is used to redirect the user to another route when a user is
* unauthorized
*/
'redirect_strategy' => [
/**
* Set the route to redirect when user is connected (of course, it must exist!)
*/
'redirect_to_route_connected' => 'admin',
/**
* Set the route to redirect when user is disconnected (of course, it must exist!)
*/
'redirect_to_route_disconnected' => 'login',
/**
* If a user is unauthorized and redirected to another route (login, for instance), should we
* append the previous URI (the one that was unauthorized) in the query params?
*/
// 'append_previous_uri' => true,
/**
* If append_previous_uri option is set to true, this option set the query key to use when
* the previous uri is appended
*/
// 'previous_uri_query_key' => 'redirectTo'
],
/**
* Various plugin managers for guards and role providers. Each of them must follow a common
* plugin manager config format, and can be used to create your custom objects
*/
// 'guard_manager' => [],
// 'role_provider_manager' => []
]
];
-----------
MODULE.php
public function getServiceConfig()
{
return array(
'factories' => array(
'Zend\Log\FirePhp' => function ($sm)
{
$writer_firebug = new \Zend\Log\Writer\FirePhp();
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer_firebug);
return $logger;
},
'Zend\Authentication\AuthenticationService' => function ($serviceManager)
{
// If you are using DoctrineORMModule:
return $serviceManager->get('doctrine.authenticationservice.orm_default');
}
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment