welcom ! Handel home

2022年2月10日 星期四

Mosquitto acl topic存取權限管理

  mosquitto topic 設定ACL(Access Control List)


>>對於 Tpoic 的讀寫 有三種權限

< read , write , readwrite >


>>對於 MQTT client user  管理權限設定有三類


1#General section                 通用user 權限

2#User specific section         指定user 權限

3#Client or user ID section   由登入帳號指定權限


>> 設定格式

1#General section   < 用於不定隨機 登入者之權限管理 >

   以 topic 關鍵字 開頭 定義 指定的topic 相關讀寫權限給 不特定的 登入者 

   但若登入者有登入的 user ID 則不是適用 


 topic read  $SYS/#

 topic write $log/#

 topic readwrite $node/#



2#User specific section    <用於 指定user 權限管理 授權特定管理者帳號的操作> 

    以 user 關鍵字開頭 定義接下來的 topic 權限清單

    相關清單 均為指定之user ID 之權限


 user JOHN

 topic read $USER/#

 topic write $USER/#

 topic readwrite $USER/+/GPIO


3#Client or user ID section   <由登入帳號指定權限 授權使用者帳號 管理操作topic 權限 >

   適用在 以認證方式登入 之 user ID 以  pattern 關鍵字開頭 定義 相關之topic 讀寫權限

   %c  client ID  , %u user ID


 pattern  read   $USER/connect/%c/state

 pattern  write  $USER/connect/%c/data

 pattern  readwrite $USER/device/%u/control