Skip to content

Commit

Permalink
Merge pull request #21 from sausin/sausin-patch-2
Browse files Browse the repository at this point in the history
Support for keystone v3 in OVH
  • Loading branch information
sausin authored Jan 9, 2020
2 parents 972cba0 + 8889ee7 commit 1f864b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4

install:
- travis_retry composer update
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Install via composer:
composer require sausin/laravel-ovh
```
Note: Branch 1.2.x works for PHP versions < 7.2

Note: Branch 2.x works with soon to be deprecated v2 of the OVH keystone API

Then include the service provider in config/app.php
```php
Expand All @@ -36,8 +36,8 @@ as below
'driver' => 'ovh',
'user' => env('OVH_USER'),
'pass' => env('OVH_PASS'),
'userDomain' => env('OVH_USER_DOMAIN', 'Default'),
'region' => env('OVH_REGION'),
'tenantName' => env('OVH_TENANT_NAME'),
'container' => env('OVH_CONTAINER'),
'projectId' => env('OVH_PROJECT_ID'),
'urlKey' => env('OVH_URL_KEY'),
Expand Down
29 changes: 12 additions & 17 deletions src/OVHServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
namespace Sausin\LaravelOvh;

use BadMethodCallException;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
use OpenStack\Common\Transport\Utils as TransportUtils;
use OpenStack\Identity\v2\Service;
use OpenStack\OpenStack;

class OVHServiceProvider extends ServiceProvider
Expand Down Expand Up @@ -44,7 +40,7 @@ public function boot()
protected function checkConfig($config)
{
// needed keys
$needKeys = ['server', 'region', 'user', 'pass', 'tenantName', 'projectId', 'container'];
$needKeys = ['server', 'region', 'user', 'pass', 'userDomain', 'projectId', 'container'];

if (count(array_intersect($needKeys, array_keys($config))) === count($needKeys)) {
return;
Expand All @@ -62,21 +58,20 @@ protected function checkConfig($config)
*/
protected function makeClient($config)
{
// this is needed because default setup of openstack leads to authentication
// going to wrong path of the auth url as OVH uses deprecated version
$httpClient = new Client([
'base_uri' => TransportUtils::normalizeUrl($config['server']),
'handler' => HandlerStack::create(),
]);

// setup the client for OpenStack v1
// setup the client for OpenStack
return new OpenStack([
'authUrl' => $config['server'],
'region' => $config['region'],
'username' => $config['user'],
'password' => $config['pass'],
'tenantName' => $config['tenantName'],
'identityService' => Service::factory($httpClient),
'user' => [
'name' => $config['user'],
'password' => $config['pass'],
'domain' => ['name' => 'userDomain'],
],
'scope' => [
'project' => [
'id' => $config['projectId'],
],
],
]);
}

Expand Down

0 comments on commit 1f864b5

Please sign in to comment.