Skip to content

Commit a6fc6d4

Browse files
committed
Handle null claims in groupJwtClaim and rolesJwtClaim by providing empty list fallback
1 parent 1799d04 commit a6fc6d4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

common/src/main/kotlin/com/cosmotech/common/utils/SecurityUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fun getCurrentAccountGroups(configuration: CsmPlatformProperties): List<String>
5959
return getValueFromAuthenticatedToken(configuration) {
6060
try {
6161
val jwt = JWTParser.parse(it)
62-
jwt.jwtClaimsSet.getStringListClaim(configuration.authorization.groupJwtClaim)
62+
jwt.jwtClaimsSet.getStringListClaim(configuration.authorization.groupJwtClaim) ?: emptyList()
6363
} catch (e: ParseException) {
6464
JSONObjectUtils.parse(it)[configuration.authorization.groupJwtClaim] as List<String>
6565
}
@@ -70,7 +70,7 @@ fun getCurrentAuthenticatedRoles(configuration: CsmPlatformProperties): List<Str
7070
return getValueFromAuthenticatedToken(configuration) {
7171
try {
7272
val jwt = JWTParser.parse(it)
73-
jwt.jwtClaimsSet.getStringListClaim(configuration.authorization.rolesJwtClaim)
73+
jwt.jwtClaimsSet.getStringListClaim(configuration.authorization.rolesJwtClaim) ?: emptyList()
7474
} catch (e: ParseException) {
7575
JSONObjectUtils.parse(it)[configuration.authorization.rolesJwtClaim] as List<String>
7676
}

0 commit comments

Comments
 (0)