raegmaen/openid-connect-php

OpenID Connect 客户端

0.2.1 2018-11-21 13:28 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:49:24 UTC


README

PHP 库,用于通过 OpenId Connect 协议(OpenId Connect 协议)对身份提供者进行用户认证。
实现的使用案例

  1. 使用授权码流程进行认证
  2. 使用刷新令牌刷新访问令牌

需求

  1. PHP 5.6 或更高版本
  2. CURL 扩展
  3. JSON 扩展

安装

Composer

composer require raegmaen/openid-connect-php

许可证

Apache 许可证,版本 2.0

示例

$openIdConnectClient = OpenIdConnectFactory::create(
    $providerUrl,
    $clientId,
    $clientSecret,
    $callbackUrl
);

$authenticationResult = $this->openIdConnectClient->authenticate($requestData);
if ($authenticationResult instanceof UserRedirect) {
    // Redirect user to given Url
}

$claims = $authenticationResult->getIdToken()->getClaims();

$name = $claims->get('given_name');