zploited / laravel-identity
Laravel 的身份验证客户端,简化了向您的身份租户的身份验证流程。
dev-main
2023-09-24 12:36 UTC
Requires
- php: ^8.0
- laravel/framework: ^9.29|^10.0
- zploited/php-identity: dev-main
Requires (Dev)
- orchestra/testbench: ^7.7
This package is auto-updated.
Last update: 2024-09-24 14:56:49 UTC
README
安装
包安装
可以使用 composer 安装 Laravel 包
composer require zploited/laravel-identity
之后,您需要在 .env 文件中配置您的客户端信息,使用以下设置
IDENTITY_IDENTIFIER=<tenant identifying domain name> IDENTITY_CLIENT_ID=<identifier of the app> IDENTITY_CLIENT_SECRET=<secret of the app> IDENTITY_REDIRECT_URI=<redirect url, that will handle incoming token> IDENTITY_SCOPE=<scopes to use> IDENTITY_PROTOCOL=<http or https - default is https>
守卫
该包包含两个不同的守卫,各自服务于不同的目的。
- identity:session
- identity:bearer
您需要在 config/auth.php 文件中添加您想要使用的守卫。这可以通过向文件的 'guards' 部分添加您想要使用的驱动程序来实现,例如。
'guards' => [ 'web' => [ 'driver' => 'identity:session' ], ],
注意,提供商已被删除,因为守卫不使用提供商。
使用
Identity 类
从现在起,所有操作都通过 Zploited\Identity\Client\Identity 类处理。它可以通过依赖注入实例化,或者通过以下方式:
$identity = app()->make(Zploited\Identity\Client\Identity::class);
这将获取从 config/identity-client.php 中配置的实例。