On this page
检查认证
描述
object user.checkAuthentication
此方法检查并延长用户会话。
默认情况下,使用参数 'sessionid' 调用 'user.checkAuthentication' 会延长用户会话。
参数
该方法接受以下参数。
| 参数 | 类型 | 说明 |
|---|---|---|
| extend | boolean | 是否延长用户会话。 默认值:"true"。 将该值设置为 "false" 可在不延长会话的情况下检查用户会话。 参数行为: - 如果设置了 sessionid,则支持 |
| sessionid | string | 用户认证令牌。 参数行为: - 如果未设置 token,则为必需 |
| token | string | 用户 API 令牌。 参数行为: - 如果未设置 sessionid,则为必需 |
返回值
(object) 返回一个包含用户信息的对象。
除标准用户属性外,还会返回以下信息。
| 属性 | Type | 描述 |
|---|---|---|
| auth_type | integer | 用户的默认认证方式。 有关可能的值列表,请参见认证对象的 authentication_type 属性。 |
| debug_mode | integer | 是否为用户启用或禁用调试模式。 有关可能的值列表,请参见用户组对象的 debug_mode 属性。 |
| deprovisioned | boolean | 用户是否属于已取消配置用户组。 |
| gui_access | string | 用户访问前端的认证方法。 有关可能的值列表,请参见用户组对象的 gui_access 属性。 |
| secret | string | 随机的 32 个字符字符串。在用户登录时生成。 如果使用 API token 检查用户会话,则不会返回 secret 属性。 |
| sessionid | string | 认证令牌,必须在后续 API 请求中使用。 如果使用 API token 检查用户会话,则不会返回 sessionid 属性。 |
| type | integer | 用户类型。 有关可能的值列表,请参见角色对象的 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 令牌检查身份验证
使用用户 API 令牌检查用户会话,并返回有关该用户的附加信息。
请求:
{
"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()。