Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-155

HTTP headers are incorrectly treated case sensitive causing OpenStack x-storage-url to fail

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.10, 1.6.1, 1.7.0
    • Fix Version/s: 1.6.2, 1.7.0
    • Component/s: jclouds-blobstore
    • Labels:
    • Environment:
      Apache 2.2 with mod_wsgi produces HTTP header "x-storage-url"

      Description

      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...

        Attachments

        1. ParseAuthenticationResponseFromHeaders.txt
          4 kB
          Rodney Beede
        2. ParseAuthenticationResponseFromHeadersTest.txt
          4 kB
          Rodney Beede
        3. pom.txt
          0.2 kB
          Rodney Beede
        4. diff-common-openstack-pom.diff
          0.5 kB
          Rodney Beede
        5. diff-ParseAuthenticationResponseFromHeaders.diff
          2 kB
          Rodney Beede
        6. diff-ParseAuthenticationResponseFromHeadersTest.diff
          2 kB
          Rodney Beede

          Activity

            People

            • Assignee:
              andrewp Andrew Phillips
              Reporter:
              rbeede Rodney Beede
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 168h
                168h
                Remaining:
                Remaining Estimate - 168h
                168h
                Logged:
                Time Spent - Not Specified
                Not Specified