Skip to content

Commit 04a8f28

Browse files
committed
fix(authorization): Fix hierarchy filters for superusers
The filter's `isWildcard` flag was always set to `true` for superusers. This prevented the `containedIn` filter to be applied correctly. Fix this by taking the presence of a `containedIn` filter into account. Signed-off-by: Oliver Heger <[email protected]>
1 parent 8af0269 commit 04a8f28

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

components/authorization/backend/src/main/kotlin/service/DbAuthorizationService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class DbAuthorizationService(
217217
return HierarchyFilter(
218218
transitiveIncludes = includes,
219219
nonTransitiveIncludes = permissions.implicitIncludes().filterContainedIn(containedInId),
220-
isWildcard = permissions.isSuperuser()
220+
isWildcard = permissions.isSuperuser() && containedInId == null
221221
)
222222
}
223223

components/authorization/backend/src/test/kotlin/service/DbAuthorizationServiceTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,7 @@ class DbAuthorizationServiceTest : WordSpec() {
11201120
containedIn = repositoryCompoundId.productId
11211121
)
11221122

1123+
filter.isWildcard shouldBe false
11231124
filter.transitiveIncludes.entries.shouldBeSingleton { (key, value) ->
11241125
key shouldBe CompoundHierarchyId.PRODUCT_LEVEL
11251126
value shouldBe setOf(repositoryCompoundId.parent)

0 commit comments

Comments
 (0)