Upgrade akka-http to 10.2 (#8058)

* 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
This commit is contained in:
Moritz Kiefer 2020-11-25 13:39:25 +01:00 committed by GitHub
parent 2156f946d1
commit 2d3820ac14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 142 additions and 132 deletions

View File

@ -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",

View File

@ -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]

View File

@ -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)
))

View File

@ -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, _] =

View File

@ -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",

View File

@ -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}.")
() =>

View File

@ -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 {

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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)