[
https://issues.apache.org/jira/browse/JCLOUDS-155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14087794#comment-14087794
]
Fabian Lange commented on JCLOUDS-155:
--------------------------------------
[~andrewp] yes i know that. and this patch does no longer work.
When you get a "x-storage-url" header, it is put into the map, but the code
reading the map expects "X-Storage-Url".
What your test verifies is exactly thew problem:
{code}
assertEquals(md, new AuthenticationResponse("token", ImmutableMap.<String, URI>
of("x-storage-url",
URI.create("http://fooman:8080/v1/token"))));
{code}
But later on when that value is read again, then it uses the Value of the
constant to read from the map. But that value is not set, only the lowercased
version.
so i am sorry to report this, but the fix of this ticket is not working.
> HTTP headers are incorrectly treated case sensitive causing OpenStack
> x-storage-url to fail
> -------------------------------------------------------------------------------------------
>
> Key: JCLOUDS-155
> URL: https://issues.apache.org/jira/browse/JCLOUDS-155
> Project: jclouds
> Issue Type: Bug
> Components: jclouds-blobstore
> Affects Versions: 1.5.10, 1.6.1, 1.7.0
> Environment: Apache 2.2 with mod_wsgi produces HTTP header
> "x-storage-url"
> Reporter: Rodney Beede
> Assignee: Andrew Phillips
> Labels: openstack, swift
> Fix For: 1.6.2, 1.7.0
>
> Attachments: ParseAuthenticationResponseFromHeaders.txt,
> ParseAuthenticationResponseFromHeadersTest.txt,
> diff-ParseAuthenticationResponseFromHeaders.diff,
> diff-ParseAuthenticationResponseFromHeadersTest.diff,
> diff-common-openstack-pom.diff, pom.txt
>
> Original Estimate: 168h
> Remaining Estimate: 168h
>
> There is a bug in jclouds (confirmed 1.6 and 1.5, probably also 1.7) where it
> does not correctly detect the OpenStack "X-Storage-Url" HTTP header due to a
> code logic bug regarding case sensitivity. When parsing the authentication
> response the "X-Storage-Url" header is sent back from the server. Some web
> servers send back this header as "x-storage-url" instead which causes jclouds
> to not grab the value and thus use the wrong URL for subsequent requests.
> The code points are detailed below. The code should be modified to use case
> insensitive matches for the header values as HTTP headers are case
> insensitive according to RFC 2616.
> As Swift grizzly has a guide for using Apache this will become an important
> issue as more people use that web server for their proxy-server.
> http://docs.openstack.org/developer/swift/apache_deployment_guide.html
> jclouds-1.6.x\common\openstack\src\main\java\org\jclouds\openstack\reference\AuthHeaders.java
> public static final String URL_SUFFIX = "-Url";
> public static final String STORAGE_URL = "X-Storage" + URL_SUFFIX;
> jclouds-1.6.x\apis\swift\src\main\java\org\jclouds\openstack\swift\config\SwiftRestClientModule.java
> public static class StorageEndpointModule extends
> OpenStackAuthenticationModule {
> @Provides
> @Singleton
> @Storage
> protected Supplier<URI>
> provideStorageUrl(URIFromAuthenticationResponseForService.Factory factory) {
> return factory.create(AuthHeaders.STORAGE_URL);
> }
> }
>
>
> NOTE: Creates a URIFromAuthenticationResponseForService object with uses
> AuthHeaders.STORAGE_URL as the reference.
> jclouds-1.6.x\common\openstack\src\main\java\org\jclouds\openstack\functions\URIFromAuthenticationResponseForService.java
> public static interface Factory {
> URIFromAuthenticationResponseForService create(String service);
> }
> Leads to
>
> public
> URIFromAuthenticationResponseForService(Supplier<AuthenticationResponse>
> auth, @Assisted String service) {
> this.auth = auth;
> this.service = service;
> }
>
> So we have an AuthenticationResponse (inside Supplier) and "String
> service" or this.service = AuthHeaders.STORAGE_URL = "X-Storage-Url"
>
>
> jclouds-1.6.x\common\openstack\src\main\java\org\jclouds\openstack\domain\AuthenticationResponse.java
> public AuthenticationResponse(String authToken, Map<String, URI> services)
> {
> this.authToken = checkNotNull(authToken, "authToken");
> this.services = ImmutableMap.copyOf(checkNotNull(services, "services"));
> }
> public Map<String, URI> getServices() {
> return services;
> }
> NOTE: Map<String, URI> services is a map of the header name to URI. This
> map is case sensitive, but it shouldn't be.
> Allowable values should be:
> X-Storage-Url
> x-storage-url
> x-StoRage-URl
> etc...
--
This message was sent by Atlassian JIRA
(v6.2#6252)