akamai-open / edgegrid-auth
实现了由https://developer.akamai.com/introduction/Client_Auth.html指定的Akamai {OPEN} EdgeGrid身份验证
2.0.0
2022-10-14 15:00 UTC
Requires
- php: >=8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- humbug/box: >=4.1.0
- phpspec/prophecy: ~1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
Suggests
- akamai-open/edgegrid-client: Provide a fully featured HTTP client & CLI pre-configured with EdgeGrid authentication. (PHP 8.1+)
This package is auto-updated.
Last update: 2024-09-18 17:23:14 UTC
README
此库需要PHP 8+,并为PHP实现了Akamai EdgeGrid身份验证方案。
安装
要安装,请使用composer
$ composer require akamai-open/edgegrid-auth
其他安装方法
单个文件(PHAR)
从发行版页面下载PHAR文件,并将其包含在您的代码中
```php
include 'akamai-open-edgegrid-auth.phar';
// Library is ready to use
```
克隆或下载
-
您可以选择克隆或下载以获取此存储库的副本。
- 使用git或subversion克隆此存储库。
- 下载最新的ZIP存档或特定版本的ZIP存档。
-
使用composer自动加载器并安装依赖项。
$ composer install
-
包含自动加载器。
require_once 'vendor/autoload.php';
如果您不使用自动加载器,请手动将所有必需的类包含在您的代码中。
require_once 'src/Authentication.php'; require_once 'src/Authentication/Timestamp.php'; require_once 'src/Authentication/Nonce.php'; require_once 'src/Authentication/Exception.php'; require_once 'src/Authentication/Exception/ConfigException.php'; require_once 'src/Authentication/Exception/SignerException.php'; require_once 'src/Authentication/Exception/SignerException/InvalidSignDataException.php';
使用
安装库后,您可以通过调用适当的\Akamai\Open\Edgegrid\Authentication::set*()
方法创建头部值。
例如,使用内置的流HTTP客户端可能如下所示
$auth = \Akamai\Open\EdgeGrid\Authentication::createFromEdgeRcFile('default', '/.edgerc'); $auth->setHttpMethod('GET'); $auth->setPath('/identity-management/v3/user-profile'); $context = array( 'http' => array( 'header' => array( 'Authorization: ' . $auth->createAuthHeader(), 'Content-Type: application/json' ) ) ); $context = stream_context_create($context); $response = json_decode(file_get_contents('https://' . $auth->getHost() . $auth->getPath(), null, $context));
许可证
版权© 2022 Akamai Technologies, Inc. 保留所有权利
根据Apache许可证第2版(“许可证”)许可;除非您遵守许可证,否则不得使用此文件。您可以在https://apache.ac.cn/licenses/LICENSE-2.0获取许可证副本。
除非适用法律要求或书面同意,否则在许可证下分发的软件按“现状”分发的,不提供任何明示或暗示的保证或条件。有关许可证管理权限和限制的特定语言,请参阅许可证。