user.checkAuthentication

描述

object user.checkAuthentication

此方法用于检查并延长用户会话。

使用参数 sessionid 调用 user.checkAuthentication 方法将默认延长用户会话。

参数

该方法接受以下参数。

参数 数据类型 描述
extend boolean 是否延长用户会话。

默认值:"true"。
将值设为 "false" 可以在不延长会话的情况下检查用户会话。

参数行为
- 如果 sessionid 已设置,则为 supported
sessionid string 用户 认证

参数行为
- 如果 token 未设置,则为 required
secret string 随机 32 字符 string。在用户登录时生成。
token string 用户 认证

参数行为
- 如果 sessionid 未设置,则为 required

返回值

(object) 返回一个包含用户信息的 object。

除了 用户 外,还会返回以下信息。

属性 数据类型 描述
auth_type integer 用户的默认认证方式。

可能的取值列表,请参考 认证-objectauthentication_type 属性。
debug_mode integer 是否为用户启用了调试模式。

可能的取值列表,请参考 用户组debug_mode 属性。
deprovisioned boolean 用户是否属于某个 配置
gui_access string 用户访问前端的身份验证方法。

可能的取值列表,请参考 用户组gui_access 属性。
secret string 随机生成的 32 字符串 string。在用户登录时生成。

如果使用 API 令牌验证用户会话,则不会返回属性 secret
sessionid string 身份验证令牌,后续的 API 请求必须使用该令牌。

如果使用 API 令牌验证用户会话,则不会返回属性 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",
               "type": 3,
               "userip": "127.0.0.1",
               "debug_mode": 0,
               "gui_access": "1",
               "deprovisioned": false,
               "auth_type": 0
           },
           "id": 1
       }

来源

ui/include/classes/api/services/CUser.php 中的 CUser::checkAuthentication()。