From 2d3820ac146706d2716ef062c9351e69017c0de6 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 25 Nov 2020 13:39:25 +0100 Subject: [PATCH] Upgrade akka-http to 10.2 (#8058) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Upgrade akka-http to 10.2 Follow up to #8048, I left out this upgrade to reduce noise and since I wasn’t quite sure how involved it was going to be. changelog_begin changelog_end * Reenable transparent HEAD requests Apparently no longer on by default but we depend on this in waitForHttpServer changelog_begin changelog_end --- bazel-java-deps.bzl | 6 +- .../com/digitalasset/http/HttpService.scala | 4 +- .../http/StaticContentEndpoints.scala | 22 +-- .../http/WebsocketEndpoints.scala | 12 +- maven_install.json | 156 +++++++++--------- .../digitalasset/navigator/UIBackend.scala | 11 +- .../com/daml/oauth/middleware/Server.scala | 34 +++- .../scala/com/daml/oauth/server/Server.scala | 15 +- .../scala/com/daml/oauth/server/Client.scala | 6 +- .../daml/lf/engine/trigger/Server.scala | 8 +- 10 files changed, 142 insertions(+), 132 deletions(-) diff --git a/bazel-java-deps.bzl b/bazel-java-deps.bzl index 42c10eeaa40..61a29ed0563 100644 --- a/bazel-java-deps.bzl +++ b/bazel-java-deps.bzl @@ -35,9 +35,9 @@ def install_java_deps(): "com.storm-enroute:scalameter-core_2.12:0.10.1", "com.typesafe.akka:akka-actor_2.12:2.6.10", "com.typesafe.akka:akka-actor-typed_2.12:2.6.10", - "com.typesafe.akka:akka-http_2.12:10.1.13", - "com.typesafe.akka:akka-http-spray-json_2.12:10.1.13", - "com.typesafe.akka:akka-http-testkit_2.12:10.1.13", + "com.typesafe.akka:akka-http_2.12:10.2.1", + "com.typesafe.akka:akka-http-spray-json_2.12:10.2.1", + "com.typesafe.akka:akka-http-testkit_2.12:10.2.1", "com.typesafe.akka:akka-slf4j_2.12:2.6.10", "com.typesafe.akka:akka-stream_2.12:2.6.10", "com.typesafe.akka:akka-stream-testkit_2.12:2.6.10", diff --git a/ledger-service/http-json/src/main/scala/com/digitalasset/http/HttpService.scala b/ledger-service/http-json/src/main/scala/com/digitalasset/http/HttpService.scala index c2e12f54260..9565eeb2a61 100644 --- a/ledger-service/http-json/src/main/scala/com/digitalasset/http/HttpService.scala +++ b/ledger-service/http-json/src/main/scala/com/digitalasset/http/HttpService.scala @@ -99,7 +99,7 @@ object HttpService extends StrictLogging { ): Future[Error \/ ServerBinding] = { import startSettings._ - implicit val settings: ServerSettings = ServerSettings(asys) + implicit val settings: ServerSettings = ServerSettings(asys).withTransparentHeadRequests(true) val tokenHolder = accessTokenFile.map(new TokenHolder(_)) @@ -210,7 +210,7 @@ object HttpService extends StrictLogging { ) binding <- liftET[Error]( - Http().bindAndHandleAsync(allEndpoints, address, httpPort, settings = settings), + Http().newServerAt(address, httpPort).withSettings(settings).bind(allEndpoints) ) _ <- either(portFile.cata(f => createPortFile(f, binding), \/-(()))): ET[Unit] diff --git a/ledger-service/http-json/src/main/scala/com/digitalasset/http/StaticContentEndpoints.scala b/ledger-service/http-json/src/main/scala/com/digitalasset/http/StaticContentEndpoints.scala index abfdf612111..ed3d26c7e1e 100644 --- a/ledger-service/http-json/src/main/scala/com/digitalasset/http/StaticContentEndpoints.scala +++ b/ledger-service/http-json/src/main/scala/com/digitalasset/http/StaticContentEndpoints.scala @@ -2,12 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 package com.daml.http +import akka.actor.ActorSystem import akka.http.scaladsl.model._ import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.directives.ContentTypeResolver.Default -import akka.http.scaladsl.server.{Directives, RoutingLog} -import akka.http.scaladsl.settings.{ParserSettings, RoutingSettings} -import akka.stream.Materializer +import akka.http.scaladsl.server.{Directives} import com.typesafe.scalalogging.StrictLogging import scalaz.syntax.show._ @@ -15,21 +14,14 @@ import scala.concurrent.Future object StaticContentEndpoints { def all(config: StaticContentConfig)( - implicit - routingSettings: RoutingSettings, - parserSettings: ParserSettings, - materializer: Materializer, - routingLog: RoutingLog): HttpRequest PartialFunction Future[HttpResponse] = + implicit asys: ActorSystem, + ): HttpRequest PartialFunction Future[HttpResponse] = new StaticContentRouter(config) } private class StaticContentRouter(config: StaticContentConfig)( - implicit - routingSettings: RoutingSettings, - parserSettings: ParserSettings, - materializer: Materializer, - routingLog: RoutingLog) - extends PartialFunction[HttpRequest, Future[HttpResponse]] + implicit asys: ActorSystem, +) extends PartialFunction[HttpRequest, Future[HttpResponse]] with StrictLogging { private val pathPrefix: Uri.Path = Uri.Path("/" + config.prefix) @@ -38,7 +30,7 @@ private class StaticContentRouter(config: StaticContentConfig)( logger.warn("DO NOT USE StaticContentRouter IN PRODUCTION, CONSIDER SETTING UP REVERSE PROXY!!!") private val fn = - akka.http.scaladsl.server.Route.asyncHandler( + akka.http.scaladsl.server.Route.toFunction( Directives.rawPathPrefix(Slash ~ config.prefix)( Directives.getFromDirectory(config.directory.getAbsolutePath) )) diff --git a/ledger-service/http-json/src/main/scala/com/digitalasset/http/WebsocketEndpoints.scala b/ledger-service/http-json/src/main/scala/com/digitalasset/http/WebsocketEndpoints.scala index 15d4abfcea4..c11d31bafc3 100644 --- a/ledger-service/http-json/src/main/scala/com/digitalasset/http/WebsocketEndpoints.scala +++ b/ledger-service/http-json/src/main/scala/com/digitalasset/http/WebsocketEndpoints.scala @@ -5,7 +5,7 @@ package com.daml.http import akka.http.scaladsl.model.HttpMethods._ import akka.http.scaladsl.model._ -import akka.http.scaladsl.model.ws.{Message, UpgradeToWebSocket} +import akka.http.scaladsl.model.ws.{Message, WebSocketUpgrade} import akka.stream.scaladsl.Flow import com.daml.jwt.domain.Jwt import com.typesafe.scalalogging.StrictLogging @@ -22,7 +22,7 @@ object WebsocketEndpoints { private[http] val wsProtocol: String = "daml.ws.auth" private def findJwtFromSubProtocol( - upgradeToWebSocket: UpgradeToWebSocket, + upgradeToWebSocket: WebSocketUpgrade, ): Unauthorized \/ Jwt = { upgradeToWebSocket.requestedProtocols .collectFirst { @@ -33,7 +33,7 @@ object WebsocketEndpoints { private def preconnect( decodeJwt: ValidateJwt, - req: UpgradeToWebSocket, + req: WebSocketUpgrade, subprotocol: String, ) = for { @@ -56,7 +56,7 @@ class WebsocketEndpoints( case req @ HttpRequest(GET, Uri.Path("/v1/stream/query"), _, _, _) => Future.successful( (for { - upgradeReq <- req.header[UpgradeToWebSocket] \/> InvalidUserInput( + upgradeReq <- req.attribute(AttributeKeys.webSocketUpgrade) \/> InvalidUserInput( s"Cannot upgrade client's connection to websocket", ) _ = logger.info(s"GOT $wsProtocol") @@ -75,7 +75,7 @@ class WebsocketEndpoints( case req @ HttpRequest(GET, Uri.Path("/v1/stream/fetch"), _, _, _) => Future.successful( (for { - upgradeReq <- req.header[UpgradeToWebSocket] \/> InvalidUserInput( + upgradeReq <- req.attribute(AttributeKeys.webSocketUpgrade) \/> InvalidUserInput( s"Cannot upgrade client's connection to websocket", ) payload <- preconnect(decodeJwt, upgradeReq, wsProtocol) @@ -93,7 +93,7 @@ class WebsocketEndpoints( def handleWebsocketRequest[A: WebSocketService.StreamQueryReader]( jwt: Jwt, jwtPayload: domain.JwtPayload, - req: UpgradeToWebSocket, + req: WebSocketUpgrade, protocol: String, ): HttpResponse = { val handler: Flow[Message, Message, _] = diff --git a/maven_install.json b/maven_install.json index a69b97db693..cc1e9a903f9 100644 --- a/maven_install.json +++ b/maven_install.json @@ -1,6 +1,6 @@ { "dependency_tree": { - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": -1645962655, + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": 2002757912, "conflict_resolution": {}, "dependencies": [ { @@ -2437,184 +2437,184 @@ "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.12/2.6.10/akka-actor_2.12-2.6.10-sources.jar" }, { - "coord": "com.typesafe.akka:akka-http-core_2.12:10.1.13", + "coord": "com.typesafe.akka:akka-http-core_2.12:10.2.1", "dependencies": [ "org.scala-lang:scala-library:2.12.12", - "com.typesafe.akka:akka-parsing_2.12:10.1.13" + "com.typesafe.akka:akka-parsing_2.12:10.2.1" ], "directDependencies": [ - "com.typesafe.akka:akka-parsing_2.12:10.1.13", + "com.typesafe.akka:akka-parsing_2.12:10.2.1", "org.scala-lang:scala-library:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.1.13/akka-http-core_2.12-10.1.13.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.2.1/akka-http-core_2.12-10.2.1.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.1.13/akka-http-core_2.12-10.1.13.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.2.1/akka-http-core_2.12-10.2.1.jar" ], - "sha256": "ef54b16e6a6729900f3270f4ff7cabe342c51a5622dbb8e0141c09c4a6e0aba3", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.1.13/akka-http-core_2.12-10.1.13.jar" + "sha256": "94e0725f7d451a4d206d5327124994481200c18caaa5cd766df847a1e7596071", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.2.1/akka-http-core_2.12-10.2.1.jar" }, { - "coord": "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.1.13", + "coord": "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.2.1", "dependencies": [ - "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.1.13", + "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.2.1", "org.scala-lang:scala-library:jar:sources:2.12.12" ], "directDependencies": [ - "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.1.13", + "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.2.1", "org.scala-lang:scala-library:jar:sources:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.1.13/akka-http-core_2.12-10.1.13-sources.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.2.1/akka-http-core_2.12-10.2.1-sources.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.1.13/akka-http-core_2.12-10.1.13-sources.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.2.1/akka-http-core_2.12-10.2.1-sources.jar" ], - "sha256": "fd6c754a00c026ab2ffbf276353138bb233baec25162ae5259c7a1fe0c163bae", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.1.13/akka-http-core_2.12-10.1.13-sources.jar" + "sha256": "56b5bb861e579c024ed9c77ff8dbe2f696f50560b5507cb05817786f75891396", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-core_2.12/10.2.1/akka-http-core_2.12-10.2.1-sources.jar" }, { - "coord": "com.typesafe.akka:akka-http-spray-json_2.12:10.1.13", + "coord": "com.typesafe.akka:akka-http-spray-json_2.12:10.2.1", "dependencies": [ - "com.typesafe.akka:akka-http_2.12:10.1.13", - "com.typesafe.akka:akka-http-core_2.12:10.1.13", + "com.typesafe.akka:akka-parsing_2.12:10.2.1", "io.spray:spray-json_2.12:1.3.5", - "org.scala-lang:scala-library:2.12.12", - "com.typesafe.akka:akka-parsing_2.12:10.1.13" + "com.typesafe.akka:akka-http_2.12:10.2.1", + "com.typesafe.akka:akka-http-core_2.12:10.2.1", + "org.scala-lang:scala-library:2.12.12" ], "directDependencies": [ - "com.typesafe.akka:akka-http_2.12:10.1.13", + "com.typesafe.akka:akka-http_2.12:10.2.1", "io.spray:spray-json_2.12:1.3.5", "org.scala-lang:scala-library:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.1.13/akka-http-spray-json_2.12-10.1.13.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.2.1/akka-http-spray-json_2.12-10.2.1.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.1.13/akka-http-spray-json_2.12-10.1.13.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.2.1/akka-http-spray-json_2.12-10.2.1.jar" ], - "sha256": "415863dc9673045ee48ce5f722e510bba1485b27e171673fb99c1ee9f2b7f8f4", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.1.13/akka-http-spray-json_2.12-10.1.13.jar" + "sha256": "39ca94336ff52bf3a5d677d28a141cb678cf6e0cdca14b963a808139e65fffc5", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.2.1/akka-http-spray-json_2.12-10.2.1.jar" }, { - "coord": "com.typesafe.akka:akka-http-spray-json_2.12:jar:sources:10.1.13", + "coord": "com.typesafe.akka:akka-http-spray-json_2.12:jar:sources:10.2.1", "dependencies": [ + "com.typesafe.akka:akka-http_2.12:jar:sources:10.2.1", "io.spray:spray-json_2.12:jar:sources:1.3.5", - "com.typesafe.akka:akka-http_2.12:jar:sources:10.1.13", - "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.1.13", + "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.2.1", "org.scala-lang:scala-library:jar:sources:2.12.12", - "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.1.13" + "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.2.1" ], "directDependencies": [ - "com.typesafe.akka:akka-http_2.12:jar:sources:10.1.13", + "com.typesafe.akka:akka-http_2.12:jar:sources:10.2.1", "io.spray:spray-json_2.12:jar:sources:1.3.5", "org.scala-lang:scala-library:jar:sources:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.1.13/akka-http-spray-json_2.12-10.1.13-sources.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.2.1/akka-http-spray-json_2.12-10.2.1-sources.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.1.13/akka-http-spray-json_2.12-10.1.13-sources.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.2.1/akka-http-spray-json_2.12-10.2.1-sources.jar" ], - "sha256": "f351792fed5f78ad7538188a0d1b8860353cf584e14d87f096844db284437edc", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.1.13/akka-http-spray-json_2.12-10.1.13-sources.jar" + "sha256": "bbda88fd34d39580d54bf224bdc48b9999077b71cb979298ad290725695e3c58", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-spray-json_2.12/10.2.1/akka-http-spray-json_2.12-10.2.1-sources.jar" }, { - "coord": "com.typesafe.akka:akka-http-testkit_2.12:10.1.13", + "coord": "com.typesafe.akka:akka-http-testkit_2.12:10.2.1", "dependencies": [ "org.scala-lang:scala-library:2.12.12", - "com.typesafe.akka:akka-parsing_2.12:10.1.13", - "com.typesafe.akka:akka-http-core_2.12:10.1.13", - "com.typesafe.akka:akka-http_2.12:10.1.13" + "com.typesafe.akka:akka-http-core_2.12:10.2.1", + "com.typesafe.akka:akka-http_2.12:10.2.1", + "com.typesafe.akka:akka-parsing_2.12:10.2.1" ], "directDependencies": [ - "com.typesafe.akka:akka-http_2.12:10.1.13", + "com.typesafe.akka:akka-http_2.12:10.2.1", "org.scala-lang:scala-library:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.1.13/akka-http-testkit_2.12-10.1.13.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.2.1/akka-http-testkit_2.12-10.2.1.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.1.13/akka-http-testkit_2.12-10.1.13.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.2.1/akka-http-testkit_2.12-10.2.1.jar" ], - "sha256": "d8efea08fc77fc895a208cc01d9bb91d952dc834f0c87c994f718b36d10b7b2c", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.1.13/akka-http-testkit_2.12-10.1.13.jar" + "sha256": "e8a7028f949a76acf7e674e14980aa4d086838fbf6875f1b3514068c7989c0e2", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.2.1/akka-http-testkit_2.12-10.2.1.jar" }, { - "coord": "com.typesafe.akka:akka-http-testkit_2.12:jar:sources:10.1.13", + "coord": "com.typesafe.akka:akka-http-testkit_2.12:jar:sources:10.2.1", "dependencies": [ - "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.1.13", + "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.2.1", "org.scala-lang:scala-library:jar:sources:2.12.12", - "com.typesafe.akka:akka-http_2.12:jar:sources:10.1.13", - "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.1.13" + "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.2.1", + "com.typesafe.akka:akka-http_2.12:jar:sources:10.2.1" ], "directDependencies": [ - "com.typesafe.akka:akka-http_2.12:jar:sources:10.1.13", + "com.typesafe.akka:akka-http_2.12:jar:sources:10.2.1", "org.scala-lang:scala-library:jar:sources:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.1.13/akka-http-testkit_2.12-10.1.13-sources.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.2.1/akka-http-testkit_2.12-10.2.1-sources.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.1.13/akka-http-testkit_2.12-10.1.13-sources.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.2.1/akka-http-testkit_2.12-10.2.1-sources.jar" ], - "sha256": "a8d51b376699d51ad94f54b1aed430456caae3f1f7784e582ce22392c41f625f", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.1.13/akka-http-testkit_2.12-10.1.13-sources.jar" + "sha256": "b7865b16f39ec11d82a888ef5753f043377041f2720733ec5c23650f9e87592c", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http-testkit_2.12/10.2.1/akka-http-testkit_2.12-10.2.1-sources.jar" }, { - "coord": "com.typesafe.akka:akka-http_2.12:10.1.13", + "coord": "com.typesafe.akka:akka-http_2.12:10.2.1", "dependencies": [ "org.scala-lang:scala-library:2.12.12", - "com.typesafe.akka:akka-parsing_2.12:10.1.13", - "com.typesafe.akka:akka-http-core_2.12:10.1.13" + "com.typesafe.akka:akka-http-core_2.12:10.2.1", + "com.typesafe.akka:akka-parsing_2.12:10.2.1" ], "directDependencies": [ - "com.typesafe.akka:akka-http-core_2.12:10.1.13", + "com.typesafe.akka:akka-http-core_2.12:10.2.1", "org.scala-lang:scala-library:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.1.13/akka-http_2.12-10.1.13.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.2.1/akka-http_2.12-10.2.1.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.1.13/akka-http_2.12-10.1.13.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.2.1/akka-http_2.12-10.2.1.jar" ], - "sha256": "a86f278db7caf2c7c1dd81e19f5d34d97b2ea5c1bea5086e10a04a520224046f", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.1.13/akka-http_2.12-10.1.13.jar" + "sha256": "ae237bdaed2943ed861dca2d7bbdf21f7310473bf7f837ef146caa3ee5d4a55d", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.2.1/akka-http_2.12-10.2.1.jar" }, { - "coord": "com.typesafe.akka:akka-http_2.12:jar:sources:10.1.13", + "coord": "com.typesafe.akka:akka-http_2.12:jar:sources:10.2.1", "dependencies": [ - "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.1.13", + "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.2.1", "org.scala-lang:scala-library:jar:sources:2.12.12", - "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.1.13" + "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.2.1" ], "directDependencies": [ - "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.1.13", + "com.typesafe.akka:akka-http-core_2.12:jar:sources:10.2.1", "org.scala-lang:scala-library:jar:sources:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.1.13/akka-http_2.12-10.1.13-sources.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.2.1/akka-http_2.12-10.2.1-sources.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.1.13/akka-http_2.12-10.1.13-sources.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.2.1/akka-http_2.12-10.2.1-sources.jar" ], - "sha256": "ba1ef041df6f89a6927e4660b515195ada8275791ebb4415509166b03156675a", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.1.13/akka-http_2.12-10.1.13-sources.jar" + "sha256": "40013dd55cb7c68e555487e2894e5c2f1805f2ab4695da04e1811e51388efc5a", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-http_2.12/10.2.1/akka-http_2.12-10.2.1-sources.jar" }, { - "coord": "com.typesafe.akka:akka-parsing_2.12:10.1.13", + "coord": "com.typesafe.akka:akka-parsing_2.12:10.2.1", "dependencies": [ "org.scala-lang:scala-library:2.12.12" ], "directDependencies": [ "org.scala-lang:scala-library:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.1.13/akka-parsing_2.12-10.1.13.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.2.1/akka-parsing_2.12-10.2.1.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.1.13/akka-parsing_2.12-10.1.13.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.2.1/akka-parsing_2.12-10.2.1.jar" ], - "sha256": "63065aa4a07661a3d11f78ac9c598220d8acc92ef3d87e81cdb9da9b476ff556", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.1.13/akka-parsing_2.12-10.1.13.jar" + "sha256": "b89c5b0fa550a42e83a81a4be3e3a920fa9b54ba2eafd6b744e180e26d7380f8", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.2.1/akka-parsing_2.12-10.2.1.jar" }, { - "coord": "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.1.13", + "coord": "com.typesafe.akka:akka-parsing_2.12:jar:sources:10.2.1", "dependencies": [ "org.scala-lang:scala-library:jar:sources:2.12.12" ], "directDependencies": [ "org.scala-lang:scala-library:jar:sources:2.12.12" ], - "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.1.13/akka-parsing_2.12-10.1.13-sources.jar", + "file": "v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.2.1/akka-parsing_2.12-10.2.1-sources.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.1.13/akka-parsing_2.12-10.1.13-sources.jar" + "https://repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.2.1/akka-parsing_2.12-10.2.1-sources.jar" ], - "sha256": "defcb6b4fac84a68dc265cd0f5161a09463f2efc414cce0ddccda70587f73125", - "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.1.13/akka-parsing_2.12-10.1.13-sources.jar" + "sha256": "a89c0ca22d3bf76bbfffa08e278da18f2590ed00961ba171838ba88b97da1d3c", + "url": "https://repo1.maven.org/maven2/com/typesafe/akka/akka-parsing_2.12/10.2.1/akka-parsing_2.12-10.2.1-sources.jar" }, { "coord": "com.typesafe.akka:akka-protobuf-v3_2.12:2.6.10", diff --git a/navigator/backend/src/main/scala/com/digitalasset/navigator/UIBackend.scala b/navigator/backend/src/main/scala/com/digitalasset/navigator/UIBackend.scala index e130e0b508f..0c0c714aafa 100644 --- a/navigator/backend/src/main/scala/com/digitalasset/navigator/UIBackend.scala +++ b/navigator/backend/src/main/scala/com/digitalasset/navigator/UIBackend.scala @@ -17,8 +17,8 @@ import akka.http.scaladsl.model.headers.{Cookie, EntityTag, HttpCookie, `Cache-C import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Route import akka.http.scaladsl.settings.RoutingSettings +import akka.http.scaladsl.settings.ServerSettings import akka.pattern.ask -import akka.stream.Materializer import akka.util.Timeout import com.daml.grpc.GrpcException import com.daml.navigator.SessionJsonProtocol._ @@ -213,7 +213,6 @@ abstract class UIBackend extends LazyLogging with ApplicationInfoJsonSupport { banner.foreach(println) implicit val system: ActorSystem = ActorSystem("da-ui-backend") - implicit val materializer: Materializer = Materializer(system) import system.dispatcher @@ -248,10 +247,10 @@ abstract class UIBackend extends LazyLogging with ApplicationInfoJsonSupport { } val stopServer = if (arguments.startWebServer) { - val binding = Http().bindAndHandle( - getRoute(system, arguments, config, graphQL, info, getAppState), - "0.0.0.0", - arguments.port) + val binding = Http() + .newServerAt("0.0.0.0", arguments.port) + .withSettings(ServerSettings(system).withTransparentHeadRequests(true)) + .bind(getRoute(system, arguments, config, graphQL, info, getAppState)) logger.info(s"DA UI backend server listening on port ${arguments.port}") println(s"Frontend running at http://localhost:${arguments.port}.") () => diff --git a/triggers/service/auth/src/main/scala/com/daml/oauth/middleware/Server.scala b/triggers/service/auth/src/main/scala/com/daml/oauth/middleware/Server.scala index fe179c3cb15..38a67d5ca0b 100644 --- a/triggers/service/auth/src/main/scala/com/daml/oauth/middleware/Server.scala +++ b/triggers/service/auth/src/main/scala/com/daml/oauth/middleware/Server.scala @@ -47,13 +47,29 @@ object Server extends StrictLogging { // TODO[AH] Make sure this is bounded in size - or avoid state altogether. val requests: TrieMap[UUID, Uri] = TrieMap() val route = concat( - path("auth") { get { auth(config) } }, - path("login") { get { login(config, requests) } }, - path("cb") { get { loginCallback(config, requests) } }, - path("refresh") { post { refresh(config) } }, + path("auth") { + get { + auth(config) + } + }, + path("login") { + get { + login(config, requests) + } + }, + path("cb") { + get { + loginCallback(config, requests) + } + }, + path("refresh") { + post { + refresh(config) + } + }, ) - Http().bindAndHandle(route, "localhost", config.port.value) + Http().newServerAt("localhost", config.port.value).bind(route) } def stop(f: Future[ServerBinding])(implicit ec: ExecutionContext): Future[Done] = @@ -91,7 +107,7 @@ object Server extends StrictLogging { }.getOrElse(false) private def auth(config: Config) = - parameters(('claims.as[Request.Claims])) + parameters('claims.as[Request.Claims]) .as[Request.Auth](Request.Auth) { auth => optionalToken { case Some(token) @@ -106,7 +122,7 @@ object Server extends StrictLogging { } private def login(config: Config, requests: TrieMap[UUID, Uri]) = - parameters(('redirect_uri.as[Uri], 'claims.as[Request.Claims], 'state ?)) + parameters('redirect_uri.as[Uri], 'claims.as[Request.Claims], 'state ?) .as[Request.Login](Request.Login) { login => extractRequest { request => val requestId = UUID.randomUUID @@ -145,7 +161,7 @@ object Server extends StrictLogging { } concat( - parameters(('code, 'state ?)) + parameters('code, 'state ?) .as[OAuthResponse.Authorize](OAuthResponse.Authorize) { authorize => popRequest(authorize.state) { redirectUri => @@ -183,7 +199,7 @@ object Server extends StrictLogging { } } }, - parameters(('error, 'error_description ?, 'error_uri.as[Uri] ?, 'state ?)) + parameters('error, 'error_description ?, 'error_uri.as[Uri] ?, 'state ?) .as[OAuthResponse.Error](OAuthResponse.Error) { error => popRequest(error.state) { redirectUri => val uri = redirectUri.withQuery { diff --git a/triggers/service/auth/src/main/scala/com/daml/oauth/server/Server.scala b/triggers/service/auth/src/main/scala/com/daml/oauth/server/Server.scala index 55674f61f51..4f9d8b55e31 100644 --- a/triggers/service/auth/src/main/scala/com/daml/oauth/server/Server.scala +++ b/triggers/service/auth/src/main/scala/com/daml/oauth/server/Server.scala @@ -101,13 +101,12 @@ class Server(config: Config) { path("authorize") { get { parameters( - ( - 'response_type, - 'client_id, - 'redirect_uri.as[Uri], - 'scope ?, - 'state ?, - 'audience.as[Uri] ?)) + 'response_type, + 'client_id, + 'redirect_uri.as[Uri], + 'scope ?, + 'state ?, + 'audience.as[Uri] ?) .as[Request.Authorize](Request.Authorize) { request => val payload = toPayload(request) @@ -183,7 +182,7 @@ class Server(config: Config) { ) def start()(implicit system: ActorSystem): Future[ServerBinding] = { - Http().bindAndHandle(route, "localhost", config.port.value) + Http().newServerAt("localhost", config.port.value).bind(route) } } diff --git a/triggers/service/auth/src/test/scala/com/daml/oauth/server/Client.scala b/triggers/service/auth/src/test/scala/com/daml/oauth/server/Client.scala index b9cbd59e04b..fa486eeec9f 100644 --- a/triggers/service/auth/src/test/scala/com/daml/oauth/server/Client.scala +++ b/triggers/service/auth/src/test/scala/com/daml/oauth/server/Client.scala @@ -95,7 +95,7 @@ object Client { }, path("cb") { get { - parameters(('code, 'state ?)).as[Response.Authorize](Response.Authorize) { + parameters('code, 'state ?).as[Response.Authorize](Response.Authorize) { resp => extractRequest { request => @@ -124,7 +124,7 @@ object Client { } } } ~ - parameters(('error, 'error_description ?, 'error_uri.as[Uri] ?, 'state ?)) + parameters('error, 'error_description ?, 'error_uri.as[Uri] ?, 'state ?) .as[Response.Error](Response.Error) { resp => complete(ErrorResponse(resp.error): Response) } @@ -168,7 +168,7 @@ object Client { } }, ) - Http().bindAndHandle(route, "localhost", config.port.value) + Http().newServerAt("localhost", config.port.value).bind(route) } } diff --git a/triggers/service/src/main/scala/com/digitalasset/daml/lf/engine/trigger/Server.scala b/triggers/service/src/main/scala/com/digitalasset/daml/lf/engine/trigger/Server.scala index dfa65a4c27e..dbd0dde32cc 100644 --- a/triggers/service/src/main/scala/com/digitalasset/daml/lf/engine/trigger/Server.scala +++ b/triggers/service/src/main/scala/com/digitalasset/daml/lf/engine/trigger/Server.scala @@ -20,6 +20,7 @@ import akka.http.scaladsl.model.Uri.Path import akka.http.scaladsl.model._ import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.{Directive, Directive1, Route} +import akka.http.scaladsl.settings.ServerSettings import akka.http.scaladsl.unmarshalling.{Unmarshal, Unmarshaller} import akka.pattern.StatusReply import akka.stream.Materializer @@ -317,7 +318,7 @@ class Server( case None => complete(StatusCodes.NotFound) case Some(callback) => concat( - parameters(('error, 'error_description ?)) { (error, errorDescription) => + parameters('error, 'error_description ?) { (error, errorDescription) => complete( errorResponse( StatusCodes.Forbidden, @@ -676,7 +677,10 @@ object Server { val serverBinding = for { _ <- initializeF _ <- Future.traverse(initialDars)(server.addDar(_)) - binding <- Http().bindAndHandle(Route.handlerFlow(server.route), host, port) + binding <- Http() + .newServerAt(host, port) + .withSettings(ServerSettings(untypedSystem).withTransparentHeadRequests(true)) + .bind(server.route) } yield binding ctx.pipeToSelf(serverBinding) { case Success(binding) => Started(binding)