Skip to content

Commit 335edbd

Browse files
committed
refactor: move client auth out of probe metadata
1 parent df9f40b commit 335edbd

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

control/src/main/kotlin/spp/probe/ProbeConfiguration.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ object ProbeConfiguration {
9797
val spp: JsonObject
9898
get() = localProperties!!.getJsonObject("spp")
9999

100-
fun getString(property: String?): String? {
100+
fun getJsonObject(property: String): JsonObject? {
101+
return localProperties!!.getJsonObject("spp").getJsonObject(property)
102+
}
103+
104+
fun getString(property: String): String? {
101105
return localProperties!!.getJsonObject("spp").getString(property)
102106
}
103107

control/src/main/kotlin/spp/probe/SourceProbe.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,14 @@ object SourceProbe {
265265
meta.putAll(ProbeConfiguration.spp.getJsonObject("probe_metadata").map)
266266
}
267267

268+
//add probe auth headers
269+
ProbeConfiguration.getJsonObject("authentication")?.let {
270+
it.getString("client_id")?.let { probeMessageHeaders.put("client_id", it) }
271+
it.getString("client_secret")?.let { probeMessageHeaders.put("client_secret", it) }
272+
it.getString("tenant_id")?.let { probeMessageHeaders.put("tenant_id", it) }
273+
}
274+
268275
//send probe connected status
269-
meta["client_id"]?.let { probeMessageHeaders.put("client_id", it) }
270-
meta["client_secret"]?.let { probeMessageHeaders.put("client_secret", it) }
271-
meta["tenant_id"]?.let { probeMessageHeaders.put("tenant_id", it) }
272276
val replyAddress = UUID.randomUUID().toString()
273277
val pc = InstanceConnection(PROBE_ID, System.currentTimeMillis(), meta)
274278
val consumer = vertx!!.eventBus().localConsumer<Boolean>(replyAddress)

0 commit comments

Comments
 (0)