跳到主要内容

登录鉴权插件

Tencent CloudBase Framework MP Plugin

Tencent CloudBase Framework Auth Plugin

Github License Npm version issue PRs Welcome star

云开发 CloudBase Framework 框架「登录配置」插件: 通过云开发 CloudBase Framework 框架一键设置环境下的登录配置。

功能特性

  • 支持未登录、匿名登录登录设置
  • 后续会支持开放平台、公众号、账号密码等其他登录方式配置

使用方法

步骤一. 准备工作

具体步骤请参照 准备云开发环境和 CloudBase CLI 命令工具

步骤二. 编写 cloudbaserc.json 配置

framework.plugins 中新增登录插件配置

{
"envId": "YOU_ENV_ID",
"framework": {
"plugins": {
"auth": {
"use": "@cloudbase/framework-plugin-auth",
"inputs": {
"configs": [
{
"platform": "NONLOGIN",
"status": "ENABLE"
}
]
}
}
}
}
}

具体配置信息请参考下面的配置文档

步骤三. 一键部署

cloudbase framework deploy

配置

默认情况下仅需要配置 appidprivateKeyPath 即可使用,以下配置参数针对有特殊需求的场景

配置示例

云开发的配置文件 cloudbaserc.json,可在配置文件的 plugins 里修改和写入插件配置

{
"envId": "YOU_ENV_ID",
"framework": {
"plugins": {
"client": {
"use": "@cloudbase/framework-plugin-auth",
"inputs": {
"configs": [
{
"platform": "NONLOGIN",
"status": "ENABLE"
}
]
}
}
}
}
}

配置参数说明

configs

必填,类型为数组格式 Array.<Login 对象>

Login 对象

属性名称类型长度是否必填描述
platformString1-32平台名称,可枚举值:<br>WECHAT-OPEN:微信开放平台;<br>WECHAT-PUBLIC:微信公众平台;<br>QQ-MINI:QQ 小程序;<br>CUSTOM:自定义登录;<br>ANONYMOUS:匿名登录;<br>EMAIL:邮箱登录;<br>NONLOGIN:未登录<br>目前仅支持 ANONYMOUS 和 NONLOGIN
statusString1-32默认开启,可枚举值:ENABLE;DISABLE。
platformIdString1-64第三方平台的 AppID
platformSecretString1-64第三方平台的 AppSecret

更多插件

请访问 CloudBase Framework 插件列表 搭配使用其他插件

文档资料