From 47a12bf20a90fdb11e7898bead1966db6d50a390 Mon Sep 17 00:00:00 2001 From: slisson Date: Mon, 25 Nov 2024 10:47:31 +0100 Subject: [PATCH] fix(model-server): RestWebModelClient couldn't request a clientId --- .../model/server/handlers/KeyValueLikeModelServer.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/model-server/src/main/kotlin/org/modelix/model/server/handlers/KeyValueLikeModelServer.kt b/model-server/src/main/kotlin/org/modelix/model/server/handlers/KeyValueLikeModelServer.kt index a89df35877..12bf9a7c45 100644 --- a/model-server/src/main/kotlin/org/modelix/model/server/handlers/KeyValueLikeModelServer.kt +++ b/model-server/src/main/kotlin/org/modelix/model/server/handlers/KeyValueLikeModelServer.kt @@ -294,6 +294,9 @@ class KeyValueLikeModelServer( serverId = { throw NoPermissionException("'$key' is read-only.") }, + legacyClientId = { + throw NoPermissionException("Directly writing to 'clientId' is not allowed") + }, unknown = { userDefinedEntries[key] = value }, @@ -349,6 +352,7 @@ class KeyValueLikeModelServer( serverId = { if (isWrite) throw NoPermissionException("'$key' is read-only.") }, + legacyClientId = {}, unknown = { call.checkPermission(ModelServerPermissionSchema.legacyUserDefinedObjects.run { if (isWrite) write else read }) }, @@ -360,6 +364,7 @@ class KeyValueLikeModelServer( immutableObject: () -> R, branch: (branch: BranchReference) -> R, serverId: () -> R, + legacyClientId: () -> R, unknown: () -> R, ): R { return when { @@ -368,6 +373,7 @@ class KeyValueLikeModelServer( key.startsWith(PROTECTED_PREFIX) -> throw NoPermissionException("Access to keys starting with '$PROTECTED_PREFIX' is only permitted to the model server itself.") key.startsWith(RepositoriesManager.KEY_PREFIX) -> throw NoPermissionException("Access to keys starting with '${RepositoriesManager.KEY_PREFIX}' is only permitted to the model server itself.") key == RepositoriesManager.LEGACY_SERVER_ID_KEY || key == RepositoriesManager.LEGACY_SERVER_ID_KEY2 -> serverId() + key == "clientId" -> legacyClientId() else -> unknown() } }