Open dopry opened 6 years ago
If we keep the scopes as static in JWT, what about dynamic scopes (topics generated on the go). My use case is in creating a chat application and topics will be generated on the go whenever a user initiated the chat with other one or a user creates a group.
@pavankumarkatakam There is nothing preventing you from providing additional access control outside of the broker in a chat application or issuing additional tokens for 'group' conversations with their own scopes.
Our authorization service will add a scopes collection to the JWT.
A scope entry will be in the form of: {{service}}:{{action}}:{{mqtt topic}}
{{service}} will be a constant, emq {{action}} will be on of 'publish' or 'subscribe' {{mqtt topic}} will be and MQTT topic, wildcards are allowed, see: http://www.steves-internet-guide.com/understanding-mqtt-topics/ for more detail on MQTT topics.
When a user tries to publish or subscribe to a topic the scopes property of the JWT should be inspected and if the topic matches the actions should be allowed. Otherwise, the action should be rejected.