Skip to content

Commit a225c71

Browse files
committed
policy for wellknown channel.
only allow subscription requests on the wellknown channel.
1 parent afb3c29 commit a225c71

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/pico-engine/krl/io.picolabs.subscription.krl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ ent:established [
6969
},...,...
7070
]
7171
*/
72+
wellknown_Policy = {
73+
name: "wellknown",
74+
event: {
75+
allow: [
76+
{domain: "wrangler", type: "subscription"}
77+
]
78+
}
7279
autoAcceptConfig = function(){
7380
ent:autoAcceptConfig.defaultsTo({})
7481
}
@@ -127,7 +134,8 @@ ent:established [
127134
select when wrangler ruleset_added where rids >< meta:rid
128135
pre{ channel = wellKnown_Rx() }
129136
if(channel.isnull() || channel{"type"} != "Tx_Rx") then
130-
engine:newChannel(meta:picoId, "wellKnown_Rx", "Tx_Rx")//wrangler:createChannel(...)
137+
engine:newPolicy( wellknown_Policy ) setting(__wellknown_Policy)
138+
engine:newChannel(pico_id = meta:picoId, name = "wellKnown_Rx", type = "Tx_Rx", policy_id = __wellknown_Policy{"id"}) //should be wrangler:createChannel(...)
131139
fired{
132140
raise Tx_Rx event "wellKnown_Rx_created" attributes event:attrs;
133141
}

0 commit comments

Comments
 (0)