diff --git a/shared/src/main/kotlin/com/egm/stellio/shared/util/ApiUtils.kt b/shared/src/main/kotlin/com/egm/stellio/shared/util/ApiUtils.kt index a680285c7..3e4e06ffe 100644 --- a/shared/src/main/kotlin/com/egm/stellio/shared/util/ApiUtils.kt +++ b/shared/src/main/kotlin/com/egm/stellio/shared/util/ApiUtils.kt @@ -172,7 +172,7 @@ fun addCoreContextIfMissing(contexts: List): List = /** * Utility but basic method to find if given contexts can resolve a known term from the core context. */ -private fun canExpandJsonLdKeyFromCore(contexts: List): Boolean { +internal fun canExpandJsonLdKeyFromCore(contexts: List): Boolean { val expandedType = JsonLdUtils.expandJsonLdTerm("datasetId", contexts) return expandedType == NGSILD_DATASET_ID_PROPERTY } diff --git a/shared/src/main/kotlin/com/egm/stellio/shared/util/AuthUtils.kt b/shared/src/main/kotlin/com/egm/stellio/shared/util/AuthUtils.kt index d239385aa..f172ffa8b 100644 --- a/shared/src/main/kotlin/com/egm/stellio/shared/util/AuthUtils.kt +++ b/shared/src/main/kotlin/com/egm/stellio/shared/util/AuthUtils.kt @@ -3,6 +3,7 @@ package com.egm.stellio.shared.util import arrow.core.* import com.egm.stellio.shared.model.* import com.egm.stellio.shared.util.AuthContextModel.AUTHORIZATION_COMPOUND_CONTEXT +import com.egm.stellio.shared.util.AuthContextModel.AUTHORIZATION_CONTEXT import com.egm.stellio.shared.util.AuthContextModel.AUTHORIZATION_ONTOLOGY import com.egm.stellio.shared.util.AuthContextModel.AUTH_REL_CAN_ADMIN import com.egm.stellio.shared.util.AuthContextModel.AUTH_REL_CAN_READ @@ -158,7 +159,10 @@ enum class AccessRight(val attributeName: String) { fun getAuthzContextFromLinkHeaderOrDefault(httpHeaders: HttpHeaders): Either> = getContextFromLinkHeader(httpHeaders.getOrEmpty(HttpHeaders.LINK)) .map { - if (it != null) listOf(it).plus(AUTHORIZATION_COMPOUND_CONTEXT) + if (it != null) + if (canExpandJsonLdKeyFromCore(listOf(it))) + listOf(it, AUTHORIZATION_CONTEXT) + else listOf(it, AUTHORIZATION_COMPOUND_CONTEXT) else listOf(AUTHORIZATION_COMPOUND_CONTEXT) }