Skip to content

Commit

Permalink
patch: update topic match function
Browse files Browse the repository at this point in the history
  • Loading branch information
OpenSrcerer committed Mar 16, 2024
1 parent 57f7991 commit 522bebc
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
}
}

0 comments on commit 522bebc

Please sign in to comment.