承接 nekman/aws-ring-http-signer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nekman/aws-ring-http-signer

最新稳定版本:2.0.0

Composer 安装命令:

composer require nekman/aws-ring-http-signer

包简介

Sign Ring HTTP calls using AWS credentials

README 文档

README

Build Status Coverage Status

RingPHP has been discontinued. This package does not make sense any more.

In order for AWS to know who/what is making the request it needs to be signed. Using this package, you can sign RingPHP requests with AWS credentials.

Do you want to use this with your Elasticsearch instance hosted on AWS? See the Usage with Elasticsearch section below.

Usage

Install with Composer:

composer require nekman/aws-ring-http-signer

In order to instantiate a new instance of the library, use the factory. Then wrap your Ring HTTP handler with the middleware and use it as normal:

use GuzzleHttp\Ring\Client\CurlHandler;
use Aws\Signature\SignatureV4;
use Nekman\AwsRingHttpSigner\AwsRingHttpSignerFactory;

$signature = new SignatureV4($awsService, $awsRegion); // How do I create this? Please consult the AWS documentation for the service you are using.
$awsRingHttpSigner = AwsRingHttpSignerFactory::create($signature);

$defaultHandler = new CurlHandler(); // Or use whatever handler you already have available.
$handler = $awsRingHttpSigner($defaultHandler);

// And you're done! Use the $handler as you normally would

Usage with Elasticsearch

Install with Composer:

composer require nekman/aws-ring-http-signer elasticsearch/elasticsearch

In order to instantiate a new instance of the library, use the factory. Then wrap your the Elasticsearch client with the middleware and use it as normal:

use Elasticsearch\ClientBuilder;
use Nekman\AwsRingHttpSigner\AwsRingHttpSignerFactory;

$awsRingHttpSigner = AwsRingHttpSignerFactory::create($awsRegion);
$handler = $awsRingHttpSigner(ClientBuilder::defaultHandler()); 

$client = ClientBuilder::create()
    ->setHandler($handler)
    ->build();

// And you're done! Use the $client as you normally would

AWS Credentials Provider and signatures

By default the library will use the default credentials provider provided by AWS. There are many other ways to load credentials which you can read about in the AWS documentation. Consult the AWS documentation on how to create a SignatureInterface.

Example

Lets say you want to provide static credentials from environment variables:

use Nekman\AwsRingHttpSigner\AwsRingHttpSignerFactory;
use Aws\Credentials\CredentialProvider;
use Aws\Credentials\Credentials;

$credentials = new Credentials(getenv("AWS_KEY"), getenv("AWS_SECRET"));
$credentialProvider = CredentialProvider::fromCredentials($credentials);

$awsRingHttpSigner = AwsRingHttpSignerFactory::create($awsRegion, $credentialProvider);

Consult the AWS documentation for more information.

Versioning

This project complies with Semantic Versioning.

Changelog

For a complete list of changes, and how to migrate between major versions, see releases page.

统计信息

  • 总下载量: 34.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-19