feat(auth): aggregate OAuth 支持环境变量回退配置,默认 LOGIN_TYPE=wx
构建并部署 BYW VoiceHub / Preflight 语法与构建检查 (push) Successful in 2m11s
构建并部署 BYW VoiceHub / 部署到生产服务器 (push) Canceled after 0s
构建并部署 BYW VoiceHub / 构建并推送容器镜像 (push) Canceled after 7m12s

- oauth-strategies.ts: loadAggregateSettings() DB 未配置时回退读取 process.env.AGGREGATE_OAUTH_*,自动启用
- .env.example: AGGREGATE_OAUTH_LOGIN_TYPE 默认改为 wx,补充 auxx.cn 示例注释
This commit is contained in:
2026-09-12 22:57:43 +08:00
parent 467dd38d5f
commit 7b605351f4
2 changed files with 31 additions and 4 deletions
+4 -3
View File
@@ -106,10 +106,11 @@ CASDOOR_ENDPOINT=
GOOGLE_CLIENT_ID= GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET= GOOGLE_CLIENT_SECRET=
# 聚合登陆 OAuth # 聚合登陆 OAuth(如 auxx.cn 等聚合登录服务,支持微信/QQ 等通道
AGGREGATE_OAUTH_APP_ID= AGGREGATE_OAUTH_APP_ID=
AGGREGATE_OAUTH_APP_KEY= AGGREGATE_OAUTH_APP_KEY=
# 支持单值、逗号分隔或 JSON 数组,例如:qq,wx,sina,baidu # 支持单值、逗号分隔或 JSON 数组,例如:qq,wx,sina,baidu
# 可用值:qq,wx,alipay,sina,baidu,douyin,huawei,xiaomi,gitee,gitea,bilibili,kuaishou # 可用值:qq,wx,alipay,sina,baidu,douyin,huawei,xiaomi,gitee,gitea,bilibili,kuaishou
AGGREGATE_OAUTH_LOGIN_TYPE=qq AGGREGATE_OAUTH_LOGIN_TYPE=wx
AGGREGATE_OAUTH_ENDPOINT=https://example.com/connect.php # 聚合登录服务基地址(https,不带 /oauth/... 路径),例如:https://www.auxx.cn
AGGREGATE_OAUTH_ENDPOINT=
+27 -1
View File
@@ -270,7 +270,33 @@ async function loadAggregateSettings() {
.from(systemSettings) .from(systemSettings)
.orderBy(asc(systemSettings.id)) .orderBy(asc(systemSettings.id))
.limit(1) .limit(1)
return row[0] ?? null const base = row[0] ?? null
const envAppId = process.env.AGGREGATE_OAUTH_APP_ID
const envAppKey = process.env.AGGREGATE_OAUTH_APP_KEY
const envLoginType = process.env.AGGREGATE_OAUTH_LOGIN_TYPE
const envEndpoint = process.env.AGGREGATE_OAUTH_ENDPOINT
const hasEnvConfig = !!(envAppId && envAppKey && envEndpoint)
const dbEnabled = base?.aggregateOAuthEnabled
const dbHasConfig = !!(
base?.aggregateOAuthAppId &&
base?.aggregateOAuthAppKey &&
base?.aggregateOAuthEndpoint
)
const enabled = Boolean(dbEnabled ?? hasEnvConfig)
const appId = (base?.aggregateOAuthAppId || envAppId || '') as string
const appKey = (base?.aggregateOAuthAppKey || envAppKey || '') as string
const loginType = ((base?.aggregateOAuthLoginType as string) || envLoginType || '') as string
const endpoint = ((base?.aggregateOAuthEndpoint as string) || envEndpoint || '') as string
return {
aggregateOAuthEnabled: enabled && !!(appId && appKey && endpoint),
aggregateOAuthAppId: appId,
aggregateOAuthAppKey: appKey,
aggregateOAuthLoginType: loginType,
aggregateOAuthEndpoint: endpoint,
_dbHasConfig: dbHasConfig,
_hasEnvConfig: hasEnvConfig
} as any
} }
function normalizeEndpoint(endpoint: string): string { function normalizeEndpoint(endpoint: string): string {