linkorb/userbase-role-provider-bundle
Composer 安装命令:
composer require linkorb/userbase-role-provider-bundle
包简介
Userbase Role Provider Bundle for modern Symfony Applications
README 文档
README
Userbase Role Provider Bundle
Use this bundle to add Roles to Users loaded by the UserProvider.
Userbase does not provide Role information about its users so apps need to supply their own. This bundle allows you to define fixed roles for your users and these will be incorporated into the User objects loaded by the Userbase UserProvider.
Define the fixed roles in a Yaml file at config/roles.yaml:-
my-username: [ROLE_ADMIN] some-other-username: [ROLE_USER]
Next, clear the app cache so that the roles are baked into the service container configuration. And that's it! You can now restrict access to resources based on these roles.
The bundle will load roles from the roles.yaml file without any further
configuration. It can instead be made to load roles from the environment.
Populating a service parameter named userbase.roles is the key to this
alternative configuration:
# add to a .env file
USERBASE_ROLES='{"adele":["ROLE_ADMIN"]}'
# add to config/services.yaml
parameters:
userbase.roles: '%env(json:USERBASE_ROLES)%'
# add to config/packages/userbase.yaml
userbase_role_provider:
fixed_roles:
from_files: false
The change to userbase.yaml will require that the app cache is cleared. Then
the roles will be loaded from the USERBASE_ROLES environment variable at the
start of every request.
Installation
Note: this feature requires version 1.7 or later of the userbase/client package. You may need to begin installation by issuing:-
$ composer require "linkorb/userbase-client ^1.7"
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
$ composer require linkorb/userbase-role-provider-bundle
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require linkorb/userbase-role-provider-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php file of your project:
// config/bundles.php return [ // ... LinkORB\Userbase\RoleProvider\UserbaseRoleProviderBundle::class => ['all' => true], ];
linkorb/userbase-role-provider-bundle 适用场景与选型建议
linkorb/userbase-role-provider-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 473 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 07 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 linkorb/userbase-role-provider-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 linkorb/userbase-role-provider-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 473
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-01