From 65705d9c69248d4ff07d4088b54d8853873f1f0f Mon Sep 17 00:00:00 2001 From: David Furey Date: Fri, 25 Oct 2024 16:23:35 +0100 Subject: [PATCH 1/4] Upgrade to Play 3.0 and Pekko Requires FAPI and pan-domain-auth-play upgrades to versions with support for Play, and then content-api-client-aws and capi-models upgrades for versions alignment. Jackson version is bumped by Play, but still needs override due to jackson-module-scala brought in by Pekko --- app/controllers/FaciaContentApiProxy.scala | 2 +- app/story_packages/metrics/metrics.scala | 2 +- app/story_packages/switchboard/Switchboard.scala | 2 +- app/story_packages/updates/Reindex.scala | 2 +- build.sbt | 4 ++-- conf/application.conf | 14 ++++++-------- project/build.properties | 2 +- project/plugins.sbt | 2 +- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/controllers/FaciaContentApiProxy.scala b/app/controllers/FaciaContentApiProxy.scala index 948768b..f2176d5 100644 --- a/app/controllers/FaciaContentApiProxy.scala +++ b/app/controllers/FaciaContentApiProxy.scala @@ -2,7 +2,7 @@ package controllers import java.net.{URI, URLEncoder} -import akka.actor.ActorSystem +import org.apache.pekko.actor.ActorSystem import story_packages.auth.PanDomainAuthActions import com.amazonaws.auth.{AWSCredentialsProviderChain, STSAssumeRoleSessionCredentialsProvider} import com.amazonaws.auth.profile.ProfileCredentialsProvider diff --git a/app/story_packages/metrics/metrics.scala b/app/story_packages/metrics/metrics.scala index b896148..35ec13b 100644 --- a/app/story_packages/metrics/metrics.scala +++ b/app/story_packages/metrics/metrics.scala @@ -3,7 +3,7 @@ package story_packages.metrics import java.io.File import java.lang.management.{GarbageCollectorMXBean, ManagementFactory} import java.util.concurrent.atomic.AtomicLong -import akka.actor.Scheduler +import org.apache.pekko.actor.Scheduler import com.amazonaws.services.cloudwatch.model.{Dimension, StandardUnit} import play.api.Logger import story_packages.services.Logging diff --git a/app/story_packages/switchboard/Switchboard.scala b/app/story_packages/switchboard/Switchboard.scala index 7e8e976..93611d0 100644 --- a/app/story_packages/switchboard/Switchboard.scala +++ b/app/story_packages/switchboard/Switchboard.scala @@ -1,6 +1,6 @@ package story_packages.switchboard -import akka.actor.Scheduler +import org.apache.pekko.actor.Scheduler import com.amazonaws.auth.AWSCredentialsProvider import story_packages.services.Logging diff --git a/app/story_packages/updates/Reindex.scala b/app/story_packages/updates/Reindex.scala index 29d9916..dcbbc2d 100644 --- a/app/story_packages/updates/Reindex.scala +++ b/app/story_packages/updates/Reindex.scala @@ -1,6 +1,6 @@ package story_packages.updates -import akka.actor.Scheduler +import org.apache.pekko.actor.Scheduler import com.amazonaws.services.dynamodbv2.document.Item import story_packages.model.StoryPackage import org.joda.time.DateTime diff --git a/build.sbt b/build.sbt index f21d536..ea23fe3 100644 --- a/build.sbt +++ b/build.sbt @@ -36,8 +36,8 @@ Compile / doc / sources := Seq.empty Compile / packageDoc / publishArtifact := false val awsVersion = "1.11.999" -val capiModelsVersion = "17.4.0" -val json4sVersion = "4.0.3" +val capiModelsVersion = "25.1.0" +val json4sVersion = "4.0.7" resolvers ++= Seq( Resolver.file("Local", file(Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns) diff --git a/conf/application.conf b/conf/application.conf index 9cc98e0..9111f26 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -1,5 +1,5 @@ -akka { - akka.loggers = ["akka.event.Logging$DefaultLogger", "akka.event.slf4j.Slf4jLogger"] +pekko { + loggers = ["org.apache.pekko.event.Logging$DefaultLogger", "org.apache.pekko.event.slf4j.Slf4jLogger"] loglevel = WARNING actor { default-dispatcher = { @@ -34,12 +34,6 @@ play { loader: Loader } - crypto { - # The secret key is used to secure cryptographics functions. - # If you deploy your application to several instances be sure to use the same key! - secret: "test" - } - il8n { langs: "en" } @@ -49,6 +43,10 @@ play { } http { + secret { + # If a Play app needs a secure Play Application Secret, it should use https://github.com/guardian/play-secret-rotation + key="This app doesn't need a secure PAS so long as it DOES NOT use session cookies, CSRF tokens, etc" + } session { secure=true } diff --git a/project/build.properties b/project/build.properties index 563a014..2743082 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.7.2 +sbt.version=1.9.6 diff --git a/project/plugins.sbt b/project/plugins.sbt index b9c585b..98eab58 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,7 +6,7 @@ resolvers ++= Seq( Resolver.typesafeRepo("releases") ) ++ Resolver.sonatypeOssRepos("releases") -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.19") +addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.5") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") From 8f73ec81b6d43c4cc758a0bdcf00171200975976 Mon Sep 17 00:00:00 2001 From: David Furey Date: Fri, 25 Oct 2024 16:24:08 +0100 Subject: [PATCH 2/4] Bump AWS to align with version brough in by content-api-client-aws Also resolves deprecation warning --- app/conf/Configuration.scala | 4 ++-- build.sbt | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/conf/Configuration.scala b/app/conf/Configuration.scala index 0fa4888..6a714f8 100644 --- a/app/conf/Configuration.scala +++ b/app/conf/Configuration.scala @@ -6,7 +6,7 @@ import com.amazonaws.AmazonClientException import com.amazonaws.auth.profile.ProfileCredentialsProvider import com.amazonaws.auth.{AWSCredentialsProvider, AWSCredentialsProviderChain, InstanceProfileCredentialsProvider} import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration -import com.amazonaws.regions.{Region, Regions} +import com.amazonaws.regions.{Region, RegionUtils} import com.amazonaws.services.cloudwatch.AmazonCloudWatch import com.amazonaws.services.dynamodbv2.AmazonDynamoDB import com.amazonaws.services.s3.{AmazonS3, AmazonS3ClientBuilder} @@ -57,7 +57,7 @@ class ApplicationConfiguration(val playConfiguration: PlayConfiguration, val env lazy val bucket = getMandatoryString("aws.bucket") object endpoints { - private val _region = Region.getRegion(Regions.fromName(region)) + private val _region = RegionUtils.getRegion(region) val monitoring: String = _region.getServiceEndpoint(AmazonCloudWatch.ENDPOINT_PREFIX) val dynamoDB: String = _region.getServiceEndpoint(AmazonDynamoDB.ENDPOINT_PREFIX) val s3: String = _region.getServiceEndpoint(AmazonS3.ENDPOINT_PREFIX) diff --git a/build.sbt b/build.sbt index ea23fe3..21d6193 100644 --- a/build.sbt +++ b/build.sbt @@ -35,7 +35,7 @@ Compile / doc / sources := Seq.empty Compile / packageDoc / publishArtifact := false -val awsVersion = "1.11.999" +val awsVersion = "1.12.770" val capiModelsVersion = "25.1.0" val json4sVersion = "4.0.7" @@ -46,8 +46,7 @@ resolvers ++= Seq( buildInfoPackage := "app" buildInfoKeys += "gitCommitId" -> env.getOrElse("GITHUB_SHA", "Unknown") -lazy val jacksonVersion = "2.13.4" -lazy val jacksonDatabindVersion = "2.13.4.2" +lazy val jacksonVersion = "2.17.2" // these Jackson dependencies are required to resolve issues in Play 2.8.x https://github.com/orgs/playframework/discussions/11222 val jacksonOverrides = Seq( @@ -56,7 +55,7 @@ val jacksonOverrides = Seq( "com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % jacksonVersion, "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % jacksonVersion, "com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion, - "com.fasterxml.jackson.core" % "jackson-databind" % jacksonDatabindVersion + "com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion ) libraryDependencies ++= jacksonOverrides ++ Seq( @@ -71,16 +70,16 @@ libraryDependencies ++= jacksonOverrides ++ Seq( "com.amazonaws" % "aws-java-sdk-dynamodb" % awsVersion, "com.gu" %% "content-api-models-scala" % capiModelsVersion, "com.gu" %% "content-api-models-json" % capiModelsVersion, - "com.gu" %% "content-api-client-aws" % "0.7", - "com.gu" %% "fapi-client-play28" % "4.0.4", - "com.gu" %% "pan-domain-auth-play_2-8" % "4.0.0", + "com.gu" %% "content-api-client-aws" % "0.7.5", + "com.gu" %% "fapi-client-play30" % "12.0.0", + "com.gu" %% "pan-domain-auth-play_3-0" % "4.0.0", "com.gu" %% "story-packages-model" % "2.2.0", "com.gu" %% "thrift-serializer" % "4.0.2", "org.json4s" %% "json4s-native" % json4sVersion, "org.json4s" %% "json4s-jackson" % json4sVersion, "net.logstash.logback" % "logstash-logback-encoder" % "7.2", - "com.typesafe.play" %% "play-json" % "2.9.4", - "org.julienrf" %% "play-json-derived-codecs" % "10.1.0", + "com.typesafe.play" %% "play-json" % "2.10.5", + "org.julienrf" %% "play-json-derived-codecs" % "11.0.0", "org.scalatest" %% "scalatest" % "3.2.15" % "test" ) From dacae89a6368b9a680de6193921ea77f1ba6b7c6 Mon Sep 17 00:00:00 2001 From: David Furey Date: Fri, 25 Oct 2024 17:07:56 +0100 Subject: [PATCH 3/4] Use even newer SBT Co-authored-by: Roberto Tyley <52038+rtyley@users.noreply.github.com> --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 2743082..bc73906 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.6 +sbt.version=1.10.3 From a29ff212380811ea9d4aeb377b43c53230583329 Mon Sep 17 00:00:00 2001 From: David Furey Date: Fri, 25 Oct 2024 17:10:27 +0100 Subject: [PATCH 4/4] Maven group id of Playframework has changed --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 21d6193..2eb89a2 100644 --- a/build.sbt +++ b/build.sbt @@ -78,7 +78,7 @@ libraryDependencies ++= jacksonOverrides ++ Seq( "org.json4s" %% "json4s-native" % json4sVersion, "org.json4s" %% "json4s-jackson" % json4sVersion, "net.logstash.logback" % "logstash-logback-encoder" % "7.2", - "com.typesafe.play" %% "play-json" % "2.10.5", + "org.playframework" %% "play-json" % "3.0.4", "org.julienrf" %% "play-json-derived-codecs" % "11.0.0", "org.scalatest" %% "scalatest" % "3.2.15" % "test" )