emqx_auth_pgsql.conf 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ##--------------------------------------------------------------------
  2. ## PostgreSQL Auth/ACL Plugin
  3. ##--------------------------------------------------------------------
  4. ## PostgreSQL server address.
  5. ##
  6. ## Value: Port | IP:Port
  7. ##
  8. ## Examples: 5432, 127.0.0.1:5432, localhost:5432
  9. auth.pgsql.server = 127.0.0.1:5432
  10. ## PostgreSQL pool size.
  11. ##
  12. ## Value: Number
  13. auth.pgsql.pool = 8
  14. ## PostgreSQL username.
  15. ##
  16. ## Value: String
  17. auth.pgsql.username = root
  18. ## PostgreSQL password.
  19. ##
  20. ## Value: String
  21. # auth.pgsql.password =
  22. ## PostgreSQL database.
  23. ##
  24. ## Value: String
  25. auth.pgsql.database = mqtt
  26. ## PostgreSQL database encoding.
  27. ##
  28. ## Value: String
  29. auth.pgsql.encoding = utf8
  30. ## Whether to enable SSL connection.
  31. ##
  32. ## Value: on | off
  33. auth.pgsql.ssl = off
  34. ## TLS version
  35. ## You can configure multi-version use "," split,
  36. ## default value is :tlsv1.2
  37. ## Example:
  38. ## tlsv1.1,tlsv1.2,tlsv1.3
  39. ##
  40. ## auth.pgsql.ssl_opts.tls_versions = tlsv1.2
  41. ## TLS version
  42. ## You can configure multi-version use "," split,
  43. ## default value is :tlsv1.2
  44. ## Example:
  45. ## tlsv1.1,tlsv1.2,tlsv1.3
  46. ##
  47. ## auth.pgsql.ssl.tls_versions = tlsv1.2
  48. ## SSL keyfile.
  49. ##
  50. ## Value: File
  51. ## auth.pgsql.ssl.keyfile =
  52. ## SSL certfile.
  53. ##
  54. ## Value: File
  55. ## auth.pgsql.ssl.certfile =
  56. ## SSL cacertfile.
  57. ##
  58. ## Value: File
  59. ## auth.pgsql.ssl.cacertfile =
  60. ## Authentication query.
  61. ##
  62. ## Value: SQL
  63. ##
  64. ## Variables:
  65. ## - %u: username
  66. ## - %c: clientid
  67. ## - %C: common name of client TLS cert
  68. ## - %d: subject of client TLS cert
  69. ##
  70. auth.pgsql.auth_query = select password from mqtt_user where username = '%u' limit 1
  71. ## Password hash.
  72. ##
  73. ## Value: plain | md5 | sha | sha256 | bcrypt
  74. auth.pgsql.password_hash = sha256
  75. ## sha256 with salt prefix
  76. ## auth.pgsql.password_hash = salt,sha256
  77. ## sha256 with salt suffix
  78. ## auth.pgsql.password_hash = sha256,salt
  79. ## bcrypt with salt prefix
  80. ## auth.pgsql.password_hash = salt,bcrypt
  81. ## pbkdf2 with macfun iterations dklen
  82. ## macfun: md4, md5, ripemd160, sha, sha224, sha256, sha384, sha512
  83. ## auth.pgsql.password_hash = pbkdf2,sha256,1000,20
  84. ## Superuser query.
  85. ##
  86. ## Value: SQL
  87. ##
  88. ## Variables:
  89. ## - %u: username
  90. ## - %c: clientid
  91. ## - %C: common name of client TLS cert
  92. ## - %d: subject of client TLS cert
  93. ##
  94. auth.pgsql.super_query = select is_superuser from mqtt_user where username = '%u' limit 1
  95. ## ACL query. Comment this query, the ACL will be disabled.
  96. ##
  97. ## Value: SQL
  98. ##
  99. ## Variables:
  100. ## - %a: ipaddress
  101. ## - %u: username
  102. ## - %c: clientid
  103. ##
  104. ## Note: You can add the 'ORDER BY' statement to control the rules match order
  105. auth.pgsql.acl_query = select allow, ipaddr, username, clientid, access, topic from mqtt_acl where ipaddr = '%a' or username = '%u' or username = '$all' or clientid = '%c'