Skip to content

Commit

Permalink
fix dev-build following pan-domain-authentication changes (#27012)
Browse files Browse the repository at this point in the history
  • Loading branch information
twrichards committed May 2, 2024
1 parent 83dcec7 commit 8fb5d4b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
35 changes: 1 addition & 34 deletions admin/app/AppLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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

Expand Down Expand Up @@ -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]
Expand Down
38 changes: 36 additions & 2 deletions admin/app/controllers/AdminControllers.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]
Expand Down

0 comments on commit 8fb5d4b

Please sign in to comment.