treehouselabs/keystone-client

一个用于OpenStack身份服务API(Keystone)的HTTP客户端,具有自动认证功能

v4.0.0 2020-09-09 13:54 UTC

This package is auto-updated.

Last update: 2024-08-29 03:52:48 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score

用于与Keystone服务通信的客户端。使用Guzzle作为实际的HTTP客户端库。

安装

composer require treehouselabs/keystone-client:~3.0

使用

使用ClientFactory创建一个Guzzle客户端。该工厂附加了中间件,可以自动请求Keystone令牌,并用它来签名发出的请求。

如果令牌已过期且请求失败,将自动获取新的令牌,并使用新的令牌重新尝试请求。

use TreeHouse\Cache\CacheInterface;
use TreeHouse\Keystone\Client\ClientFactory;
use TreeHouse\Keystone\Client\Model\Tenant;

$tokenUrl     = 'http://example.org/tokens';
$username     = 'acme';
$password     = 's3cr4t';
$serviceType  = 'compute';
$serviceName  = 'api';

// $cache is a TreeHouse\Cache\CacheInterface instance
$tenant  = new Tenant($tokenUrl, $username, $password, $serviceType, $serviceName);
$client  = (new ClientFactory($cache))->createClient($tenant);

// now just use $client as you would a regular Guzzle client
$response = $client->get('posts/');

测试

composer test

安全性

如果您发现任何安全相关的问题,请通过电子邮件peter@treehouse.nl联系,而不是使用问题跟踪器。

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件

致谢