On this page
user.checkAuthentication
描述
object user.checkAuthentication
此方法用于检查并延长用户会话。
使用参数 sessionid 调用 user.checkAuthentication 方法将默认延长用户会话。
参数
该方法接受以下参数。
| Parameter | Type | Description |
|---|---|---|
| extend | boolean | 是否延长用户会话。 默认值:"true"。 将值设置为 "false" 可在不延长会话的情况下检查用户会话。 参数行为: - 如果 sessionid 已设置,则为 supported |
| sessionid | string | 用户 authentication token。 参数行为: - 如果未设置 token,则为 required |
| token | string | 用户 API token。 参数行为: - 如果未设置 sessionid,则为 required |
返回值
(object) 返回一个包含用户信息的对象。
除了标准用户属性之外,还会返回以下信息。
| Property | Type | Description |
|---|---|---|
| auth_type | integer | 用户的默认认证方式。 有关可能值的列表,请参阅 Authentication object 的 authentication_type 属性。 |
| debug_mode | integer | 是否为该用户启用调试模式。 有关可能值的列表,请参阅 User group object 的 debug_mode 属性。 |
| deprovisioned | boolean | 该用户是否属于已取消分配用户组。 |
| gui_access | string | 用户访问前端的认证方式。 有关可能值的列表,请参阅 User group object 的 gui_access 属性。 |
| secret | string | 随机生成的 32 个字符字符串。在用户登录时生成。 如果使用 API token 检查用户会话,则不会返回 secret 属性。 |
| sessionid | string | 认证 token,后续 API 请求中必须使用。 如果使用 API token 检查用户会话,则不会返回 sessionid 属性。 |
| type | integer | 用户类型。 有关可能值的列表,请参阅 Role object 的 type 属性。 |
| userip | string | 用户的 IP 地址。 |
示例
使用身份验证令牌检查身份验证
使用用户身份验证令牌检查并延长用户会话,并返回有关用户的附加信息。
执行请求:
{
"jsonrpc": "2.0",
"method": "user.checkAuthentication",
"params": {
"sessionid": "673b8ba11562a35da902c66cf5c23fa2"
},
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": {
"userid": "1",
"username": "Admin",
"name": "Zabbix",
"surname": "Administrator",
"url": "",
"autologin": "1",
"autologout": "0",
"lang": "ru_RU",
"refresh": "0",
"theme": "default",
"attempt_failed": "0",
"attempt_ip": "127.0.0.1",
"attempt_clock": "1355919038",
"rows_per_page": "50",
"timezone": "Europe/Riga",
"roleid": "3",
"userdirectoryid": "0",
"ts_provisioned": "0",
"type": 3,
"userip": "127.0.0.1",
"debug_mode": 0,
"gui_access": "0",
"deprovisioned": false,
"auth_type": 0,
"sessionid": "673b8ba11562a35da902c66cf5c23fa2",
"secret": "0e329b933e46984e49a5c1051ecd0751"
},
"id": 1
}
使用 API token 检查认证
使用用户 API token 检查用户会话,并返回有关该用户的附加信息。
请求:
{
"jsonrpc": "2.0",
"method": "user.checkAuthentication",
"params": {
"token": "00aff470e07c12d707e50d98cfe39edef9e6ec349c14728dbdfbc8ddc5ea3eae"
},
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": {
"userid": "1",
"username": "Admin",
"name": "Zabbix",
"surname": "Administrator",
"url": "",
"autologin": "1",
"autologout": "0",
"lang": "ru_RU",
"refresh": "0",
"theme": "default",
"attempt_failed": "0",
"attempt_ip": "127.0.0.1",
"attempt_clock": "1355919338",
"rows_per_page": "50",
"timezone": "Europe/Riga",
"roleid": "3",
"userdirectoryid": "0",
"ts_provisioned": "0",
"debug_mode": 0,
"deprovisioned": false,
"gui_access": "1",
"mfaid": 0,
"auth_type": 0,
"type": 3,
"userip": "127.0.0.1"
},
"id": 1
}
来源
在 ui/include/classes/api/services/CUser.php 中的 CUser::checkAuthentication()。