il-k-honda-akamai-open/edgegrid-client
Composer 安装命令:
composer require il-k-honda-akamai-open/edgegrid-client
包简介
Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client_Auth.html
README 文档
README
Akamai {OPEN} EdgeGrid Authentication Client for PHP
Note: in version 0.6.0 the
\Akamai\Open\EdgeGrid\Authenticationlibrary itself has been moved to a seperate akamai-open/edgegrid-auth package.
This library implements the Akamai {OPEN} EdgeGrid Authentication scheme on top of Guzzle, as both a drop-in replacement client, and middleware.
For more information visit the Akamai {OPEN} Developer Community.
Installation
This library requires PHP 5.5+, or HHVM 3.5+ to be used with the built-in Guzzle HTTP client.
To install, use composer:
$ composer require akamai-open/edgegrid-client
Alternative (single file) Install
Alternatively, download the PHAR file from the releases page.
To use it, you just include it inside your code:
include 'akamai-open-edgegrid-client.phar'; // Library is ready to use
Client Usage
The Akamai\Open\EdgeGrid\Client extends \GuzzleHttp\Client and transparently enables you to sign API requests,
without interfering with other usage - this makes it a drop-in replacement, with the exception that you must call
\Akamai\Open\EdgeGrid\Client->setAuth() (or provide an instance of \Akamai\Open\EdgeGrid\Authentication to the
constructor) prior to making a request to an API.
$client = new Akamai\Open\EdgeGrid\Client([ 'base_uri' => 'https://akaa-baseurl-xxxxxxxxxxx-xxxxxxxxxxxxx.luna.akamaiapis.net' ]); $client->setAuth($client_token, $client_secret, $access_token); // use $client just as you would \Guzzle\Http\Client $response = $client->get('/billing-usage/v1/products');
Using a Credentials File
We recommend using a .edgerc credentials file. Credentials can be generated using information on the developer site at: https://developer.akamai.com/introduction/Prov_Creds.html
Your .edgerc should look something like this:
[default]
client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
host = xxxxx.luna.akamaiapis.net/
access_token = xxxxx
client_token = xxxxx
To utilize this use the factory method \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile().
To create a client using the default credentials, in an .edgerc file that exists inside the HOME directory of the web server user, or in the current working directory:
$client = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile(); // use $client just as you would \Guzzle\Http\Client $response = $client->get('/billing-usage/v1/products');
Or, specify a credentials section and/or .edgerc location:
$client = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile('example', '../config/.edgerc'); // use $client just as you would \Guzzle\Http\Client $response = $client->get('/billing-usage/v1/products');
Command Line Interface
To aid in testing, exploration, and debugging, this library features a CLI that mimics httpie and provides a limited facsimile of it's capabilities as documented here.
If you install via composer, the CLI tool is available as vendor/bin/http, or you can simply execute the PHAR file.
# Composer installed $ ./vendor/bin/http --help # For Windows > php ./vendor/bin/http --help # PHAR download php akamai-open-edgegrid-client.phar --help
Arguments
Arguments are similar to httpie:
--auth-type={edgegrid,basic,digest}— Set the authentication type (default: none)--auth user:or--a user:— Set the.edgercsection to use. Unlikehttpie-edgegridthe:is optional
You can also specify an HTTP method (HEAD|GET|POST|PUT|DELETE - case-insensitive).
Finally, you can easily specify headers and JSON body fields, using the following syntaxes:
Header-Name:value— Headers and values are:separatedjsonKey=value— Sends{"jsonKey": "value"}in thePOSTorPUTbody. This will also automatically set theContent-TypeandAcceptheaders toapplication/json.jsonKey:=[1,2,3]— Allows you to specify raw JSON data, sending{"jsonKey": [1, 2, 3]}in the body.
Limitations
- You cannot send
multipart/mime(file upload) data - Client certs are not supported
- Server certs cannot be verified
- Output cannot be customized, all HTTP and body data (request and response) is shown
- Responses are not syntax highlighted (although JSON is formatted)
Guzzle Middleware
This package provides three different middleware handlers:
\Akamai\Open\EdgeGrid\Handler\Authentication- provides transparent API request signing\Akamai\Open\EdgeGrid\Handler\Verbose- easily output (or log) responses\Akamai\Open\EdgeGrid\Handler\Debug- easily output (or log) errors
All three can be added transparently when using the Client, or added to a standard \GuzzleHttp\Client, or by adding them as a handler.
Transparent Usage
To enable Authentication call Client->setAuthentication(), or pass in an instance of \Akamai\EdgeGrid\Authentication
to Client->__construct().
To enable Verbose call Client->setInstanceVerbose() or Client::setVerbose() passing in on of true|resource|[resource output, resource error]. Defaults to [STDOUT, STDERR]`.
To enable Debug call Client->setInstanceDebug(), Client::setDebug(), or set the debug config option with true|resource. Defaults to STDERR.
Middleware
Authentication Handler
// Create the Authentication Handler $auth = \Akamai\Open\EdgeGrid\Handler\Authentication::createFromEdgeRcFile(); // or: $auth = new \Akamai\Open\EdgeGrid\Handler\Authentication; $auth->setAuth($client_token, $client_secret, $access_token); // Create the handler stack $handlerStack = \GuzzleHttp\HandlerStack::create(); // Add the Auth handler to the stack $handlerStack->push($auth); // Add the handler to a regular \GuzzleHttp\Client $guzzle = new \GuzzleHttp\Client([ "handler" => $handlerStack ]);
Verbose Handler
// Create the handler stack $handlerStack = HandlerStack::create(); // Add the Auth handler to the stack $handlerStack->push(new \Akamai\Open\EdgeGrid\Handler\Verbose()); // Add the handler to a regular \GuzzleHttp\Client $guzzle = new \GuzzleHttp\Client([ "handler" => $handlerStack ]);
Debug Handler
// Create the handler stack $handlerStack = HandlerStack::create(); // Add the Auth handler to the stack $handlerStack->push(new \Akamai\Open\EdgeGrid\Handler\Debug()); // Add the handler to a regular \GuzzleHttp\Client $guzzle = new \GuzzleHttp\Client([ "handler" => $handlerStack ]);
Using PHP 5.3 (not recommended)
PHP 5.3 has been EOL since August 14th, 2014, and has known security vulnerabilities, therefore we do not recommend using it. However, we understand that many actively supported LTS distributions are still shipping with PHP 5.3, and therefore we are providing the following information.
The signer itself is PHP 5.3 compatible and has been moved to the akamai-open/edgegrid-auth package.
Author
Davey Shafik dshafik@akamai.com
License
Copyright 2016 Akamai Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
il-k-honda-akamai-open/edgegrid-client 适用场景与选型建议
il-k-honda-akamai-open/edgegrid-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 751 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Authentication」 「client」 「open」 「akamai」 「edgegrid」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 il-k-honda-akamai-open/edgegrid-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 il-k-honda-akamai-open/edgegrid-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 il-k-honda-akamai-open/edgegrid-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Netgen Open Graph Bundle is an Ibexa Platform bundle that allows simple integration with Open Graph protocol.
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
Mock PSR-18 HTTP client
统计信息
- 总下载量: 751
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2022-03-29