Added application credential to cloud assets config

to get more granular control over scopes

Change-Id: I073155614f17ae075406902573bae791860b4e81
This commit is contained in:
smarcet 2019-01-15 08:22:36 -03:00
parent 2a43cdcb09
commit e9bcfcac09
4 changed files with 84 additions and 48 deletions

View File

@ -34,21 +34,41 @@ final class SwiftBucket implements IBucket
protected function getContainer()
{
if (!isset($this->container)) {
$openstack = new OpenStack([
$configOptions = [
'authUrl' => Config::get("cloudstorage.auth_url"),
'region' => Config::get("cloudstorage.region"),
'user' => [
'name' => Config::get("cloudstorage.user_name"),
'password' => Config::get("cloudstorage.api_key"),
];
$userName = Config::get("cloudstorage.user_name");
$userPassword = Config::get("cloudstorage.api_key");
if(!empty($userName) && !empty($userPassword)){
$configOptions['user'] = [
'name' => $userName,
'password' => $userPassword,
'domain' => ['id' => Config::get("cloudstorage.user_domain", "default")]
],
'scope' => [
];
$configOptions['scope' ] = [
'project' => [
'name' => Config::get("cloudstorage.project_name"),
'domain' => ['id' => Config::get("cloudstorage.project_domain", "default")]
],
]
]);
];
}
$appCredentialId = Config::get("cloudstorage.app_credential_id");
$appCredentialSecret = Config::get("cloudstorage.app_credential_secret");
if(isset($this->config[self::APP_CRED_ID])){
$configOptions['application_credential'] = [
'id' => $appCredentialId,
'secret' => $appCredentialSecret,
];
}
$openstack = new OpenStack($configOptions);
$this->container = $openstack->objectStoreV1()->getContainer( Config::get("cloudstorage.container"));
}

View File

@ -7,6 +7,12 @@
],
"license": "MIT",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/OpenStackweb/openstack"
}
],
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
@ -25,8 +31,8 @@
"smarcet/caldavclient": "1.1.6",
"smarcet/outlook-rest-client": "dev-master",
"idct/sftp-client": "dev-master",
"php-opencloud/openstack": "3.0.5",
"symfony/yaml": "4.2.2"
"symfony/yaml": "4.2.2",
"php-opencloud/openstack": "dev-master"
},
"require-dev": {
"filp/whoops": "^2.0",

84
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "b48ce60869f7ce9de67524c72bbc92e4",
"content-hash": "f8c3fdad0f0742b4f15e8dfee1f3034c",
"packages": [
{
"name": "cocur/slugify",
@ -1218,16 +1218,16 @@
},
{
"name": "fideloper/proxy",
"version": "4.0.0",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/fideloper/TrustedProxy.git",
"reference": "cf8a0ca4b85659b9557e206c90110a6a4dba980a"
"reference": "177c79a2d1f9970f89ee2fb4c12b429af38b6dfb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fideloper/TrustedProxy/zipball/cf8a0ca4b85659b9557e206c90110a6a4dba980a",
"reference": "cf8a0ca4b85659b9557e206c90110a6a4dba980a",
"url": "https://api.github.com/repos/fideloper/TrustedProxy/zipball/177c79a2d1f9970f89ee2fb4c12b429af38b6dfb",
"reference": "177c79a2d1f9970f89ee2fb4c12b429af38b6dfb",
"shasum": ""
},
"require": {
@ -1268,7 +1268,7 @@
"proxy",
"trusted proxy"
],
"time": "2018-02-07T20:20:57+00:00"
"time": "2019-01-10T14:06:47+00:00"
},
{
"name": "firebase/php-jwt",
@ -1821,23 +1821,23 @@
},
{
"name": "justinrainbow/json-schema",
"version": "5.2.7",
"version": "5.2.8",
"source": {
"type": "git",
"url": "https://github.com/justinrainbow/json-schema.git",
"reference": "8560d4314577199ba51bf2032f02cd1315587c23"
"reference": "dcb6e1006bb5fd1e392b4daa68932880f37550d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/8560d4314577199ba51bf2032f02cd1315587c23",
"reference": "8560d4314577199ba51bf2032f02cd1315587c23",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/dcb6e1006bb5fd1e392b4daa68932880f37550d4",
"reference": "dcb6e1006bb5fd1e392b4daa68932880f37550d4",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.1",
"friendsofphp/php-cs-fixer": "~2.2.20",
"json-schema/json-schema-test-suite": "1.2.0",
"phpunit/phpunit": "^4.8.35"
},
@ -1883,7 +1883,7 @@
"json",
"schema"
],
"time": "2018-02-14T22:26:30+00:00"
"time": "2019-01-14T23:55:14+00:00"
},
{
"name": "laravel-doctrine/extensions",
@ -2518,16 +2518,16 @@
},
{
"name": "nikic/php-parser",
"version": "v4.1.1",
"version": "v4.2.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "8aae5b59b83bb4d0dbf07b0a835f2680a658f610"
"reference": "594bcae1fc0bccd3993d2f0d61a018e26ac2865a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8aae5b59b83bb4d0dbf07b0a835f2680a658f610",
"reference": "8aae5b59b83bb4d0dbf07b0a835f2680a658f610",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/594bcae1fc0bccd3993d2f0d61a018e26ac2865a",
"reference": "594bcae1fc0bccd3993d2f0d61a018e26ac2865a",
"shasum": ""
},
"require": {
@ -2543,7 +2543,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
"dev-master": "4.2-dev"
}
},
"autoload": {
@ -2565,7 +2565,7 @@
"parser",
"php"
],
"time": "2018-12-26T11:32:39+00:00"
"time": "2019-01-12T16:31:37+00:00"
},
{
"name": "paragonie/random_compat",
@ -2614,30 +2614,29 @@
},
{
"name": "php-opencloud/openstack",
"version": "v3.0.5",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/php-opencloud/openstack.git",
"reference": "2883c92cdfe05d4a11533497c2b74cc018c7cf0b"
"url": "https://github.com/OpenStackweb/openstack.git",
"reference": "ed23384532b7a984fc7d8df8d0216dfb94ca1732"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-opencloud/openstack/zipball/2883c92cdfe05d4a11533497c2b74cc018c7cf0b",
"reference": "2883c92cdfe05d4a11533497c2b74cc018c7cf0b",
"url": "https://api.github.com/repos/OpenStackweb/openstack/zipball/ed23384532b7a984fc7d8df8d0216dfb94ca1732",
"reference": "ed23384532b7a984fc7d8df8d0216dfb94ca1732",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "~6.1",
"justinrainbow/json-schema": "~5.2",
"guzzlehttp/guzzle": "^6.1",
"justinrainbow/json-schema": "^5.2",
"php": "~7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.9",
"friendsofphp/php-cs-fixer": "^2.13",
"jakub-onderka/php-parallel-lint": "^1.0",
"php-coveralls/php-coveralls": "^2.0",
"phpunit/phpunit": "^6.5",
"psr/log": "^1.0",
"sami/sami": "dev-master",
"satooshi/php-coveralls": "^2.0"
"psr/log": "^1.0"
},
"type": "library",
"extra": {
@ -2650,7 +2649,12 @@
"OpenStack\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"autoload-dev": {
"psr-4": {
"OpenStack\\Test\\": "tests/unit/",
"OpenStack\\Integration\\": "tests/integration/"
}
},
"license": [
"Apache-2.0"
],
@ -2669,12 +2673,15 @@
"description": "PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi",
"homepage": "https://github.com/php-opencloud/openstack",
"keywords": [
"Openstack",
"api",
"openstack",
"php",
"sdk"
],
"time": "2018-03-13T10:03:02+00:00"
"support": {
"source": "https://github.com/OpenStackweb/openstack/tree/master"
},
"time": "2019-01-11T16:48:14+00:00"
},
{
"name": "phpseclib/phpseclib",
@ -5667,16 +5674,16 @@
},
{
"name": "phpunit/phpunit",
"version": "7.5.1",
"version": "7.5.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "c23d78776ad415d5506e0679723cb461d71f488f"
"reference": "7c89093bd00f7d5ddf0ab81dee04f801416b4944"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c23d78776ad415d5506e0679723cb461d71f488f",
"reference": "c23d78776ad415d5506e0679723cb461d71f488f",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7c89093bd00f7d5ddf0ab81dee04f801416b4944",
"reference": "7c89093bd00f7d5ddf0ab81dee04f801416b4944",
"shasum": ""
},
"require": {
@ -5747,7 +5754,7 @@
"testing",
"xunit"
],
"time": "2018-12-12T07:20:32+00:00"
"time": "2019-01-15T08:19:08+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -6465,7 +6472,8 @@
"minimum-stability": "dev",
"stability-flags": {
"smarcet/outlook-rest-client": 20,
"idct/sftp-client": 20
"idct/sftp-client": 20,
"php-opencloud/openstack": 20
},
"prefer-stable": true,
"prefer-lowest": false,

View File

@ -20,4 +20,6 @@ return [
'api_key' => env('CLOUD_STORAGE_APIKEY', null),
'project_name' => env('CLOUD_STORAGE_PROJECT_NAME', null),
'region' => env('CLOUD_STORAGE_REGION', null),
'app_credential_id' => env('CLOUD_STORAGE_APP_CREDENTIAL_ID', null),
'app_credential_secret' => env('CLOUD_STORAGE_APP_CREDENTIAL_SECRET', null),
];