emqx_authz.hrl 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. -define(APP, emqx_authz).
  2. -define(ALLOW_DENY(A), ((A =:= allow) orelse (A =:= <<"allow">>) orelse
  3. (A =:= deny) orelse (A =:= <<"deny">>)
  4. )).
  5. -define(PUBSUB(A), ((A =:= subscribe) orelse (A =:= <<"subscribe">>) orelse
  6. (A =:= publish) orelse (A =:= <<"publish">>) orelse
  7. (A =:= all) orelse (A =:= <<"all">>)
  8. )).
  9. -define(CMD_REPLACE, replace).
  10. -define(CMD_DELETE, delete).
  11. -define(CMD_PREPEND, prepend).
  12. -define(CMD_APPEND, append).
  13. -define(CMD_MOVE, move).
  14. -define(CMD_MOVE_TOP, <<"top">>).
  15. -define(CMD_MOVE_BOTTOM, <<"bottom">>).
  16. -define(CMD_MOVE_BEFORE(Before), {<<"before">>, Before}).
  17. -define(CMD_MOVE_AFTER(After), {<<"after">>, After}).
  18. -define(CONF_KEY_PATH, [authorization, sources]).
  19. -define(RE_PLACEHOLDER, "\\$\\{[a-z0-9_]+\\}").
  20. -define(USERNAME_RULES_EXAMPLE, #{username => user1,
  21. rules => [ #{topic => <<"test/toopic/1">>,
  22. permission => <<"allow">>,
  23. action => <<"publish">>
  24. }
  25. , #{topic => <<"test/toopic/2">>,
  26. permission => <<"allow">>,
  27. action => <<"subscribe">>
  28. }
  29. , #{topic => <<"eq test/#">>,
  30. permission => <<"deny">>,
  31. action => <<"all">>
  32. }
  33. ]
  34. }).
  35. -define(CLIENTID_RULES_EXAMPLE, #{clientid => client1,
  36. rules => [ #{topic => <<"test/toopic/1">>,
  37. permission => <<"allow">>,
  38. action => <<"publish">>
  39. }
  40. , #{topic => <<"test/toopic/2">>,
  41. permission => <<"allow">>,
  42. action => <<"subscribe">>
  43. }
  44. , #{topic => <<"eq test/#">>,
  45. permission => <<"deny">>,
  46. action => <<"all">>
  47. }
  48. ]
  49. }).
  50. -define(ALL_RULES_EXAMPLE, #{rules => [ #{topic => <<"test/toopic/1">>,
  51. permission => <<"allow">>,
  52. action => <<"publish">>
  53. }
  54. , #{topic => <<"test/toopic/2">>,
  55. permission => <<"allow">>,
  56. action => <<"subscribe">>
  57. }
  58. , #{topic => <<"eq test/#">>,
  59. permission => <<"deny">>,
  60. action => <<"all">>
  61. }
  62. ]
  63. }).
  64. -define(META_EXAMPLE, #{ page => 1
  65. , limit => 100
  66. , count => 1
  67. }).