javaswift / joss

Java library for OpenStack Storage, aka Swift
http://javaswift.org
117 stars 108 forks source link

Issue connecting Object Storage #151

Open Sukhbhullar opened 6 years ago

Sukhbhullar commented 6 years ago

Hi There,

Trying to implement object storage in my organization but getting UNKNOWN Error with HTTP status 400.

When I try to open Auth URL from browser I am getting below output

{"version": {"status": "stable", "updated": "2016-04-04T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v3+json"}], "id": "v3.6", "links": [{"href": "https://myserver:myport/v3/", "rel": "self"}]}} Not sure what that mean though :)

and from my test class below is the error from log. tried with both tenantName and tenantname but result is same.

[main] ERROR org.javaswift.joss.command.impl.core.AbstractCommand - JOSS / HTTP POST call https://myserver:myport/v3, HTTP status 400, Error UNKNOWN [main] ERROR org.javaswift.joss.command.impl.core.AbstractCommand - * Accept=application/json Exception in thread "main" Command exception, HTTP Status code: 400 => UNKNOWN at org.javaswift.joss.command.impl.core.httpstatus.HttpStatusChecker.verifyCode(HttpStatusChecker.java:45) at org.javaswift.joss.command.impl.core.AbstractCommand.call(AbstractCommand.java:50) at org.javaswift.joss.client.impl.ClientImpl.createAccount(ClientImpl.java:110) at org.javaswift.joss.client.impl.ClientImpl.createAccount(ClientImpl.java:25) at org.javaswift.joss.client.core.AbstractClient.authenticate(AbstractClient.java:35) at org.javaswift.joss.client.factory.AccountFactory.createAccount(AccountFactory.java:30) at org.javaswift.joss.tutorial.MainClass.main(MainClass.java:42)

using Joss 10.2 jar

BTW below is snippet from my test class

Account account = new AccountFactory() //.setAuthenticationMethod(AuthenticationMethod.KEYSTONE_V3) .setTenantName("MyTenant") .setTenantId("MyTenantID") .setUsername("MyUser") .setPassword("MyPassword") // .setAuthUrl("https://myserver:8080")
// .setAuthUrl("http://myserver:myport/v1/AUTH_MyTenantID") .setAuthUrl("https://myserver:myport/v3") .setMock(false) .createAccount();

Have tried with different combinations(as shown in commented lines above) but no luck.

Any help is greatly appreciated.

tfelix commented 6 years ago

Actually it looks like this might be similar to our problem. You could check if your endpoint requires a special scope. It seems like scoping is not implemented in JOSS. If no scope is given during authorization our Keystone responded with an (empty?) token which lead to an error later on. So we need to scope the token request to a project. See https://docs.openstack.org/keystone/pike/api_curl_examples.html JOSS sends the default but in some cases a JSON Payload similar to the Project scope is required.

We mitigated the problem by implementing an external authentication provider which does the same as JOSS does for V3 but instead generates the project scope payload. We will very likely open a pull request in a few days for JOSS with our (sorted out) code to enable project scoping for Keystone V3 auth.

Sukhbhullar commented 6 years ago

Thanks a lot Thomas for your response. I will try that out and will let you know how I go with it.

tfelix commented 6 years ago

If it turns out to be the case meanwhile I have opened a PR and ported our code to the internals of Joss. There are still some issues with code quality which I have to fix but maybe this can help you as well: https://github.com/javaswift/joss/pull/156