Aws signature mismatch with signed payloads after upgrading to play-ahc-ws-2.7.0 (play-s3)


(Marco) #1

Check out https://github.com/kaliber-scala/play-s3 repo and update play version from 2.6 to 2.7 in build.sbt (need to add commons-codec dependency as well). Modify build.sbt as follows:

val playVersion = "2.7.0"

lazy val root = (project in file("."))
  .settings(
    name := "play-s3",
    organization := "net.kaliber",
    scalaVersion := "2.12.2",
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-ws"     % playVersion % "provided",
      "com.typesafe.play" %% "play-test"   % playVersion % "test",
      "com.typesafe.play" %% "play-specs2" % playVersion % "test",
      "com.typesafe.play" %% "play-ahc-ws" % playVersion % "test",
      "com.typesafe.play" %% "play-logback" % playVersion % "test",
      "commons-codec" % "commons-codec" % "1.11" % "provided"
    )
  )
  .settings(bintraySettings: _*)

Also add the following lines to src/main/scala/fly/play/aws/AwsRequestHolder.scala:

def withUrl(url: String): AwsRequestHolder = 
  copy(wrappedRequest = wrappedRequest withUrl url)

Create test/conf/application.conf (play conf + s3 test bucket location)

And run sbt clean compile test and wait for the aws signature mismatches on the s3 upload tests with signed payload.

Then modify build.sbt as follows:

val playVersion = "2.7.0"

lazy val root = (project in file("."))
  .settings(
    name := "play-s3",
    organization := "net.kaliber",
    scalaVersion := "2.12.2",
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-ws"     % playVersion % "provided",
      "com.typesafe.play" %% "play-test"   % playVersion % "test",
      "com.typesafe.play" %% "play-specs2" % playVersion % "test",
      "com.typesafe.play" %% "play-ahc-ws" % "2.6.21" % "test",
      "com.typesafe.play" %% "play-logback" % playVersion % "test",
      "commons-codec" % "commons-codec" % "1.11" % "provided"
    )
  )
  .settings(bintraySettings: _*)

And run sbt clean compile test again and the tests will pass.

What did change wrt submitting request (signatures) in play-ahc-ws 2.7.0 (or in the shaded-asynchttpclient-2.0.1 dependency) ?

Thanks


(Marco) #2

This can be moved to the play-ws subcategory and then deleted from the general category.
Thanks


(Marco) #3

The signature mismatch starts with play-ws 2.7.0-M4. 2.7.0-M3 is still fine. It’s likely stemming from this PR: https://github.com/playframework/play-ws/pull/262


(Marco) #4

is the reason for this behavior. Altering the final request after the signature has been generated is a bad idea - asynchttpclient should not have been upgraded. The only solution/workaround for dependent modules for now is to copy/adopt the charset enforcement implementation of asynchttpclient, which unfortunately ties them closely together.