Skip to content

Commit

Permalink
Merge pull request #114 from RADAR-base/bugfix/reduce-json-auth-requests
Browse files Browse the repository at this point in the history
Fix redundant auth requests for JSON format topic uploads
  • Loading branch information
pvannierop authored Nov 15, 2024
2 parents 7de76e7 + 2e54179 commit f736570
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Suppress("ConstPropertyName")
object Versions {
const val project = "0.7.4"
const val project = "0.7.5"

const val java = 17
const val kotlin = "1.9.22"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ class AvroRecordProcessor(
val entitiesChecked = HashSet<EntityDetails>()

for (entity in this) {
// only check entities once
if (!entitiesChecked.add(entity)) continue
// Make sure to perform the permission check on entities only once.
// Note:
// There is a 'feature' around the comparison of EntityDetails objects; the checkPermissions method
// updates the EntityDetails object with the organization id. This means that for effective comparison
// we have to make copy of entity details so that the original entity details are compared. Without
// this every entity processed here would be considered as an entity different from all previous and
// would trigger a new permission check. This situation is a consequence of the later addition of the
// concept of organization to the entity details.
val entityCheck = entity.copy()
if (!entitiesChecked.add(entityCheck)) continue

authService.checkPermission(
Permission.MEASUREMENT_CREATE,
Expand Down Expand Up @@ -160,6 +168,7 @@ class AvroRecordProcessor(
)
defaultProject
}

else -> jsonProject["string"]?.asText() ?: throw context.invalidContent(
"Project ID should be wrapped in string union type",
)
Expand Down

0 comments on commit f736570

Please sign in to comment.