nekman/aws-ring-http-signer
此包已被弃用,不再维护。没有建议的替代包。
使用AWS凭证签名Ring HTTP调用
2.0.0
2021-01-10 14:36 UTC
Requires
- php: ^7.4||^8.0
- aws/aws-sdk-php: ^3.0
- guzzlehttp/psr7: ^1.0
- guzzlehttp/ringphp: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^9.0
Suggests
- elasticsearch/elasticsearch: Sign Elasticsearch requests using AWS credentials
README
RingPHP 已停止开发。此包不再有意义。
为了AWS知道谁/什么在发起请求,它需要对其进行签名。使用此包,您可以使用AWS凭证对RingPHP请求进行签名。
您想在与AWS托管的Elasticsearch实例上使用此功能吗?请参阅下文中的Elasticsearch使用方法部分。
使用方法
使用Composer安装
composer require nekman/aws-ring-http-signer
要实例化库的新实例,请使用工厂。然后使用中间件包装您的Ring HTTP处理器,并按正常方式使用它
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
Elasticsearch使用方法
使用Composer安装
composer require nekman/aws-ring-http-signer elasticsearch/elasticsearch
为了实例化库的新实例,请使用工厂。然后使用中间件包装Elasticsearch客户端,并按正常方式使用它
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凭证提供者和签名
默认情况下,库将使用AWS提供的默认凭证提供者。还有许多其他加载凭证的方法,您可以在AWS文档中了解。有关如何创建SignatureInterface的说明,请参阅AWS文档。
示例
假设您想从环境变量中提供静态凭证
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);
有关更多信息,请参阅AWS文档。
版本控制
本项目遵循语义版本控制。
变更日志
有关更改的完整列表以及如何迁移到主要版本,请参阅发行页面。