treehouselabs / keystone-client
An HTTP client with automatic authentication for an OpenStack Identity Service API a.k.a. Keystone
Installs: 80 736
Dependents: 1
Suggesters: 1
Security: 0
Stars: 0
Watchers: 11
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=5.6
- guzzlehttp/guzzle: ^6.0
- psr/cache: ^1.0
- psr/http-message: ^1.0
- psr/log: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.0
- symfony/cache: *
This package is auto-updated.
Last update: 2024-10-29 04:09:19 UTC
README
A client to use when communicating with Keystone services. Uses Guzzle as the actual HTTP client library.
Installation
composer require treehouselabs/keystone-client:~3.0
Usage
Use the ClientFactory
to create a Guzzle Client with. The factory attaches
middleware that automatically requests a Keystone token and signs outgoing
requests with it.
In the case of an expired token, and the request fails, a new token is fetched automatically and the request is retried with the new token.
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/');
Testing
composer test
Security
If you discover any security related issues, please email peter@treehouse.nl instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.