跳至主要內容

auth

Andy HsuGuideAPIGuide大约 5 分钟

auth

POST token获取

POST /api/auth/login

获取某个用户的临时JWt token, 有效期默认48小时

Body 请求参数

{
  "username": "{{alist_username}}",
  "password": "{{alist_password}}"
}

请求参数

名称位置类型必选中文名说明
bodybodyobjectnone
» usernamebodystring用户名用户名
» passwordbodystring密码密码
» otp_codebodystring二步验证码二步验证码

返回示例

成功

{
  "code": 200,
  "message": "success",
  "data": {
    "token": "abcd"
  }
}

返回结果

状态码状态码含义说明数据模型
200OKopen in new window成功Inline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» codeintegertruenone状态码
» messagestringtruenone信息
» dataobjecttruenonedata
»» tokenstringtruenonetoken

POST token获取hash

POST /api/auth/login/hash

获取某个用户的临时JWt token,传入的密码需要在添加-https://github.com/alist-org/alist后缀后再进行sha256

Body 请求参数

{
  "username": "{{alist_username}}",
  "password": "{{alist_password}}"
}

请求参数

名称位置类型必选中文名说明
bodybodyobjectnone
» usernamebodystring用户名用户名
» passwordbodystring密码hash后密码,获取方式为sha256(密码-https://github.com/alist-org/alist)
» otp_codebodystring二步验证码二步验证码

返回示例

成功

{
  "code": 200,
  "message": "success",
  "data": {
    "token": "abcd"
  }
}

返回结果

状态码状态码含义说明数据模型
200OKopen in new window成功Inline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» codeintegertruenone状态码
» messagestringtruenone信息
» dataobjecttruenonedata
»» tokenstringtruenonetoken

POST 生成2FA密钥

POST /api/auth/2fa/generate

请求参数

名称位置类型必选中文名说明
Authorizationheaderstringnone

返回示例

成功

{
  "code": 200,
  "message": "success",
  "data": {
    "qr": "data:image/png;base64,iVBORw0KGgoAAAANSUhE",
    "secret": "RPQZG4MDS3"
  }
}

返回结果

状态码状态码含义说明数据模型
200OKopen in new window成功Inline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» codeintegertruenone状态码none
» messagestringtruenone信息none
» dataobjecttruenone数据none
»» qrstringtruenone二维码二维码图片的data url
»» secretstringtruenone密钥none

POST 验证2FA code

POST /api/auth/2fa/verify

Body 请求参数

{
  "code": "string",
  "secret": "string"
}

请求参数

名称位置类型必选中文名说明
Authorizationheaderstringnone
bodybodyobjectnone
» codebodystring2FA验证码none
» secretbodystring2FA密钥none

返回示例

成功

{
  "code": 200,
  "message": "success",
  "data": null
}

返回结果

状态码状态码含义说明数据模型
200OKopen in new window成功Inline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» codeintegertruenone状态码none
» messagestringtruenone信息none
» datanulltruenonenone

GET 获取当前用户信息

GET /api/me

请求参数

名称位置类型必选中文名说明
Authorizationheaderstringnone

返回示例

成功

{
  "code": 200,
  "message": "success",
  "data": {
    "id": 1,
    "username": "admin",
    "password": "",
    "base_path": "/",
    "role": 2,
    "disabled": false,
    "permission": 0,
    "sso_id": "",
    "otp": true
  }
}

返回结果

状态码状态码含义说明数据模型
200OKopen in new window成功Inline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» codeintegertruenone状态码none
» messagestringtruenone信息none
» dataobjecttruenone数据none
»» idintegertruenoneidnone
»» usernamestringtruenone用户名none
»» passwordstringtruenone密码none
»» base_pathstringtruenone根目录none
»» roleintegertruenone角色none
»» disabledbooleantruenone是否禁用none
»» permissionintegertruenone权限none
»» sso_idstringtruenonesso idnone
»» otpbooleantruenone是否开启二步验证none

GET 列出当前用户 SFTP 公钥

GET /api/me/sshkey/list

请求参数

名称位置类型必选中文名说明
Authorizationheaderstringnone

返回示例

成功

{
  "code": 200,
  "message": "success",
  "data": {
    "content": [
      {
        "id": 1,
        "title": "Test-SSH-Key",
        "fingerprint": "SHA256:aAFI5C******************************KD6hYhs",
        "added_time": "2024-12-15T20:09:28.1777368+08:00",
        "last_used_time": "2024-12-15T20:10:07.7846528+08:00"
      },
      {
        "id": 2,
        "title": "Test-SSH-Key-2",
        "fingerprint": "SHA256:P2zrSs******************************h0Q5BOQ",
        "added_time": "2024-12-20T20:09:28.1777368+08:00",
        "last_used_time": "2024-12-25T20:10:07.7846528+08:00"
      },
    ],
    "total": 2
  }
}

返回结果

状态码状态码含义说明数据模型
200OKopen in new window成功Inline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» codeintegertruenone状态码none
» messagestringtruenone信息none
» dataobjecttruenone数据none
»» content[object]truenonenone
»»» idintegertruenone公钥主键none
»»» titlestringtruenone公钥名称none
»»» fingerprintstringtruenone公钥指纹none
»»» added_timestringtruenone添加时间none
»»» last_used_timestringtruenone上次认证时间none
»» totalintegertruenone总数none

POST 给当前用户添加 SFTP 公钥

POST /api/me/sshkey/add

请求参数

名称位置类型必选中文名说明
Authorizationheaderstringnone
bodybodyobjectnone
» titlebodystring公钥名none
» keybodystring公钥内容none

返回示例

成功

{
  "code": 200,
  "message": "success",
  "data": null
}

返回结果

状态码状态码含义说明数据模型
200OKopen in new window成功Inline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» codeintegertruenone状态码none
» messagestringtruenone信息none
» datanulltruenonenone

POST 删除当前用户的 SFTP 公钥

POST /api/me/sshkey/delete

请求参数

名称位置类型必选中文名说明
Authorizationheaderstringnone
idqueryinteger公钥主键none

返回示例

成功

{
  "code": 200,
  "message": "success",
  "data": null
}

返回结果

状态码状态码含义说明数据模型
200OKopen in new window成功Inline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» codeintegertruenone状态码none
» messagestringtruenone信息none
» datanulltruenonenone