Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rtyley committed Jan 30, 2024
1 parent bb1c570 commit b51e086
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 33 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java corretto-11.0.22.7.1
36 changes: 12 additions & 24 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@ import scala.sys.process._

val scroogeVersion = "4.12.0"
val awsVersion = "1.11.678"
val pandaVersion = "1.2.0"
val pandaHmacVersion = "2.1.0"
val atomMakerVersion = "1.3.4"
val pandaVersion = "3.0.1"
val atomMakerVersion = "2.0.0-PREVIEW.fix-tests-under-java-17.2024-01-18T1039.b4d55b3d"
val typesafeConfigVersion = "1.4.0" // to match what we get from Play transitively
val scanamoVersion = "1.0.0-M9"

val playJsonExtensionsVersion = "0.40.2"
val playJsonExtensionsVersion = "0.42.0"
val okHttpVersion = "2.4.0"
val diffVersion = "2.0.1"

val capiAwsVersion = "0.5"

val scalaTestVersion = "3.0.8"
val scalaTestPlusPlayVersion = "4.0.3"
val mockitoVersion = "2.0.97-beta"
val scalaXmlVersion = "1.0.5"
val scalaXmlVersion = "2.2.0"
val scalaCheckVersion = "1.14.0" // to match ScalaTest version

val awsLambdaCoreVersion = "1.1.0"
Expand All @@ -28,8 +22,6 @@ val awsLambdaEventsVersion = "1.3.0"
val logbackClassicVersion = "1.2.3"
val logstashLogbackEncoderVersion = "4.8"

val permissionsClientVersion = "0.8"

val guavaVersion = "31.1-jre"
val googleOauthVersion = "1.33.3"
val googleHttpJacksonVersion = "1.41.7"
Expand All @@ -48,14 +40,11 @@ lazy val jacksonVersion = "2.13.4"
lazy val jacksonDatabindVersion = "2.13.4.2"

lazy val commonSettings = Seq(
ThisBuild / scalaVersion := "2.12.16",
scalacOptions ++= Seq("-feature", "-deprecation"/*, "-Xfatal-warnings"*/),
ThisBuild / scalaVersion := "2.13.11", // 2.13.12 blocked by https://github.com/scala/bug/issues/12862
scalacOptions ++= Seq("-feature", "-deprecation"),
ThisBuild / organization := "com.gu",

resolvers ++= Seq(
"Sonatype OSS" at "https://oss.sonatype.org/content/repositories/releases/",
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
),
resolvers ++= Resolver.sonatypeOssRepos("releases"),

// silly SBT command to work-around lack of support for root projects that are not in the "root" folder
// https://github.com/sbt/sbt/issues/2405
Expand Down Expand Up @@ -87,10 +76,10 @@ lazy val common = (project in file("common"))
"com.google.api-client" % "google-api-client" % googleApiClientVersion,
"com.google.http-client" % "google-http-client-jackson2" % googleHttpJacksonVersion,
"com.google.apis" % "google-api-services-youtube" % youTubeApiClientVersion,
"com.gu" %% "pan-domain-auth-play_2-8" % pandaVersion,
"com.gu" %% "pan-domain-auth-play_2-9" % pandaVersion,
"com.gu" %% "pan-domain-auth-verification" % pandaVersion,
"com.gu" %% "pan-domain-auth-core" % pandaVersion,
"com.gu" %% "panda-hmac-play_2-8" % pandaHmacVersion,
"com.gu" %% "panda-hmac-play_2-9" % pandaVersion,
ws,
"com.typesafe.play" %% "play-json-joda" % "2.7.4",
"com.gu" %% "atom-publisher-lib" % atomMakerVersion,
Expand All @@ -111,15 +100,15 @@ lazy val common = (project in file("common"))
"ch.qos.logback" % "logback-classic" % logbackClassicVersion,
"com.amazonaws" % "aws-java-sdk-sts" % awsVersion,
"com.amazonaws" % "aws-java-sdk-elastictranscoder" % awsVersion,
"org.scanamo" %% "scanamo" % scanamoVersion,
"org.scanamo" %% "scanamo" % "1.0.0-M28",
"com.squareup.okhttp" % "okhttp" % okHttpVersion,
"org.scalacheck" %% "scalacheck" % scalaCheckVersion % "test", // to match ScalaTest version
"com.amazonaws" % "aws-java-sdk-sns" % awsVersion,
"com.amazonaws" % "aws-java-sdk-sqs" % awsVersion,
"com.gu" %% "editorial-permissions-client" % permissionsClientVersion,
"com.gu" %% "editorial-permissions-client" % "2.15",
"com.amazonaws" % "aws-java-sdk-stepfunctions" % awsVersion,
"com.amazonaws" % "aws-java-sdk-ses" % awsVersion,
"com.gu" %% "content-api-client-aws" % capiAwsVersion,
"com.gu" %% "content-api-client-aws" % "0.7.2",
"org.scalatest" %% "scalatest" % scalaTestVersion % "test",
"org.jsoup" % "jsoup" % jsoupVersion,
"com.beachape" %% "enumeratum" % enumeratumVersion,
Expand All @@ -135,7 +124,6 @@ lazy val app = (project in file("."))
libraryDependencies ++= Seq(
ehcache,
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonDatabindVersion,
"ai.x" %% "diff" % diffVersion,
"com.amazonaws" % "aws-java-sdk-sts" % awsVersion,
"com.amazonaws" % "aws-java-sdk-ec2" % awsVersion,
"org.scalatestplus.play" %% "scalatestplus-play" % scalaTestPlusPlayVersion % "test",
Expand Down
14 changes: 8 additions & 6 deletions common/src/main/scala/com/gu/media/Permissions.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.gu.media

import com.amazonaws.auth.AWSCredentialsProvider
import com.gu.editorial.permissions.client._
import com.gu.permissions._
import ai.x.play.json.Jsonx
import play.api.libs.json.Format
import com.gu.pandomainauth.model.{User => PandaUser}
import com.gu.permissions.PermissionDefinition

import scala.concurrent.Future

case class Permissions(
Expand All @@ -17,10 +19,10 @@ object Permissions {
implicit val format: Format[Permissions] = Jsonx.formatCaseClass[Permissions]

val app = "atom-maker"
val deleteAtom = Permission("delete_atom", app, defaultVal = PermissionDenied)
val addSelfHostedAsset = Permission("add_self_hosted_asset", app, defaultVal = PermissionDenied)
val setVideosOnAllChannelsPublic = Permission("set_videos_on_all_channels_public", app, defaultVal = PermissionDenied)
val pinboard = Permission("pinboard", "pinboard", defaultVal = PermissionDenied)
val deleteAtom = PermissionDefinition("delete_atom", app)
val addSelfHostedAsset = PermissionDefinition("add_self_hosted_asset", app)
val setVideosOnAllChannelsPublic = PermissionDefinition("set_videos_on_all_channels_public", app)
val pinboard = PermissionDefinition("pinboard", "pinboard")
}

class MediaAtomMakerPermissionsProvider(stage: String, credsProvider: AWSCredentialsProvider) extends PermissionsProvider {
Expand All @@ -46,7 +48,7 @@ class MediaAtomMakerPermissionsProvider(stage: String, credsProvider: AWSCredent
Permissions(deleteAtom = false, addSelfHostedAsset = false, publicStatus, pinboard = false)
}

private def hasPermission(permission: Permission, user: PandaUser): Future[Boolean] = {
private def hasPermission(permission: PermissionDefinition, user: PandaUser): Future[Boolean] = {
user.email match {
// TODO be better
// HACK: HMAC authenticated users are a `PandaUser` without an email
Expand Down
3 changes: 1 addition & 2 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# blocked at this version until play 2.8
sbt.version=1.8.0
sbt.version=1.9.8
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.19")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.4")

Expand Down

0 comments on commit b51e086

Please sign in to comment.