teamgantt / user-sync
与外部存储同步用户数据
v1.3.0
2022-03-31 15:18 UTC
Requires
- php: >=7.0
- psr/log: ^1.1
Requires (Dev)
- aws/aws-sdk-php: ^3.217
- kahlan/kahlan: ^5.0
This package is not auto-updated.
Last update: 2024-09-13 03:09:02 UTC
README
与外部存储同步用户数据。
目前支持以下远程存储
用法
目前主要同步密码和电子邮件地址。这在需要同步密码的情况下可能有用,尽管典型用法并不涉及同步密码。在迁移或逐步淘汰本地密码存储期间同步密码可能是合理的。
用户可以通过构造一个返回字符串字面量 'delete'
的 getAction
方法的 SyncRequestInterface
来删除。
支持的操作是 'update'
和 'delete'
。
SyncInterface
暴露了 PHP 可调用类的契约,看起来像这样
public function __invoke(SyncableUserInterface $user, SyncRequestInterface $request);
作为 SyncRequest
包含了 SyncRequestInterface
的默认实现。
use TeamGantt\UserSync\SyncRequest; use TeamGantt\UserSync\CognitoSync; $args = []; // see CognitoSync for required arguments - note: requires aws/aws-sdk-php $sync = new CognitoSync(...$args); // note that all params to SyncRequest are optional. Syncing will or will not happen depending on what is given $request = SyncRequest::fromArray(['password' => 'newcleartextpassword', 'email_address' => 'newemail@email.com', 'action' => 'update']); $user = ExampleUserRepository::fetch($userId); // $user can be any object that implements the included SyncableUserInterface $sync($user, $request); // tada!
测试
$ composer test