Skip to content

Commit

Permalink
reduce massive logging when we req. recursive rows
Browse files Browse the repository at this point in the history
via retrieveForeignRows and are not allowed to view all rows
  • Loading branch information
zingmane committed Oct 20, 2023
1 parent 0f6730a commit 44ae1b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,9 @@ class TableauxModel(
)(implicit user: TableauxUser): Future[Boolean] = {
roleModel.checkAuthorization(
ViewRow,
ComparisonObjects(permissions)
ComparisonObjects(permissions),
isInternalCall = false,
shouldLog = false
) transform {
case Success(_) => Success(true)
case Failure(_) => Success(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class RoleModel(jsonObject: JsonObject) extends LazyLogging {
def checkAuthorization(
action: Action,
objects: ComparisonObjects = ComparisonObjects(),
isInternalCall: Boolean = false
isInternalCall: Boolean = false,
shouldLog: Boolean = true
)(implicit user: TableauxUser): Future[Unit] = {

if (isInternalCall) {
Expand All @@ -71,7 +72,7 @@ class RoleModel(jsonObject: JsonObject) extends LazyLogging {
Future.successful(())
} else {
val userName = user.name
logger.info(s"User ${userName} is not allowed to do action '$action'")
if (shouldLog) logger.info(s"User ${userName} is not allowed to do action '$action'")
Future.failed(UnauthorizedException(action, userRoles))
}
}
Expand Down Expand Up @@ -411,7 +412,12 @@ class RoleModel(jsonObject: JsonObject) extends LazyLogging {
*/
class RoleModelStub extends RoleModel(Json.emptyObj()) with LazyLogging {

override def checkAuthorization(action: Action, objects: ComparisonObjects, isInternalCall: Boolean)(
override def checkAuthorization(
action: Action,
objects: ComparisonObjects,
isInternalCall: Boolean,
shouldLog: Boolean
)(
implicit user: TableauxUser
): Future[Unit] = {
Future.successful(())
Expand Down

0 comments on commit 44ae1b7

Please sign in to comment.