ncw / swift

Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)
MIT License
310 stars 107 forks source link

Default user domain in password Auth v3 & discarded server error message in Auth #153

Open tmoinel opened 4 years ago

tmoinel commented 4 years ago

When migrating from OVH Keystone API v2.0 to v3 the Authenticate method return Bad Request which isn't very explicit. After debugging it, I see that the server respond with a json error message with the reason but is discarded by the client. We should maybe extend the error type to add the return messages and/or add an error field in v3AuthResponse. I can try to do a PR to add it if it make sens for the project but I have not a good knowledge of this code base.

Reading https://docs.openstack.org/keystone/pike/contributor/http-api.html and the server response :

{
  "error": {
      "message": "Expecting to find domain in user. The server could not comply with the request since it is either malformed or otherwise incorrect. The client is assumed to be in error.",
      "code": 400,
      "title": "Bad Request"
  }
}

I resolve my issue by setting swift.Connection.Domain to default.

I can't find if the user domain is mandatory in the protocol but if it is we should be set to default if it is not provided, like in the project scope https://github.com/ncw/swift/blob/017f012e58fa8f056707eb85ce9f794ba9beec6c/auth_v3.go#L225-L227 adding an else seems sufficient https://github.com/ncw/swift/blob/017f012e58fa8f056707eb85ce9f794ba9beec6c/auth_v3.go#L197-L201

} else {
    domain = &v3Domain{Name: "Default"}
}

I can make a PR too.

ncw commented 4 years ago

After debugging it, I see that the server respond with a json error message with the reason but is discarded by the client.

What error did the client return?

A PR to improve the error message would be appreciated!

Constructing a new error with

https://github.com/ncw/swift/blob/017f012e58fa8f056707eb85ce9f794ba9beec6c/swift.go#L291

would probably be the right thing to do.

I can't find if the user domain is mandatory in the protocol but if it is we should be set to default if it is not provided, like in the project scope

I think if you are using v3 auth you are expected to provide a domain. Its a while since I looked at this so my memory is hazy!