Skip to content

Commit 26b9692

Browse files
committed
feat(dashboard): Dashboard support token-based login
1 parent 5a3f119 commit 26b9692

File tree

2 files changed

+99
-1
lines changed

2 files changed

+99
-1
lines changed

en_US/dashboard/introduction.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Support for custom plug-in integration, Extend EMQX connectivity protocols throu
3232

3333
In addition to debugging through online MQTT over WebSocket client connections and publishing subscriptions, we also support diagnosing and finding issues using things like slow subscriptions and online logs tracing and alarms.
3434

35-
## Running
35+
## Launch Dashboard
3636

3737
EMQX Dashboard is a web application that listens to port `18083` by default. After installing EMQX successfully, you can access and use EMQX Dashboard by opening <http://localhost:18083/> (replace localhost with the actual IP address if deployed on a non-local machine) through your browser.
3838

@@ -46,6 +46,54 @@ For users who have installed EMQX for the first time, you can use the default us
4646

4747
After logging in for the first time, the system will automatically detect that you are logging in with the default username and password, and will force you to change the default password, which is good for the security of accessing Dashboard, note that the changed password cannot be the same as the original password, and it is not recommended to use `public` as the login password again.
4848

49+
### Token-Based Login via URL
50+
51+
Starting from EMQX 5.6.0, the Dashboard supports a token-based login method that allows users to log in directly by embedding authentication information in the URL.
52+
53+
This feature is particularly useful for seamless redirection and integration scenarios where a user should be logged in automatically without entering credentials manually.
54+
55+
#### How To Use This Login Method
56+
57+
1. Call the `/login` API to obtain the login token and related information.
58+
59+
2. Manually add the username used during login (not included in the `/login` response).
60+
61+
3. Combine the data into a JSON structure:
62+
63+
```json
64+
{
65+
"license": {
66+
"edition": "ee"
67+
},
68+
"role": "administrator",
69+
"token": "xxx.jwt.token",
70+
"version": "5.5.0-g0fef19f8",
71+
"username": "admin"
72+
}
73+
```
74+
75+
4. Convert the JSON string to Base64.
76+
77+
5. Embed the encoded string in the `login_meta` query parameter of the Dashboard URL.
78+
79+
#### Example URL
80+
81+
For versions **before 5.6.0**:
82+
83+
```bash
84+
http://localhost:18083?login_meta=BASE64_ENCODED_STRING
85+
```
86+
87+
Redirects to the default cluster overview page.
88+
89+
For **version 5.6.0 and later**, you can also specify a target page:
90+
91+
```bash
92+
http://localhost:18083/#/dashboard/overview?login_meta=BASE64_ENCODED_STRING
93+
```
94+
95+
This method provides a smooth, pre-authenticated user experience for accessing the EMQX Dashboard. Make sure to handle the token securely and ensure it has appropriate expiration and scope limits.
96+
4997
## Reset password
5098

5199
You can reset your Dashboard login password via the `admins` command. For details, see [CLI - admins](../admin/cli.md#admins).

zh_CN/dashboard/introduction.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,56 @@ EMQX Dashboard 是一个 Web 应用程序,默认监听 `18083` 端口。下载
4646

4747
首次登录后,系统会自动检测到您正在使用默认用户名和密码登录,并会强制要求修改默认密码,这有利于访问 Dashboard 的安全性提升,注意修改的密码不能与原密码相同,且不建议再次使用 `public` 做为登录密码。
4848

49+
### 通过 URL Token 登录 Dashboard
50+
51+
从 EMQX 5.6.0 开始,Dashboard 支持通过在 URL 中携带登录信息的方式进行免登录访问。
52+
53+
此功能适用于需要无缝跳转或集成场景,可在无需用户手动输入凭据的情况下,自动登录 Dashboard。
54+
55+
#### 使用方法
56+
57+
使用此登录方式的步骤如下:
58+
59+
1. 调用 `/login` 接口,获取登录返回的 token 及相关信息。
60+
61+
2. 手动添加登录时使用的用户名(该字段不包含在接口返回中)。
62+
63+
3. 将数据整理成如下 JSON 结构:
64+
65+
```json
66+
{
67+
"license": {
68+
"edition": "ee"
69+
},
70+
"role": "administrator",
71+
"token": "xxx.jwt.token",
72+
"version": "5.5.0-g0fef19f8",
73+
"username": "admin"
74+
}
75+
```
76+
77+
4. 将 JSON 字符串进行 Base64 编码。
78+
79+
5. 将编码后的字符串通过 `login_meta` 参数附加到 Dashboard 的访问 URL 中。
80+
81+
#### 示例 URL
82+
83+
**5.6.0 以下版本**
84+
85+
```bash
86+
http://localhost:18083?login_meta=BASE64_ENCODED_STRING
87+
```
88+
89+
将默认跳转至集群总览页面。
90+
91+
**5.6.0 及以上版本**,可指定跳转页面:
92+
93+
```bash
94+
http://localhost:18083/#/dashboard/overview?login_meta=BASE64_ENCODED_STRING
95+
```
96+
97+
通过该方式,可以为用户提供无需手动登录的便捷访问体验。请确保妥善管理 token 的安全性,建议设置合理的过期时间和访问权限范围。
98+
4999
## 忘记密码
50100

51101
如果您忘记了 Dashboard 登录密码,可以通过 CLI 的 `admins` 命令进行重置,详情请参考 [命令行 - admins](../admin/cli.md#admins)

0 commit comments

Comments
 (0)