Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix postgresql table example #2799

Open
wants to merge 2 commits into
base: release-5.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions en_US/access-control/authz/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,15 @@ Users need to provide a query statement template and ensure the following fields
Example table structure for storing credentials:

```sql
CREATE TYPE ACTION AS ENUM('publish','subscribe','all');
CREATE TYPE PERMISSION AS ENUM('allow','deny');

CREATE TABLE mqtt_acl (
id SERIAL PRIMARY KEY,
ipaddress CHARACTER VARYING(60) NOT NULL DEFAULT '',
username CHARACTER VARYING(255) NOT NULL DEFAULT '',
clientid CHARACTER VARYING(255) NOT NULL DEFAULT '',
action ACTION,
permission PERMISSION,
topic CHARACTER VARYING(255) NOT NULL,
qos tinyint,
retain tinyint
CREATE TABLE mqtt_acl(
id serial PRIMARY KEY,
username text NOT NULL,
permission text NOT NULL,
action text NOT NULL,
topic text NOT NULL,
qos smallint,
retain smallint
);

CREATE INDEX mqtt_acl_username_idx ON mqtt_acl(username);
```

Expand Down
13 changes: 7 additions & 6 deletions zh_CN/access-control/authz/postgresql.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 基于 PostgreSQL 进行授权

PostgreSQL Authorizer 支持客户端的权限列表存储在 PostgreSQL 数据库中。
PostgreSQL 授权器支持客户端的权限列表存储在 PostgreSQL 数据库中。

::: tip 前置准备

Expand All @@ -9,7 +9,7 @@ PostgreSQL Authorizer 支持客户端的权限列表存储在 PostgreSQL 数据

## 表结构与查询语句

PostgreSQL Authorizer 可以支持任何表结构,甚至是多个表联合查询、或从视图中查询。用户需要提供一个查询 SQL 模板,且确保查询结果包含以下字段:
PostgreSQL 授权器可以支持任何表结构,甚至是多个表联合查询、或从视图中查询。用户需要提供一个查询 SQL 模板,且确保查询结果包含以下字段:

- `permission`: 用于指定操作权限,可选值有 `allow` 和 `deny`。
- `action`: 用于指定当前规则适用于哪些操作,可选值有 `publish`、`subscribe` 和 `all`。
Expand All @@ -26,8 +26,8 @@ CREATE TABLE mqtt_acl(
permission text NOT NULL,
action text NOT NULL,
topic text NOT NULL,
qos tinyint,
retain tinyint
qos smallint,
retain smallint
);
CREATE INDEX mqtt_acl_username_idx ON mqtt_acl(username);
```
Expand Down Expand Up @@ -60,13 +60,14 @@ query = "SELECT permission, action, topic, qos, retain FROM mqtt_acl WHERE usern
3. 按照以下说明进行配置。

- **服务**:指定 EMQX 要连接的服务器地址(`host:port`)。
- **数据库**: PostgreSQL 数据库名称。

- **数据库**: PostgreSQL 数据库名称。
- **用户名**(可选): 指定用户名。
- **密码**(可选): 指定用户密码。
- **启用 TLS**:如果要启用 TLS,请启用此项。
- **连接池大小**(可选): 输入一个整数值,以定义从 EMQX 节点到 PostgreSQL 的并发连接数。默认值: `8`.
- **禁用预处理语句**(可选):如果使用的 PostgreSQL 服务不支持预处理语句,如事务模式下的 PGBouncer 或 Supabase,请启用此选项。该选项在 EMQ X v5.7.1 中引入。
- **SQL**: 根据数据模式填写查询语句。有关详细信息,请参阅 [表结构与查询语句](#表结构与查询语句)。
- **SQL**: 根据数据模式填写查询语句。有关详细信息,请参阅 [表结构与查询语句](#表结构与查询语句)。
4. 单击**创建**完成设置。

## 配置项
Expand Down