Skip to content

Commit d81b52b

Browse files
committed
update(authn&authz): Add ${peername} placeholder
1 parent fd105f2 commit d81b52b

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

en_US/access-control/authn/authn.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The authentication mechanisms supported in EMQX include:
2424

2525
### X.509 Certificate Authentication
2626

27-
EMQX supports [X.509 certificate authentication](./x509.md) for client authentication. Using X.509 certificate authentication in EMQX, clients and servers can establish trusted connections through TLS/SSL, ensuring the authenticity of communication parties and the integrity of the data transmitted. EMQX allows for both one-way and two-way authentication: one-way authentication where only the server is authenticated by the client, and two-way authentication where both client and server mutually verify each other's certificates. This flexibility caters to various levels of security requirements and deployment scenarios.
27+
EMQX supports [X.509 certificate authentication](./x509.md) for client authentication. Using X.509 certificate authentication in EMQX, clients and servers can establish trusted connections through TLS/SSL, ensuring the authenticity of communication parties and the integrity of the data transmitted. EMQX allows for both one-way and two-way authentication: one-way authentication, where only the server is authenticated by the client, and two-way authentication, where both client and server mutually verify each other's certificates. This flexibility caters to various levels of security requirements and deployment scenarios.
2828

2929
### JWT Authentication
3030

@@ -209,7 +209,9 @@ EMQX currently supports the following placeholders:
209209

210210
- `${peerhost}`: It will be replaced with the client's IP address at runtime. EMQX supports [Proxy Protocol](http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt), that is, even if EMQX is deployed behind some TCP proxy or load balancer, users can still use this placeholder to get the real IP address.
211211

212-
- `${peerport}`: It will be replaced with the client's IP port in runtime.
212+
- `${peerport}`: It will be replaced with the client's IP port at runtime.
213+
214+
- `${peername}`: It will be replaced with the client's IP address and port at runtime, and the format is `IP: PORT`.
213215

214216
- `${cert_subject}`: It will be replaced by the subject of the client's TLS certificate at runtime. If the load balancer sends client certificate information to the TCP listener, ensure that Proxy Protocol v2 is in use.
215217

en_US/access-control/authz/authz.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ The following placeholders are supported in query statements:
9191
* `${username}`: It is replaced with the username at runtime. The username comes from the `Username` field in the `CONNECT` packet. If `peer_cert_as_username` is enabled, it is overridden by the fields or the content of the certificate.
9292
* `${clientid}`: It is replaced by the client ID at runtime. The client ID is normally explicitly specified by the client in the `CONNECT` packet. If `use_username_as_clientid` or `peer_cert_as_clientid` is enabled, this field is overridden by the username, fields in the certificate, or the content of the certificate.
9393
* `${peerhost}`: It is replaced with the client's IP address at runtime. EMQX supports [Proxy Protocol](http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt), that is, even if EMQX is deployed behind some TCP proxy or load balancer, users can still use this placeholder to get the real IP address.
94-
- `${peerport}`: It will be replaced with the client's IP port in runtime.
94+
- `${peerport}`: It will be replaced with the client's IP port at runtime.
95+
- `${peername}`: It will be replaced with the client's IP address and port at runtime, and the format is `IP: PORT`.
9596
* `${cert_common_name}`: It is replaced by the Common Name of the client's TLS certificate at runtime. If the load balancer sends client certificate information to the TCP listener, ensure that Proxy Protocol v2 is in use.
9697
* `${cert_subject}`: It is replaced by the subject of the client's TLS certificate at runtime. If the load balancer sends client certificate information to the TCP listener, ensure that Proxy Protocol v2 is in use.
9798
* `${client_attrs.NAME}`: A client attribute. `NAME` will be replaced by an attribute name set based on predefined configurations at runtime. For details about the client attributes, see [MQTT Client Attributes](../../client-attributes/client-attributes.md).

zh_CN/access-control/authn/authn.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,25 @@ SELECT password_hash, salt FROM mqtt_user where username = 'emqx_u' LIMIT 1
188188

189189
目前 EMQX 支持以下占位符:
190190

191-
- `${clientid}`: 将在运行时被替换为客户端 ID。客户端 ID 一般由客户端在 `CONNECT` 报文中显式指定,如果启用了 `use_username_as_clientid``peer_cert_as_clientid`,则会在连接时被用户名、证书中的字段或证书内容所覆盖。
191+
- `${clientid}`将在运行时被替换为客户端 ID。客户端 ID 一般由客户端在 `CONNECT` 报文中显式指定,如果启用了 `use_username_as_clientid``peer_cert_as_clientid`,则会在连接时被用户名、证书中的字段或证书内容所覆盖。
192192

193-
- `${username}`: 将在运行时被替换为用户名。用户名来自 `CONNECT` 报文中的 `Username` 字段。如果启用了 `peer_cert_as_username`,则会在连接时被证书中的字段或证书内容所覆盖。
193+
- `${username}`将在运行时被替换为用户名。用户名来自 `CONNECT` 报文中的 `Username` 字段。如果启用了 `peer_cert_as_username`,则会在连接时被证书中的字段或证书内容所覆盖。
194194

195-
- `${password}`: 将在运行时被替换为密码。密码来自 `CONNECT` 报文中的 `Password` 字段。
195+
- `${password}`将在运行时被替换为密码。密码来自 `CONNECT` 报文中的 `Password` 字段。
196196

197-
- `${peerhost}`: 将在运行时被替换为客户端的 IP 地址。EMQX 支持 [Proxy Protocol](http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt),即使 EMQX 部署在某些 TCP 代理或负载均衡器之后,用户也可以使用此占位符获得真实 IP 地址。
197+
- `${peerhost}`将在运行时被替换为客户端的 IP 地址。EMQX 支持 [Proxy Protocol](http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt),即使 EMQX 部署在某些 TCP 代理或负载均衡器之后,用户也可以使用此占位符获得真实 IP 地址。
198198

199-
- `${peerport}`: 它将在运行时被客户端的 IP 端口替换。
199+
- `${peerport}`:将在运行时被客户端的 IP 端口替换。
200200

201-
- `${cert_subject}`: 将在运行时被替换为客户端 TLS 证书的主题(Subject)。如果证书信息是从负载均衡器发送到 EMQX 的 TCP 端口,需要确保负载均衡器使用的是 Proxy Protocol v2
201+
- `${peername}`:将在运行时被替换为客户端的 IP 地址和端口,格式为 `IP: PORT`
202202

203-
- `${cert_common_name}`: 将在运行时被替换为客户端 TLS 证书的通用名称(Common Name)。如果证书信息是从负载均衡器发送到 EMQX 的 TCP 端口,需要确保负载均衡器使用的是 Proxy Protocol v2。
203+
- `${cert_subject}`:将在运行时被替换为客户端 TLS 证书的主题(Subject)。如果证书信息是从负载均衡器发送到 EMQX 的 TCP 端口,需要确保负载均衡器使用的是 Proxy Protocol v2。
204+
205+
- `${cert_common_name}`:将在运行时被替换为客户端 TLS 证书的通用名称(Common Name)。如果证书信息是从负载均衡器发送到 EMQX 的 TCP 端口,需要确保负载均衡器使用的是 Proxy Protocol v2。
204206

205207
- `${client_attrs.NAME}`:某个客户端属性。`NAME` 将在运行时根据预定义配置替换为属性名称。有客户端属性的详细信息,请参见 [MQTT 客户端属性](../../client-attributes/client-attributes.md)
206208

207-
- `${zone}`: 在运行时将替换为客户端的 Zone。`${zone}` 占位符可以直接用于认证模板中,简化规则创建,并支持基于 Zone 的特定配置。有关 Zone 的详细配置信息,请参见 [Zone 覆盖](../../configuration/configuration.md#zone-覆盖)
209+
- `${zone}`在运行时将替换为客户端的 Zone。`${zone}` 占位符可以直接用于认证模板中,简化规则创建,并支持基于 Zone 的特定配置。有关 Zone 的详细配置信息,请参见 [Zone 覆盖](../../configuration/configuration.md#zone-覆盖)
208210

209211
例如,以下 ACL 规则使用 `${zone}` 根据客户端的指定 zone 动态应用权限:
210212

zh_CN/access-control/authz/authz.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@ SELECT action, permission, topic FROM mqtt_acl where username = 'emqx_u'
9090

9191
EMQX 授权支持的数据查询占位符如下:
9292

93-
- `${username}`: 将在运行时被替换为用户名。用户名来自 `CONNECT` 报文中的 `Username` 字段。如果启用了 `peer_cert_as_username`,则会在连接时被证书中的字段或证书内容所覆盖。
94-
- `${clientid}`: 将在运行时被替换为客户端 ID。客户端 ID 一般由客户端在 `CONNECT` 报文中显式指定,如果启用了 `use_username_as_clientid``peer_cert_as_clientid`,则会在连接时被用户名、证书中的字段或证书内容所覆盖。
95-
- `${peerhost}`: 将在运行时被替换为客户端的 IP 地址。EMQX 支持 [Proxy Protocol](http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt),即使 EMQX 部署在某些 TCP 代理或负载均衡器之后,用户也可以使用此占位符获得真实 IP 地址。
96-
- `${peerport}`: 它将在运行时被客户端的 IP 端口替换。
97-
- `${cert_common_name}`: 将在运行时被替换为客户端 TLS 证书的通用名称(Common Name)。如果证书信息是从负载均衡器发送到 EMQX 的 TCP 端口,需要确保负载均衡器使用的是 Proxy Protocol v2。
98-
- `${cert_subject}`: 将在运行时被替换为客户端 TLS 证书的主题(Subject)。如果证书信息是从负载均衡器发送到 EMQX 的 TCP 端口,需要确保负载均衡器使用的是 Proxy Protocol v2。
99-
- `${client_attrs.NAME}`: 某个客户端属性。`NAME` 将在运行时根据预定义配置替换为属性名称。有客户端属性的详细信息,请参见 [MQTT 客户端属性](../../client-attributes/client-attributes.md)
100-
- `${zone}`: 在运行时将替换为客户端的 Zone。`${zone}` 占位符可以直接用于授权模板中。有关 Zone 的详细配置信息,请参见 [Zone 覆盖](../../configuration/configuration.md#zone-覆盖)
93+
- `${username}`:将在运行时被替换为用户名。用户名来自 `CONNECT` 报文中的 `Username` 字段。如果启用了 `peer_cert_as_username`,则会在连接时被证书中的字段或证书内容所覆盖。
94+
- `${clientid}`:将在运行时被替换为客户端 ID。客户端 ID 一般由客户端在 `CONNECT` 报文中显式指定,如果启用了 `use_username_as_clientid``peer_cert_as_clientid`,则会在连接时被用户名、证书中的字段或证书内容所覆盖。
95+
- `${peerhost}`:将在运行时被替换为客户端的 IP 地址。EMQX 支持 [Proxy Protocol](http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt),即使 EMQX 部署在某些 TCP 代理或负载均衡器之后,用户也可以使用此占位符获得真实 IP 地址。
96+
- `${peerport}`:将在运行时被客户端的 IP 端口替换。
97+
- `${peername}`:将在运行时被替换为客户端的 IP 地址和端口,格式为 `IP: PORT`
98+
- `${cert_common_name}`:将在运行时被替换为客户端 TLS 证书的通用名称(Common Name)。如果证书信息是从负载均衡器发送到 EMQX 的 TCP 端口,需要确保负载均衡器使用的是 Proxy Protocol v2。
99+
- `${cert_subject}`:将在运行时被替换为客户端 TLS 证书的主题(Subject)。如果证书信息是从负载均衡器发送到 EMQX 的 TCP 端口,需要确保负载均衡器使用的是 Proxy Protocol v2。
100+
- `${client_attrs.NAME}`:某个客户端属性。`NAME` 将在运行时根据预定义配置替换为属性名称。有客户端属性的详细信息,请参见 [MQTT 客户端属性](../../client-attributes/client-attributes.md)
101+
- `${zone}`:在运行时将替换为客户端的 Zone。`${zone}` 占位符可以直接用于授权模板中。有关 Zone 的详细配置信息,请参见 [Zone 覆盖](../../configuration/configuration.md#zone-覆盖)
101102

102103
<!-- TODO
103104
确认 HTTP AuthZ 为什么会多出几个

0 commit comments

Comments
 (0)