You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -8,7 +8,7 @@ Knowledge about [basic EMQX authorization concepts](./authz.md)
8
8
9
9
:::
10
10
11
-
## Configure with Dashboard
11
+
## Create Built-in Database Authorizer via Dashboard
12
12
13
13
1. On the [EMQX Dashboard](http://127.0.0.1:18083/#/authentication), navigate to **Access Control** > **Authorization** in the left-hand menu to open the **Authorization** page.
14
14
@@ -26,7 +26,7 @@ Knowledge about [basic EMQX authorization concepts](./authz.md)
26
26
27
27
4. Click **Create** to complete the setup.
28
28
29
-
## Configure with Configuration File
29
+
## Create Built-in Database Authorizer via Configuration File
30
30
31
31
The built-in database authorizer is identified by type `built_in_database`.
32
32
@@ -51,71 +51,161 @@ You can create authorization rules through the Dashboard or API.
51
51
52
52
### Create Authorization Rules via Dashboard
53
53
54
-
On the **Authorization** page in Dashboard, click the **Permissions** button in the **Actions** column of the **Built-in Database** backend.
54
+
You can define authorization rules directly from the EMQX Dashboard by using the **Permissions** page of the **Built-in Database** backend.
55
+
56
+
#### Access the Permissions Page
57
+
58
+
1. In the Dashboard, go to the **Authorization** page.
59
+
2. In the **Actions** column of the **Built-in Database** backend, click **Permissions**.
|**Client ID**|**Client ID**: (Required) Exact client ID to which this rule applies.<br />**Username Pattern**: (Optional) A regular expression to match usernames for which this rule is valid. |
91
+
|**Username**|**Username**: (Required) Exact username to which this rule applies.<br />**Client ID Pattern**: (Optional) A regular expression to match client IDs for which this rule is valid. |
92
+
|**All Users**|**Client ID Pattern**: (Optional) A regular expression to match usernames for which this rule is valid.<br />**Username Pattern**: (Optional) A regular expression to match usernames for which this rule is valid. |
93
+
94
+
**Example patterns:**
95
+
96
+
-`^device-user-.*`: Matches usernames starting with `device-user-`.
97
+
-`^sensor-.*`: Matches client IDs starting with `sensor-`.
98
+
99
+
#### Add a Rule
100
+
101
+
1. On the **Permissions** page, select the target tab: **Client ID**, **Username**, or **All Users**.
102
+
2. Click **Add**.
103
+
3. Fill in the [common fields](#common-rule-fields) and any [scope-specific fields](#fields-by-rule-scope).
104
+
4. (Optional) Click **Add Permission** to add multiple rules. Use the **Up** and **Down** buttons to adjust rule execution order.
105
+
5. Click **Add** to save the rule.
106
+
107
+
#### Manage Multiple Rules (All Users Only)
108
+
109
+
For **All Users** rules, you can change rule order from the **More** menu in the **Actions** column:
110
+
111
+
- Move Up
112
+
- Move Down
113
+
- Move to Top
114
+
- Move to Bottom
59
115
60
-
-**Client ID**: See the **Client ID** tab, specify the client that this rule applies to.
61
-
-**Username**: See the **Username** tab, specify the user that this rule applies to.
62
-
-**Permission**: Whether to allow or deny a certain type of operation request from the current client/user; optional values: **Allow**, **Deny**.
63
-
-**Action**: Configure the operation corresponding to this rule; optional values: **Publish**, **Subscribe**, **Publish & Subscribe**.
64
-
-**Topic**: Configure the topic corresponding to this rule.
116
+
Rules are evaluated from top to bottom, so order determines priority.
65
117
66
-
EMQX supports configuring multiple authorization check rules for a single client or user, and you can adjust the execution order and priority of different rules through the **Move Up** and **Move Down** buttons on the page.
118
+
#### Edit and Manage Rules
67
119
68
-
If you want to configure authorization check rules for multiple clients or users at the same time, you can import the relevant configuration through the HTTP API.
120
+
On the **Permissions** page, you can edit or delete existing rules:
69
121
70
-
### Create via REST API
122
+
- In the **Actions** column of the corresponding rule, click the **Edit** button to modify rule fields, matching patterns, or IP range settings.
123
+
- Click the **Delete** button to remove a rule.
71
124
72
-
Rules are also managed through `/api/v5/authorization/sources/built_in_database` APIs.
You can also manage authorization rules through the REST API. The API endpoints correspond directly to the Dashboard’s three scopes: Username, Client ID, and All Users.
curl -X POST 'http://localhost:18083/api/v5/authorization/sources/built_in_database/rules/users' \
90
145
-H 'Content-Type: application/json' \
91
146
-d '[
92
-
{
93
-
"clientid": "client1",
147
+
{
148
+
"username": "user1",
149
+
"rules": [
150
+
{
151
+
"topic": "v1/devices/#",
152
+
"permission": "allow",
153
+
"action": "publish",
154
+
"qos": [0,1,2],
155
+
"retain": "all"
156
+
}
157
+
]
158
+
}
159
+
]'
160
+
```
161
+
162
+
#### Example: Update Rules for a User
163
+
164
+
```bash
165
+
curl -X PUT 'http://localhost:18083/api/v5/authorization/sources/built_in_database/rules/users/user1' \
166
+
-H 'Content-Type: application/json' \
167
+
-d '{
168
+
"username": "user1",
94
169
"rules": [
95
170
{
96
-
"action": "publish",
171
+
"topic": "v1/devices/+/state",
97
172
"permission": "allow",
98
-
"topic": "test/topic/1"
99
-
},
100
-
{
101
173
"action": "subscribe",
102
-
"permission": "allow",
103
-
"topic": "test/topic/2"
104
-
},
105
-
{
106
-
"action": "all",
107
-
"permission": "deny",
108
-
"topic": "eq test/#"
174
+
"qos": [0,1],
175
+
"retain": "all"
109
176
}
110
177
]
111
-
}
112
-
]'
178
+
}'
113
179
```
114
180
115
-
Each rule contains:
116
-
*`permission`: Whether to allow or deny a certain type of operation request from current client/user; optional values: `allow` or `deny`;
117
-
*`action`: Configure the operation corresponding to this rule; optional values: `publish`, `subscribe`, or `all`;
118
-
*`topic`: Configure the corresponding to this rule, supporting [topic placeholders](./authz.md#topic-placeholders).
119
-
*`qos`: (Optional) A number array used to specify the QoS levels that the rule applies to, e.g. `[0, 1]`, `[1, 2]`. The default is all QoS levels.
120
-
*`retain`: (Optional) Used to specify whether the current rule supports retained messages. Value options are `true`, `false`. Default is to allow retained messages.
181
+
#### Example: Create Rules for All Users
182
+
183
+
```bash
184
+
curl -X POST 'http://localhost:18083/api/v5/authorization/sources/built_in_database/rules/all' \
Copy file name to clipboardExpand all lines: en_US/getting-started/getting-started.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ Container deployment is the quickest way to start exploring EMQX. This quick sta
56
56
57
57
### Install EMQX Using Installation Package
58
58
59
-
You can also install EMQX using installation packages on a computer or VM and easily adjust the configurations or run performance tuning. The instructions below use macOS 15 (Sequoia) and arm64 architecure (Apple Silicon) as an example to illustrate the installation steps.
59
+
You can also install EMQX using installation packages on a computer or VM and easily adjust the configurations or run performance tuning. The instructions below use macOS 15 (Sequoia) and arm64 architecture (Apple Silicon) as an example to illustrate the installation steps.
60
60
61
61
::: tip
62
62
@@ -114,7 +114,7 @@ The broker address and the port information should be prepared before testing th
114
114
115
115
1. Click [MQTTX Web](https://mqttx.app/web-client#/recent_connections) to visit the browser-based MQTTX.
116
116
117
-
2. Configure and establish the MQTT connection. Click the **+ New Connection** button to enter the configure page:
117
+
2. Configure and establish the MQTT connection. Click the **+ New Connection** button to enter the configuration page:
118
118
119
119
-**Name**: Input a connection name, for example, `MQTTX_Test`.
0 commit comments