tiriel/firestore-security-bridge
Composer 安装命令:
composer require tiriel/firestore-security-bridge
包简介
Symfony Bridge to provide UserProvider for Firestore-persisted users in Symfony
README 文档
README
A small bridge to be used in conjunction with Firestore ODM Bundle. This bridge allows you to use your Firestore DTO as users in Symfony's Security Bundle.
Requirements
This bundle requires PHP 8.2+, Symfony 7+, and Firestore ODM Bundle.
This bundle also relies heavily on Google Glouc Firestore PHP Client, and its technical requirements are the same (most notably PHP gRPC and Protobuf extensions). See Google's documentation for more details.
Installation
If you have Symfony Flex, a contrib recipe is available:
composer require tiriel/firestore-security-bridge
That's it, you're good to go.
If you haven't got Flex installed, first require the bundle as shown above.
Then, enable the bundle in the config/bundles.php file:
<?php return [ // ... Tiriel\FirestoreOdmBundle\TirielFirestoreOdmBundle::class => ['all' => true], Tiriel\FirestoreSecurityBridge\TirielFirestoreSecurityBundle::class => ['all' => true], ];
You can now reuse the file config/packages/tiriel.yaml from Firestore ODM and add the following content:
tiriel_firestore_odm: # ... tiriel_firestore_security: # The service id or the manager responsible for the DTO you want to use as UserInterface user_manager: App\Manager\UserFirestoreDtoManager
Usage
User DTO
See the documentation for Firestore ODM Bundle if you want a basic understanding of how DTOs are used in Firebase ODM.
In addition, the DTO you wish to use as your Security user should extend Tiriel\FirestoreSecurityBridge\Dto\AbstractUser.
This class implements Tiriel\FirestoreOdmBundle\Dto\Interface\PersistableDtoInterface
and Symfony\Component\Security\Core\User\UserInterface.
If you want your users to be authenticated using password, you can still implement
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface.
Example:
use Tiriel\FirestoreSecurityBridge\Dto\AbstractUser; class User extends AbstractUser implements PasswordAuthenticatedUserInterface { // ...
You can now create a manager for your DTO as usual per Firestore ODM Bundle's documentation.
Using the DTO and Manager in the Security Bundle
You are now set to use your new DTO and its manager in your firewalls, simply define a new
User Provider in config/packages/security.yaml with the id tiriel.firestore_security.user_provider:
security: # ... # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider providers: # used to reload user from session & other features (e.g. switch_user) app_user_provider: id: 'tiriel.firestore_security.user_provider'
You are now set, you can use your User DTO as a security User.
tiriel/firestore-security-bridge 适用场景与选型建议
tiriel/firestore-security-bridge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tiriel/firestore-security-bridge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tiriel/firestore-security-bridge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-30