You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And just refers to https://lon.identity.api.rackspacecloud.com/v2.0/ to identificate. Using CURL I'm able to retrive the catalog list of services, also my TOKEN to use with X-Auth-Token. And the public URL endpoints of this catalog services,
Test Done, following that documentation I'm able to create the same Guzzle Post, thant I was doing with CURL. And, this part "works", using it as identityService, is till giving the same response.
$httpClient = new Client([
'base_uri' => TransportUtils::normalizeUrl('https://lon.identity.api.rackspacecloud.com/v2.0/'),
'handler' => HandlerStack::create(),
'json'=>["auth"=>['RAX-KSKEY:apiKeyCredentials'=>["username"=>"username","apiKey"=>'apikey']]],
'defaults'=>['headers' => ['content-type' => 'application/json', 'Accept' => 'application/json']],
]
);
#I've used this piece just to check getting the same result as with the CURL client identifiing to Rackspace.
#$response=$httpClient->post("tokens");
#$body=json_decode($response->getBody()->getContents(),true);
$options = [
'authUrl' => 'https://lon.identity.api.rackspacecloud.com/v2.0/',
'region' => 'LON',
'username' => 'username',
'password' => 'apikey',
'identityService' => Service::factory($httpClient),
];
/** @var OpenStack $openstack */
$openstack = new OpenStack($options);
$containers = $openstack->objectStoreV1()->listContainers();
The response stills Client error:POST https://lon.identity.api.rackspacecloud.com/v2.0/tokens` resulted in a 401 Unauthorized response:
{"unauthorized":{"code":401,"message":"Error code: 'AUTH-004'; Unable to authenticate user with credentials provided."}}
`
I can't remember doing it, but it looks like Rackspace expects 'apiKey', not 'password' and that we're overriding the default OpenStack\Identity\v2\Api to accomplish that. It's mixed in with stuff like caching the auth token and guzzle retry middleware. But from a quick look the relevant bits are:
use OpenStack\Identity\v2\Api as OpenStackApi;
class Api extends OpenStackApi
{
protected $params;
public function __construct()
{
$this->params = new Params();
}
public function postToken(): array
{
return [
'method' => 'POST',
'path' => 'tokens',
'params' => [
'username' => $this->params->username(),
'apiKey' => $this->params->apiKey(),
],
];
}
}
and
use OpenStack\Common\Api\AbstractParams;
class Params extends AbstractParams
{
public function username()
{
return [
'type' => self::STRING_TYPE,
'location' => self::JSON,
'path' => 'auth.RAX-KSKEY:apiKeyCredentials',
'required' => true,
];
}
public function apiKey()
{
return [
'type' => self::STRING_TYPE,
'location' => self::JSON,
'path' => 'auth.RAX-KSKEY:apiKeyCredentials',
'required' => true,
];
}
}
You'd need to construct an instance of the Identity service passing the api as the second param, and somehow tell the rest of openstack to use that. As I said, our requirements are complex and there may be a much easier way of doing it.
Sure would have been nice if Rackspace hadn't fired all their developers 4 years ago ;)
It Works as expected, the only required extra change is having to EDIT OpenStack Builder, to make a replacement of the API and the Service class, to match the ones we have created.
Somthing as UGLY as this
I'm not so happy with this solution. Looks like a horrible patch. But it works, which is what my company need right now. I'll try to write Rackspace Support for looking for a better solution than this one. But, anyway thanks @kynx@haphan for your incredible help. Couldn't make it without you.
I struggled with getting OpenStack working with Rackspace Cloud Files for days so I wrote my own very simple PHP client for the basic functionality that my app needs for Cloud Files here: https://github.com/gkilwein/Rackspace-Cloud-Files Hopefully this helps someone.
Activity
haphan commentedon Oct 27, 2020
@ap-coder This SDK should work with RackSpace Openstack for the most part. What is the issue you are having?
braisdesousa commentedon Nov 4, 2020
Hi @haphan ! I'm at the same point than @ap-coder . I'm moving my old ObjectStore from https://github.com/rackspace/php-opencloud to this new OpenStack code ( the old rackspace still requiring deprected code)
Trying to follow with https://php-openstack-sdk.readthedocs.io/en/latest/services/object-store/v1/account.html docs, I create a very simple PHP Code as follows
$openstack = new OpenStack([ 'authUrl' => 'https://identity.api.rackspacecloud.com/v2.0/', 'region' => 'LON', 'user' => [ 'id' => 'myUserName', 'password' => 'myApiKey' ], 'scope' => ['project' => ['id' => 'object-store']] ]);But, the output I got while trying to execute this code is
` HTTP Error
Please ensure that the resource you're trying to access actually exists. Visit http://docs.php-opencloud.com/en/latest/http-codes for more information about debugging HTTP status codes, or file a support issue on https://github.com/php-openc
`
I have also opened a ticket with Rackspace, but I thing here I could get a better solution.
haphan commentedon Nov 4, 2020
braisdesousa commentedon Nov 4, 2020
This may be the problem @haphan, there is not identityV3 on rackspace. All documentation is based on https://developer.rackspace.com/docs/cloud-identity/quickstart/
And just refers to https://lon.identity.api.rackspacecloud.com/v2.0/ to identificate. Using CURL I'm able to retrive the catalog list of services, also my TOKEN to use with X-Auth-Token. And the public URL endpoints of this catalog services,
But I cannot make it work with OpenStack.
haphan commentedon Nov 4, 2020
@braisdesousa I recall this issue with auth v2.0 now. Pardon me because not many platforms are still using v2.
For v2 identity you'd need to override the config for
IdentityService, it is documented hereCan you give it a try and report back? Thanks
braisdesousa commentedon Nov 5, 2020
Test Done, following that documentation I'm able to create the same Guzzle Post, thant I was doing with CURL. And, this part "works", using it as identityService, is till giving the same response.
The response stills
Client error:POST https://lon.identity.api.rackspacecloud.com/v2.0/tokens` resulted in a401 Unauthorizedresponse:{"unauthorized":{"code":401,"message":"Error code: 'AUTH-004'; Unable to authenticate user with credentials provided."}}
`
kynx commentedon Nov 5, 2020
@braisdesousa We use this with Rackspace.
I can't remember doing it, but it looks like Rackspace expects 'apiKey', not 'password' and that we're overriding the default
OpenStack\Identity\v2\Apito accomplish that. It's mixed in with stuff like caching the auth token and guzzle retry middleware. But from a quick look the relevant bits are:and
Then the config looks something like:
You'd need to construct an instance of the Identity service passing the api as the second param, and somehow tell the rest of openstack to use that. As I said, our requirements are complex and there may be a much easier way of doing it.
Sure would have been nice if Rackspace hadn't fired all their developers 4 years ago ;)
braisdesousa commentedon Nov 7, 2020
Thank you @kynx ! I will give it a Try ASAP and reply if it works.
braisdesousa commentedon Nov 16, 2020
It Works as expected, the only required extra change is having to EDIT OpenStack Builder, to make a replacement of the API and the Service class, to match the ones we have created.
Somthing as UGLY as this
I'm not so happy with this solution. Looks like a horrible patch. But it works, which is what my company need right now. I'll try to write Rackspace Support for looking for a better solution than this one. But, anyway thanks @kynx @haphan for your incredible help. Couldn't make it without you.
gkilwein commentedon Jan 27, 2022
I struggled with getting OpenStack working with Rackspace Cloud Files for days so I wrote my own very simple PHP client for the basic functionality that my app needs for Cloud Files here: https://github.com/gkilwein/Rackspace-Cloud-Files Hopefully this helps someone.
colethorsen commentedon Sep 23, 2024
Late to this issue, but since it still doesn't seem to have a solution:
This uses php-opencloud/openstack v3.10.0
You also need to create the identity service referenced in the code: