From 522bebc48ff8e9bd9339f2328cf69b72fe17254a Mon Sep 17 00:00:00 2001 From: Daniel Stefani <daniel.stefani@crispybacon.al> Date: Sat, 16 Mar 2024 22:51:26 +0200 Subject: [PATCH] patch: update topic match function --- .../paddy/security/mqtt/MqttAuthorizationController.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/online/danielstefani/paddy/security/mqtt/MqttAuthorizationController.kt b/src/main/kotlin/online/danielstefani/paddy/security/mqtt/MqttAuthorizationController.kt index bd1acbc..29ffb69 100644 --- a/src/main/kotlin/online/danielstefani/paddy/security/mqtt/MqttAuthorizationController.kt +++ b/src/main/kotlin/online/danielstefani/paddy/security/mqtt/MqttAuthorizationController.kt @@ -41,14 +41,10 @@ class MqttAuthorizationController( } /* - Topics are expected to be in some-topic-here/test/abc/SUB-XXXX. - This function extracts the SUB-XXXX part and checks it against the sub in the claim. + Topics are expected to be in the format daemon/SUB-XXXX/... + This function makes sure that the first part is in that format. */ private fun subMatchTopic(sub: String, topic: String): Boolean { - val topicSerial: String? = with(topic.split("/")) { - if (this.isEmpty()) null - else this.last() - } - return topicSerial.equals(sub) + return topic.startsWith("daemon/$sub/") } } \ No newline at end of file