From 8fb5d4ba5849ccce6f9aeace44ca0c55fc8c5065 Mon Sep 17 00:00:00 2001 From: Tom Richards Date: Fri, 26 Apr 2024 11:03:24 +0100 Subject: [PATCH] fix `dev-build` following pan-domain-authentication changes (https://github.com/guardian/frontend/pull/27012) --- admin/app/AppLoader.scala | 35 +----------------- admin/app/controllers/AdminControllers.scala | 38 ++++++++++++++++++-- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/admin/app/AppLoader.scala b/admin/app/AppLoader.scala index 2c272eea02c..73dab985329 100644 --- a/admin/app/AppLoader.scala +++ b/admin/app/AppLoader.scala @@ -7,12 +7,10 @@ import common._ import conf.switches.SwitchboardLifecycle import controllers.{AdminControllers, HealthCheck} import _root_.dfp.DfpDataCacheLifecycle -import com.amazonaws.regions.Regions -import com.amazonaws.services.s3.AmazonS3ClientBuilder import org.apache.pekko.actor.{ActorSystem => PekkoActorSystem} import concurrent.BlockingOperations import contentapi.{CapiHttpClient, ContentApiClient, HttpClient} -import http.{AdminHttpErrorHandler, CommonGzipFilter, Filters, GuardianAuthWithExemptions, routes} +import http.{AdminHttpErrorHandler, CommonGzipFilter, Filters} import dev.DevAssetsController import jobs._ import model.{AdminLifecycle, ApplicationIdentity} @@ -26,7 +24,6 @@ import play.api.i18n.I18nComponents import play.api.libs.ws.WSClient import services.{ParameterStoreService, _} import router.Routes -import conf.Configuration.aws.mandatoryCredentials import scala.concurrent.ExecutionContext @@ -78,36 +75,6 @@ trait AdminServices extends I18nComponents { trait AppComponents extends FrontendComponents with AdminControllers with AdminServices { - private lazy val s3Client = AmazonS3ClientBuilder - .standard() - .withRegion(Regions.EU_WEST_1) - .withCredentials( - mandatoryCredentials, - ) - .build() - - lazy val auth = new GuardianAuthWithExemptions( - controllerComponents, - wsClient, - toolsDomainPrefix = "frontend", - oauthCallbackPath = routes.GuardianAuthWithExemptions.oauthCallback.path, - s3Client, - system = "frontend-admin", - extraDoNotAuthenticatePathPrefixes = Seq( - "/deploys", //not authenticated so it can be accessed by Prout to determine which builds have been deployed - "/deploy", //not authenticated so it can be accessed by Riff-Raff to notify about a new build being deployed - // Date: 06 July 2021 - // Author: Pascal - // Added as part of posing the ground for the interactive migration. - // It should be removed when the Interactives migration is complete, meaning when we no longer need the routes - // POST /interactive-librarian/live-presser/*path - // POST /interactive-librarian/read-clean-write/*path - // in [admin]. - "/interactive-librarian/", - ), - requiredEditorialPermissionName = "admin_tool_access", - ) - lazy val healthCheck = wire[HealthCheck] lazy val devAssetsController = wire[DevAssetsController] lazy val logbackOperationsPool = wire[LogbackOperationsPool] diff --git a/admin/app/controllers/AdminControllers.scala b/admin/app/controllers/AdminControllers.scala index 8f64abc5a8b..463cb682b72 100644 --- a/admin/app/controllers/AdminControllers.scala +++ b/admin/app/controllers/AdminControllers.scala @@ -1,21 +1,26 @@ package controllers +import com.amazonaws.regions.Regions +import com.amazonaws.services.s3.AmazonS3ClientBuilder import com.softwaremill.macwire._ import common.PekkoAsync import controllers.admin._ import controllers.admin.commercial._ import controllers.cache.{ImageDecacheController, PageDecacheController} import dfp._ -import http.GuardianAuthWithExemptions +import http.{GuardianAuthWithExemptions, routes} import model.ApplicationContext import play.api.http.HttpConfiguration import play.api.libs.ws.WSClient import play.api.mvc.ControllerComponents import services.{OphanApi, ParameterStoreService, RedirectService} +import conf.Configuration.aws.mandatoryCredentials +import org.apache.pekko.stream.Materializer trait AdminControllers { def pekkoAsync: PekkoAsync def wsClient: WSClient def ophanApi: OphanApi + implicit def materializer: Materializer implicit def appContext: ApplicationContext def redirects: RedirectService def httpConfiguration: HttpConfiguration @@ -38,7 +43,36 @@ trait AdminControllers { def placementService: PlacementService def dfpApi: DfpApi def parameterStoreService: ParameterStoreService - def auth: GuardianAuthWithExemptions + + private lazy val s3Client = AmazonS3ClientBuilder + .standard() + .withRegion(Regions.EU_WEST_1) + .withCredentials( + mandatoryCredentials, + ) + .build() + + lazy val auth = new GuardianAuthWithExemptions( + controllerComponents, + wsClient, + toolsDomainPrefix = "frontend", + oauthCallbackPath = routes.GuardianAuthWithExemptions.oauthCallback.path, + s3Client, + system = "frontend-admin", + extraDoNotAuthenticatePathPrefixes = Seq( + "/deploys", //not authenticated so it can be accessed by Prout to determine which builds have been deployed + "/deploy", //not authenticated so it can be accessed by Riff-Raff to notify about a new build being deployed + // Date: 06 July 2021 + // Author: Pascal + // Added as part of posing the ground for the interactive migration. + // It should be removed when the Interactives migration is complete, meaning when we no longer need the routes + // POST /interactive-librarian/live-presser/*path + // POST /interactive-librarian/read-clean-write/*path + // in [admin]. + "/interactive-librarian/", + ), + requiredEditorialPermissionName = "admin_tool_access", + ) lazy val uncachedWebAssets = wire[UncachedWebAssets] lazy val uncachedAssets = wire[UncachedAssets]