emqx_auth_pgsql.conf 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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: true | false
  33. auth.pgsql.ssl = false
  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.tls_versions = tlsv1.2
  41. ## SSL keyfile.
  42. ##
  43. ## Value: File
  44. ## auth.pgsql.ssl_opts.keyfile =
  45. ## SSL certfile.
  46. ##
  47. ## Value: File
  48. ## auth.pgsql.ssl_opts.certfile =
  49. ## SSL cacertfile.
  50. ##
  51. ## Value: File
  52. ## auth.pgsql.ssl_opts.cacertfile =
  53. ## Authentication query.
  54. ##
  55. ## Value: SQL
  56. ##
  57. ## Variables:
  58. ## - %u: username
  59. ## - %c: clientid
  60. ## - %C: common name of client TLS cert
  61. ## - %d: subject of client TLS cert
  62. ##
  63. auth.pgsql.auth_query = select password from mqtt_user where username = '%u' limit 1
  64. ## Password hash.
  65. ##
  66. ## Value: plain | md5 | sha | sha256 | bcrypt
  67. auth.pgsql.password_hash = sha256
  68. ## sha256 with salt prefix
  69. ## auth.pgsql.password_hash = salt,sha256
  70. ## sha256 with salt suffix
  71. ## auth.pgsql.password_hash = sha256,salt
  72. ## bcrypt with salt prefix
  73. ## auth.pgsql.password_hash = salt,bcrypt
  74. ## pbkdf2 with macfun iterations dklen
  75. ## macfun: md4, md5, ripemd160, sha, sha224, sha256, sha384, sha512
  76. ## auth.pgsql.password_hash = pbkdf2,sha256,1000,20
  77. ## Superuser query.
  78. ##
  79. ## Value: SQL
  80. ##
  81. ## Variables:
  82. ## - %u: username
  83. ## - %c: clientid
  84. ## - %C: common name of client TLS cert
  85. ## - %d: subject of client TLS cert
  86. ##
  87. auth.pgsql.super_query = select is_superuser from mqtt_user where username = '%u' limit 1
  88. ## ACL query. Comment this query, the ACL will be disabled.
  89. ##
  90. ## Value: SQL
  91. ##
  92. ## Variables:
  93. ## - %a: ipaddress
  94. ## - %u: username
  95. ## - %c: clientid
  96. ##
  97. ## Note: You can add the 'ORDER BY' statement to control the rules match order
  98. 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'