prooph/service-bus-zfc-rbac-bridge
最新稳定版本:v1.1
Composer 安装命令:
composer require prooph/service-bus-zfc-rbac-bridge
包简介
Marry Service Bus with ZfcRbac
关键字:
README 文档
README
Marry Service Bus with ZfcRbac
Important
This library will receive support until December 31, 2019 and will then be deprecated.
For further information see the official announcement here: https://www.sasaprolic.com/2018/08/the-future-of-prooph-components.html
Installation
- Add
"prooph/service-bus-zfc-rbac-bridge": "~1.0"as requirement to your composer.json. - In the
configfolder you will find a configuration skeleton. The configuration is a simple PHP array flavored with some comments to help you understand the structure.
Requirements
- Your Inversion of Control container must implement the interop-container interface.
- ZfcRbac's authorization service should be registered in the container under the
ZfcRbac\Service\AuthorizationServicekey.
Note: Don't worry, if your environment doesn't provide the requirements. You can always bootstrap the authorization service by hand. Just look at the factories for inspiration in this case.
Sample
Assuming a TestQuery with message name test and you want to use the route guard and finalize guard together with an assertion (TestAssertion), your config should look like this:
return [
'prooph' => [
'service_bus' => [
'query_bus' => [
'plugins' => [
\Prooph\ServiceBus\RouteGuard::class,
\Prooph\ServiceBus\FinalizeGuard::class,
]
]
]
],
'zfc_rbac' => [
'assertion_manager' => [
'TestAssertion' => 'TestAssertion',
],
'assertion_map' => [
'test' => 'TestAssertion'
],
'role_provider' => [
'ZfcRbac\Role\InMemoryRoleProvider' => [
'user' => [
'permissions' => [
'test'
]
]
]
]
]
];
And your TestAssertion should look like this:
class TestAssertion implements \ZfcRbac\Assertion\AssertionInterface
{
public function assert(AuthorizationService $authorizationService, $context = null)
{
// return true, if no context present, otherwise your route guard will always fail, because the result is not yet known.
if (null === $context) {
return true;
}
return ($context['owner'] == $authorizationService->getIdentity());
}
}
Support
- Ask questions on Stack Overflow tagged with #prooph.
- File issues at https://github.com/prooph/service-bus-zfc-rbac-bridge/issues.
- Say hello in the prooph gitter chat.
Contribute
Please feel free to fork and extend existing or add new features and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.
License
Released under the New BSD License.
统计信息
- 总下载量: 25.1k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-09-11