graphene-ict / laravel-cognito-guard
Laravel 验证 AWS Cognito 用户池发布的 JSON Web Tokens (JWT) 的身份验证保护器
v1.0.0
2022-09-25 10:33 UTC
Requires
- php: ^7.3|^8.0
- aws/aws-sdk-php: ^3.235
- firebase/php-jwt: ^6.3
- fruitcake/laravel-cors: ^2.0
- guzzlehttp/guzzle: ^7.0.1
- lcobucci/jwt: ^4.2
- phpseclib/phpseclib: ^3.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
- dev-main
- v1.0.0
- dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-5
- dev-dependabot/github_actions/actions/checkout-4
- dev-dependabot/github_actions/aglipanci/laravel-pint-action-2.3.0
- dev-dependabot/github_actions/ramsey/composer-install-2
- dev-develop
- dev-feature/additionals
- dev-feature/tests
- dev-feature/fix-namespaces
This package is auto-updated.
Last update: 2024-09-09 09:38:02 UTC
README
Laravel 验证 AWS Cognito 用户池发布的 JSON Web Tokens (JWT) 的身份验证保护器
安装
您可以通过 composer 安装此包
composer require graphene-ict/laravel-cognito-guard
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="GrapheneICT\CognitoGuard\Services\CognitoAuthServiceProvider" --tag="config"
这是已发布配置文件的内容
return [ /* * If persist_user_data is true the cognito guard will automatically create a new user * record anytime the user contained in a validated JWT * does not already exist in the users table. * * The new user will be created with the user attributes name, email, provider and provider_id so * it is required for you to add them at the list of fillable attributes in the model array, if you * wish to add more attributes from the cognito modify before it is saved or use the events. * */ 'persist_user_data' => true, 'models' => [ /* * When using this package, we need to know which * Eloquent model should be used for your user. Of course, it * is often just the "User" model but you may use whatever you like. * */ 'user' => [ 'model' => App\Models\User::class, ], ], ];
由于 persist_user_data 默认为 true,用户将自动保存以下属性:name, email, provider 和 provider_id,因此必须在可填充列表中添加它们。如果您想使用 CognitoService 类扩展更多属性,请在保存之前修改数据或使用事件。
$cognitoService = new CognitoService(); $attributes = $cognitoService->getCognitoUserAttributes($token);
使用方法
在配置auth中使用 coginto 驱动器创建额外的保护器
'api' => [ 'driver' => 'cognito', 'provider' => 'users', ],
之后,只需将其应用于以下所示的认证默认值作为认证选项
'defaults' => [ 'guard' => 'api', 'passwords' => 'users', ],
更新日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
有关详细信息,请参阅 CONTRIBUTING。
安全漏洞
请查阅 我们的安全策略 了解如何报告安全漏洞。
鸣谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。