zploited / php-identity
这个PHP库简化了您身份租户的身份验证流程。
dev-main
2023-09-26 12:07 UTC
Requires
- php: ^8.0|^9
- ext-json: *
- codercat/jwk-to-pem: ^1.1
- guzzlehttp/guzzle: ^7.5
- lcobucci/jwt: ^4.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-26 14:31:32 UTC
README
这个PHP库简化了您身份租户的身份验证流程。
使用方法
Oauth 2.0 身份验证
Identity对象负责处理针对您的租户的所有身份验证流程。
$identity = new \Zploited\Identity\Client\Identity([ 'identifier' => 'tenant.auth.zploited.dk' // (required) your identifier is the identifying subdomain url of your tenant. 'client_id' => 'cINJBpkw2LoLDn6p1DwgfVcj2VpBhVt5' // (required) the ID of the client you are using. 'client_secret' => 'LtjKmRKJ2h7UF745xvKC43QTlYj354zRaMzuwV7tOAMpbvmlSaNBpYW1SU6vNIP0' // (optional) if the client have a secret, it must be provided here. 'redirect_uri' => 'https://domain.tld/callback' // (optional) the url used during authorization to return to your site. 'scopes' = ['openid','email','documents:read'] // (optional) effective scopes we want to access. ]);
授权
要开始授权流程,您可以使用
$identity->beginAuthorizationFlow(bool $implicit = false); // it takes a bool argument which states if this is an implicit grant or not.
这将使浏览器重定向到授权端点,然后当授权服务器将用户重定向回您的站点时,使用redirect_uri,您将执行
$token = $identity->handleAuthorizationResponse();
这将处理传入的响应变量,如果一切看起来正常,它将为您提供Token对象。
授权类型
除了授权之外,您还可以使用以下内容,具体取决于您想使用哪种类型的授权。
$token = $identity->clientCredentials(); // if using this grant, the identity object is required to have the client_secret defined. $token = $identity->password(string $email, string $password);