auth-tool-cloudbase
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOverview
概述
Configure CloudBase authentication providers: Anonymous, Username/Password, SMS, Email, WeChat, Google, and more.
Prerequisites: CloudBase environment ID ()
env配置CloudBase身份认证提供商:匿名、用户名/密码、短信、邮箱、微信、Google等。
前提条件:CloudBase环境ID()
envAuthentication Scenarios
认证场景
1. Get Login Strategy
1. 获取登录策略
Query current login configuration:
js
{
"params": { "EnvId": `env` },
"service": "lowcode",
"action": "DescribeLoginStrategy"
}Returns object or if not configured.
LoginStrategyfalse查询当前登录配置:
js
{
"params": { "EnvId": `env` },
"service": "lowcode",
"action": "DescribeLoginStrategy"
}返回对象,若未配置则返回。
LoginStrategyfalse2. Anonymous Login
2. 匿名登录
- Get (see Scenario 1)
LoginStrategy - Set (on) or
LoginStrategy.AnonymousLogin = true(off)false - Update:
js
{
"params": { "EnvId": `env`, ...LoginStrategy },
"service": "lowcode",
"action": "ModifyLoginStrategy"
}- 获取(参见场景1)
LoginStrategy - 设置(开启)或
LoginStrategy.AnonymousLogin = true(关闭)false - 更新配置:
js
{
"params": { "EnvId": `env`, ...LoginStrategy },
"service": "lowcode",
"action": "ModifyLoginStrategy"
}3. Username/Password Login
3. 用户名/密码登录
- Get (see Scenario 1)
LoginStrategy - Set (on) or
LoginStrategy.UserNameLogin = true(off)false - Update:
js
{
"params": { "EnvId": `env`, ...LoginStrategy },
"service": "lowcode",
"action": "ModifyLoginStrategy"
}- 获取(参见场景1)
LoginStrategy - 设置(开启)或
LoginStrategy.UserNameLogin = true(关闭)false - 更新配置:
js
{
"params": { "EnvId": `env`, ...LoginStrategy },
"service": "lowcode",
"action": "ModifyLoginStrategy"
}4. SMS Login
4. 短信登录
- Get (see Scenario 1)
LoginStrategy - Modify:
- Turn on:
LoginStrategy.PhoneNumberLogin = true - Turn off:
LoginStrategy.PhoneNumberLogin = false - Config (optional):
js
LoginStrategy.SmsVerificationConfig = { Type: 'default', // 'default' or 'apis' Method: 'methodName', SmsDayLimit: 30 // -1 = unlimited }
- Turn on:
- Update:
js
{
"params": { "EnvId": `env`, ...LoginStrategy },
"service": "lowcode",
"action": "ModifyLoginStrategy"
}- 获取(参见场景1)
LoginStrategy - 修改配置:
- 开启:
LoginStrategy.PhoneNumberLogin = true - 关闭:
LoginStrategy.PhoneNumberLogin = false - 配置(可选):
js
LoginStrategy.SmsVerificationConfig = { Type: 'default', // 'default'或'apis' Method: 'methodName', SmsDayLimit: 30 // -1 = 无限制 }
- 开启:
- 更新配置:
js
{
"params": { "EnvId": `env`, ...LoginStrategy },
"service": "lowcode",
"action": "ModifyLoginStrategy"
}5. Email Login
5. 邮箱登录
Turn on (Tencent Cloud email):
js
{
"params": {
"EnvId": `env`,
"Id": "email",
"On": "TRUE",
"EmailConfig": { "On": "TRUE", "SmtpConfig": {} }
},
"service": "tcb",
"action": "ModifyProvider"
}Turn off:
js
{
"params": { "EnvId": `env`, "Id": "email", "On": "FALSE" },
"service": "tcb",
"action": "ModifyProvider"
}Turn on (custom SMTP):
js
{
"params": {
"EnvId": `env`,
"Id": "email",
"On": "TRUE",
"EmailConfig": {
"On": "FALSE",
"SmtpConfig": {
"AccountPassword": "password",
"AccountUsername": "username",
"SecurityMode": "SSL",
"SenderAddress": "sender@example.com",
"ServerHost": "smtp.qq.com",
"ServerPort": 465
}
}
},
"service": "tcb",
"action": "ModifyProvider"
}开启(腾讯云邮箱):
js
{
"params": {
"EnvId": `env`,
"Id": "email",
"On": "TRUE",
"EmailConfig": { "On": "TRUE", "SmtpConfig": {} }
},
"service": "tcb",
"action": "ModifyProvider"
}关闭:
js
{
"params": { "EnvId": `env`, "Id": "email", "On": "FALSE" },
"service": "tcb",
"action": "ModifyProvider"
}开启(自定义SMTP):
js
{
"params": {
"EnvId": `env`,
"Id": "email",
"On": "TRUE",
"EmailConfig": {
"On": "FALSE",
"SmtpConfig": {
"AccountPassword": "password",
"AccountUsername": "username",
"SecurityMode": "SSL",
"SenderAddress": "sender@example.com",
"ServerHost": "smtp.qq.com",
"ServerPort": 465
}
}
},
"service": "tcb",
"action": "ModifyProvider"
}6. WeChat Login
6. 微信登录
- Get WeChat config:
js
{
"params": { "EnvId": `env` },
"service": "tcb",
"action": "GetProviders"
}Filter by , save as .
Id == "wx_open"WeChatProvider-
Get credentials from WeChat Open Platform:
AppIDAppSecret
-
Update:
js
{
"params": {
"EnvId": `env`,
"Id": "wx_open",
"On": "TRUE", // "FALSE" to disable
"Config": {
...WeChatProvider.Config,
ClientId: `AppID`,
ClientSecret: `AppSecret`
}
},
"service": "tcb",
"action": "ModifyProvider"
}- 获取微信配置:
js
{
"params": { "EnvId": `env` },
"service": "tcb",
"action": "GetProviders"
}筛选的配置,保存为。
Id == "wx_open"WeChatProvider-
从微信开放平台获取凭证:
AppIDAppSecret
-
更新配置:
js
{
"params": {
"EnvId": `env`,
"Id": "wx_open",
"On": "TRUE", // "FALSE"表示禁用
"Config": {
...WeChatProvider.Config,
ClientId: `AppID`,
ClientSecret: `AppSecret`
}
},
"service": "tcb",
"action": "ModifyProvider"
}7. Google Login
7. Google登录
- Get redirect URI:
js
{
"params": { "EnvId": `env` },
"service": "lowcode",
"action": "DescribeStaticDomain"
}Save as .
result.Data.StaticDomainstaticDomain-
Configure at Google Cloud Console:
- Create OAuth 2.0 Client ID
- Set redirect URI:
https://{staticDomain}/__auth/ - Get and
Client IDClient Secret
-
Enable:
js
{
"params": {
"EnvId": `env`,
"ProviderType": "OAUTH",
"Id": "google",
"On": "TRUE", // "FALSE" to disable
"Name": { "Message": "Google" },
"Description": { "Message": "" },
"Config": {
"ClientId": `Client ID`,
"ClientSecret": `Client Secret`,
"Scope": "email openid profile",
"AuthorizationEndpoint": "https://accounts.google.com/o/oauth2/v2/auth",
"TokenEndpoint": "https://oauth2.googleapis.com/token",
"UserinfoEndpoint": "https://www.googleapis.com/oauth2/v3/userinfo",
"TokenEndpointAuthMethod": "CLIENT_SECRET_BASIC",
"RequestParametersMap": {
"RegisterUserSyncScope": "syncEveryLogin",
"IsGoogle": "TRUE"
}
},
"Picture": "https://qcloudimg.tencent-cloud.cn/raw/f9131c00dcbcbccd5899a449d68da3ba.png",
"TransparentMode": "FALSE",
"ReuseUserId": "TRUE",
"AutoSignUpWithProviderUser": "TRUE"
},
"service": "tcb",
"action": "ModifyProvider"
}- 获取重定向URI:
js
{
"params": { "EnvId": `env` },
"service": "lowcode",
"action": "DescribeStaticDomain"
}保存为。
result.Data.StaticDomainstaticDomain-
在Google Cloud Console中配置:
- 创建OAuth 2.0客户端ID
- 设置重定向URI:
https://{staticDomain}/__auth/ - 获取和
Client IDClient Secret
-
启用配置:
js
{
"params": {
"EnvId": `env`,
"ProviderType": "OAUTH",
"Id": "google",
"On": "TRUE", // "FALSE"表示禁用
"Name": { "Message": "Google" },
"Description": { "Message": "" },
"Config": {
"ClientId": `Client ID`,
"ClientSecret": `Client Secret`,
"Scope": "email openid profile",
"AuthorizationEndpoint": "https://accounts.google.com/o/oauth2/v2/auth",
"TokenEndpoint": "https://oauth2.googleapis.com/token",
"UserinfoEndpoint": "https://www.googleapis.com/oauth2/v3/userinfo",
"TokenEndpointAuthMethod": "CLIENT_SECRET_BASIC",
"RequestParametersMap": {
"RegisterUserSyncScope": "syncEveryLogin",
"IsGoogle": "TRUE"
}
},
"Picture": "https://qcloudimg.tencent-cloud.cn/raw/f9131c00dcbcbccd5899a449d68da3ba.png",
"TransparentMode": "FALSE",
"ReuseUserId": "TRUE",
"AutoSignUpWithProviderUser": "TRUE"
},
"service": "tcb",
"action": "ModifyProvider"
}8. Get Publishable Key
8. 获取可发布密钥
Query existing key:
js
{
"params": { "EnvId": `env`, "KeyType": "publish_key", "PageNumber": 1, "PageSize": 10 },
"service": "lowcode",
"action": "DescribeApiKeyTokens"
}Return if exists (filter by ).
PublishableKey.ApiKeyName == "publish_key"Create new key (if not exists):
js
{
"params": { "EnvId": `env`, "KeyType": "publish_key", "KeyName": "publish_key" },
"service": "lowcode",
"action": "CreateApiKeyToken"
}If creation fails, direct user to: "https://tcb.cloud.tencent.com/dev?envId=`env`#/env/apikey"
查询现有密钥:
js
{
"params": { "EnvId": `env`, "KeyType": "publish_key", "PageNumber": 1, "PageSize": 10 },
"service": "lowcode",
"action": "DescribeApiKeyTokens"
}若存在则返回(通过筛选)。
PublishableKey.ApiKeyName == "publish_key"创建新密钥(若不存在):
js
{
"params": { "EnvId": `env`, "KeyType": "publish_key", "KeyName": "publish_key" },
"service": "lowcode",
"action": "CreateApiKeyToken"
}若创建失败,请引导用户访问:"https://tcb.cloud.tencent.com/dev?envId=`env`#/env/apikey"