emqx_auth_pgsql.conf 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. ##
  36. ## Available enum values:
  37. ## tlsv1.3,tlsv1.2,tlsv1.1,tlsv1
  38. ##
  39. ## Value: String, seperated by ','
  40. #auth.pgsql.ssl.tls_versions = tlsv1.3,tlsv1.2,tlsv1.1
  41. ## SSL keyfile.
  42. ##
  43. ## Value: File
  44. #auth.pgsql.ssl.keyfile =
  45. ## SSL certfile.
  46. ##
  47. ## Value: File
  48. #auth.pgsql.ssl.certfile =
  49. ## SSL cacertfile.
  50. ##
  51. ## Value: File
  52. #auth.pgsql.ssl.cacertfile =
  53. ## In mode verify_none the default behavior is to allow all x509-path
  54. ## validation errors.
  55. ##
  56. ## Value: true | false
  57. #auth.pgsql.ssl.verify = false
  58. ## If not specified, the server's names returned in server's certificate is validated against
  59. ## what's provided `auth.pgsql.server` config's host part.
  60. ## Setting to 'disable' will make EMQ X ignore unmatched server names.
  61. ## If set with a host name, the server's names returned in server's certificate is validated
  62. ## against this value.
  63. ##
  64. ## Value: String | disable
  65. ## auth.pgsql.ssl.server_name_indication = disable
  66. ## Authentication query.
  67. ##
  68. ## Value: SQL
  69. ##
  70. ## Variables:
  71. ## - %u: username
  72. ## - %c: clientid
  73. ## - %C: common name of client TLS cert
  74. ## - %d: subject of client TLS cert
  75. ##
  76. auth.pgsql.auth_query = select password from mqtt_user where username = '%u' limit 1
  77. ## Password hash.
  78. ##
  79. ## Value: plain | md5 | sha | sha256 | bcrypt
  80. auth.pgsql.password_hash = sha256
  81. ## sha256 with salt prefix
  82. ## auth.pgsql.password_hash = salt,sha256
  83. ## sha256 with salt suffix
  84. ## auth.pgsql.password_hash = sha256,salt
  85. ## bcrypt with salt prefix
  86. ## auth.pgsql.password_hash = salt,bcrypt
  87. ## pbkdf2 with macfun iterations dklen
  88. ## macfun: md4, md5, ripemd160, sha, sha224, sha256, sha384, sha512
  89. ## auth.pgsql.password_hash = pbkdf2,sha256,1000,20
  90. ## Superuser query.
  91. ##
  92. ## Value: SQL
  93. ##
  94. ## Variables:
  95. ## - %u: username
  96. ## - %c: clientid
  97. ## - %C: common name of client TLS cert
  98. ## - %d: subject of client TLS cert
  99. ##
  100. auth.pgsql.super_query = select is_superuser from mqtt_user where username = '%u' limit 1
  101. ## ACL query. Comment this query, the ACL will be disabled.
  102. ##
  103. ## Value: SQL
  104. ##
  105. ## Variables:
  106. ## - %a: ipaddress
  107. ## - %u: username
  108. ## - %c: clientid
  109. ##
  110. ## Note: You can add the 'ORDER BY' statement to control the rules match order
  111. 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'