Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logging for users without permission to access tool #198

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/conf/Configuration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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}
import com.gu.permissions.PermissionsConfig
import org.apache.commons.io.IOUtils
import play.api.Mode
import play.api.{Configuration => PlayConfiguration}
Expand Down Expand Up @@ -170,6 +171,12 @@ class ApplicationConfiguration(val playConfiguration: PlayConfiguration, val env
object latest {
lazy val pageSize = 20
}

val permissions = PermissionsConfig(
stage = environment.stage,
region = aws.region,
awsCredentials = aws.mandatoryCredentials,
)
}

object Properties extends AutomaticResourceManagement {
Expand Down
8 changes: 8 additions & 0 deletions app/story_packages/auth/PanDomainAuthActions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ package story_packages.auth
import com.gu.pandomainauth.action.AuthActions
import com.gu.pandomainauth.model.AuthenticatedUser
import com.gu.pandomainauth.PanDomain
import com.gu.permissions.{PermissionDefinition, PermissionsProvider}
import play.api.mvc._
import conf.ApplicationConfiguration
import story_packages.services.Logging

trait PanDomainAuthActions extends AuthActions with Results with Logging {
def config: ApplicationConfiguration

val permissions = PermissionsProvider(config.permissions)

val StoryPackagesAccess = PermissionDefinition("story-packages-access", "story-packages")

override def validateUser(authedUser: AuthenticatedUser): Boolean = {
if (!permissions.hasPermission(StoryPackagesAccess, authedUser.user.email)) {
Logger.warn(s"User ${authedUser.user.email} does not have ${StoryPackagesAccess.name} permission")
}
PanDomain.guardianValidation(authedUser)
}

Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ libraryDependencies ++= jacksonOverrides ++ Seq(
"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" %% "editorial-permissions-client" % "2.15",
"com.gu" %% "story-packages-model" % "2.2.0",
"com.gu" %% "thrift-serializer" % "4.0.2",
"org.json4s" %% "json4s-native" % json4sVersion,
Expand Down
Loading