Commit 7f4329d9 by Finley Ge Committed by GitHub

feat(login): add WeCom auto redirect switch (#7264)

* feat(login): add WeCom auto redirect toggle

* docs(release): update WeCom redirect changelog

* docs(release): move WeCom redirect note to v4.15.1
parent 75b1e63d
...@@ -217,6 +217,7 @@ These variables are mainly read by `projects/app`. Some are currently defined in ...@@ -217,6 +217,7 @@ These variables are mainly read by `projects/app`. Some are currently defined in
| `SHOW_COUPON` | `false` | Whether redemption codes are shown. | | `SHOW_COUPON` | `false` | Whether redemption codes are shown. |
| `SHOW_DISCOUNT_COUPON` | `false` | Whether discount coupons are shown. | | `SHOW_DISCOUNT_COUPON` | `false` | Whether discount coupons are shown. |
| `HIDE_CHAT_COPYRIGHT_SETTING` | `false` | Whether copyright settings are hidden. | | `HIDE_CHAT_COPYRIGHT_SETTING` | `false` | Whether copyright settings are hidden. |
| `WECOM_LOGIN_AUTO_REDIRECT` | `false` | Whether WeCom terminals automatically redirect to login. |
| `APP_REGISTRATION_URL` | Empty | App registration application URL. Currently kept mostly for compatibility. | | `APP_REGISTRATION_URL` | Empty | App registration application URL. Currently kept mostly for compatibility. |
| `PASSWORD_EXPIRED_MONTH` | Empty | Password expiration period in months. Empty means passwords do not expire. | | `PASSWORD_EXPIRED_MONTH` | Empty | Password expiration period in months. Empty means passwords do not expire. |
| `OPENAPI_KEY_MAX_COUNT` | `100` | Maximum number of system API Keys one team member can create. Minimum is 1. | | `OPENAPI_KEY_MAX_COUNT` | `100` | Maximum number of system API Keys one team member can create. Minimum is 1. |
......
...@@ -217,6 +217,7 @@ description: projects/app、projects/code-sandbox 与 pro/admin 环境变量说 ...@@ -217,6 +217,7 @@ description: projects/app、projects/code-sandbox 与 pro/admin 环境变量说
| `SHOW_COUPON` | `false` | 是否展示兑换码功能。 | | `SHOW_COUPON` | `false` | 是否展示兑换码功能。 |
| `SHOW_DISCOUNT_COUPON` | `false` | 是否展示优惠券功能。 | | `SHOW_DISCOUNT_COUPON` | `false` | 是否展示优惠券功能。 |
| `HIDE_CHAT_COPYRIGHT_SETTING` | `false` | 是否隐藏版权信息配置项。 | | `HIDE_CHAT_COPYRIGHT_SETTING` | `false` | 是否隐藏版权信息配置项。 |
| `WECOM_LOGIN_AUTO_REDIRECT` | `false` | 是否允许企微终端自动跳转登录。 |
| `APP_REGISTRATION_URL` | 空 | 应用备案申请地址;当前主要作为兼容配置保留。 | | `APP_REGISTRATION_URL` | 空 | 应用备案申请地址;当前主要作为兼容配置保留。 |
| `PASSWORD_EXPIRED_MONTH` | 空 | 密码过期月份数;为空表示不过期。 | | `PASSWORD_EXPIRED_MONTH` | 空 | 密码过期月份数;为空表示不过期。 |
| `OPENAPI_KEY_MAX_COUNT` | `100` | 单个团队成员最多可创建的系统 API Key 数量,最小值为 1。 | | `OPENAPI_KEY_MAX_COUNT` | `100` | 单个团队成员最多可创建的系统 API Key 数量,最小值为 1。 |
......
...@@ -45,6 +45,7 @@ The script only fills missing `appName` values. It does not overwrite existing v ...@@ -45,6 +45,7 @@ The script only fills missing `appName` values. It does not overwrite existing v
1. Added global API Key tag management and an `appName` display snapshot for historical app-level API Keys, making older API keys compatible and easier to find when they were previously associated with apps. 1. Added global API Key tag management and an `appName` display snapshot for historical app-level API Keys, making older API keys compatible and easier to find when they were previously associated with apps.
2. Pre-extract the skill name and description when publishing a skill to help with generation. 2. Pre-extract the skill name and description when publishing a skill to help with generation.
3. Added the `WECOM_LOGIN_AUTO_REDIRECT` environment variable to control whether WeCom terminals automatically redirect to login. It is disabled by default.
## ⚙️ Improvements ## ⚙️ Improvements
......
...@@ -47,6 +47,7 @@ curl -X POST "{{host}}/api/admin/initv4151" \ ...@@ -47,6 +47,7 @@ curl -X POST "{{host}}/api/admin/initv4151" \
1. 增加全局 API Key 标签管理,并为历史应用级 API Key 增加 `appName` 展示快照,便于兼容旧版 API 密钥并查找以前应用关联的密钥。 1. 增加全局 API Key 标签管理,并为历史应用级 API Key 增加 `appName` 展示快照,便于兼容旧版 API 密钥并查找以前应用关联的密钥。
2. 发布技能时,预提取技能名称和描述,便于辅助生成。 2. 发布技能时,预提取技能名称和描述,便于辅助生成。
3. 新增 `WECOM_LOGIN_AUTO_REDIRECT` 环境变量,可控制企微终端是否自动跳转登录,默认关闭。
## ⚙️ 优化 ## ⚙️ 优化
......
...@@ -67,6 +67,7 @@ export type FastGPTFeConfigsType = { ...@@ -67,6 +67,7 @@ export type FastGPTFeConfigsType = {
show_discount_coupon?: boolean; show_discount_coupon?: boolean;
show_enterprise_auth?: boolean; show_enterprise_auth?: boolean;
showWecomConfig?: boolean; showWecomConfig?: boolean;
wecomLoginAutoRedirect?: boolean;
show_dataset_feishu?: boolean; show_dataset_feishu?: boolean;
show_dataset_yuque?: boolean; show_dataset_yuque?: boolean;
......
...@@ -181,6 +181,8 @@ SHOW_DISCOUNT_COUPON=false ...@@ -181,6 +181,8 @@ SHOW_DISCOUNT_COUPON=false
APP_REGISTRATION_URL= APP_REGISTRATION_URL=
# 是否隐藏版权信息配置,只有值为 true 时隐藏 # 是否隐藏版权信息配置,只有值为 true 时隐藏
HIDE_CHAT_COPYRIGHT_SETTING= HIDE_CHAT_COPYRIGHT_SETTING=
# 是否允许企微终端自动跳转登录,默认 false
WECOM_LOGIN_AUTO_REDIRECT=false
# 单个团队成员最多可创建的系统 API Key 数量,最小值为 1 # 单个团队成员最多可创建的系统 API Key 数量,最小值为 1
OPENAPI_KEY_MAX_COUNT=100 OPENAPI_KEY_MAX_COUNT=100
......
...@@ -16,6 +16,7 @@ export const appEnv = createEnv({ ...@@ -16,6 +16,7 @@ export const appEnv = createEnv({
SHOW_COUPON: BoolSchema.default(false), SHOW_COUPON: BoolSchema.default(false),
SHOW_DISCOUNT_COUPON: BoolSchema.default(false), SHOW_DISCOUNT_COUPON: BoolSchema.default(false),
HIDE_CHAT_COPYRIGHT_SETTING: BoolSchema.default(false), HIDE_CHAT_COPYRIGHT_SETTING: BoolSchema.default(false),
WECOM_LOGIN_AUTO_REDIRECT: BoolSchema.default(false),
AGENT_SANDBOX_FREE_TIP: BoolSchema.default(false), AGENT_SANDBOX_FREE_TIP: BoolSchema.default(false),
OPENAPI_KEY_MAX_COUNT: IntSchema.min(1).default(100), OPENAPI_KEY_MAX_COUNT: IntSchema.min(1).default(100),
......
...@@ -47,6 +47,8 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => { ...@@ -47,6 +47,8 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
const redirectUri = `${location.origin}/login/provider`; const redirectUri = `${location.origin}/login/provider`;
const isWecomWorkTerminal = checkIsWecomTerminal(); const isWecomWorkTerminal = checkIsWecomTerminal();
const canWecomTerminalAutoRedirect =
!isWecomWorkTerminal || feConfigs?.wecomLoginAutoRedirect === true;
const oAuthList: OAuthItem[] = useMemo( const oAuthList: OAuthItem[] = useMemo(
() => [ () => [
...@@ -181,14 +183,17 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => { ...@@ -181,14 +183,17 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
if (rootLogin) return; if (rootLogin) return;
const sso = oAuthList.find((item) => item.provider === OAuthEnum.sso); const sso = oAuthList.find((item) => item.provider === OAuthEnum.sso);
// sso auto login // sso auto login
if (sso && (feConfigs?.sso?.autoLogin || isWecomWorkTerminal)) onClickOauth(sso); if (sso && canWecomTerminalAutoRedirect && (feConfigs?.sso?.autoLogin || isWecomWorkTerminal)) {
if (feConfigs.oauth?.wecom && isWecomWorkTerminal) { onClickOauth(sso);
}
if (feConfigs.oauth?.wecom && isWecomWorkTerminal && canWecomTerminalAutoRedirect) {
onClickOauth({ onClickOauth({
provider: OAuthEnum.wecom provider: OAuthEnum.wecom
} as any); } as any);
} }
}, [ }, [
rootLogin, rootLogin,
canWecomTerminalAutoRedirect,
feConfigs?.sso?.autoLogin, feConfigs?.sso?.autoLogin,
isWecomWorkTerminal, isWecomWorkTerminal,
onClickOauth, onClickOauth,
......
...@@ -154,6 +154,7 @@ export async function initSystemConfig() { ...@@ -154,6 +154,7 @@ export async function initSystemConfig() {
}, },
isPlus: !!licenseData, isPlus: !!licenseData,
hideChatCopyrightSetting: appEnv.HIDE_CHAT_COPYRIGHT_SETTING, hideChatCopyrightSetting: appEnv.HIDE_CHAT_COPYRIGHT_SETTING,
wecomLoginAutoRedirect: appEnv.WECOM_LOGIN_AUTO_REDIRECT,
show_aiproxy: hasAIProxyApiEndpoint(), show_aiproxy: hasAIProxyApiEndpoint(),
show_coupon: appEnv.SHOW_COUPON, show_coupon: appEnv.SHOW_COUPON,
show_discount_coupon: appEnv.SHOW_DISCOUNT_COUPON, show_discount_coupon: appEnv.SHOW_DISCOUNT_COUPON,
......
...@@ -29,6 +29,24 @@ describe('app env validation', () => { ...@@ -29,6 +29,24 @@ describe('app env validation', () => {
}); });
}); });
it('WECOM_LOGIN_AUTO_REDIRECT 默认关闭,且支持显式开启', async () => {
vi.stubEnv('WECOM_LOGIN_AUTO_REDIRECT', '');
await expect(importAppEnv()).resolves.toMatchObject({
appEnv: expect.objectContaining({
WECOM_LOGIN_AUTO_REDIRECT: false
})
});
vi.stubEnv('WECOM_LOGIN_AUTO_REDIRECT', 'true');
await expect(importAppEnv()).resolves.toMatchObject({
appEnv: expect.objectContaining({
WECOM_LOGIN_AUTO_REDIRECT: true
})
});
});
it('OPENAPI_KEY_MAX_COUNT 必须是大于等于 1 的整数', async () => { it('OPENAPI_KEY_MAX_COUNT 必须是大于等于 1 的整数', async () => {
vi.stubEnv('OPENAPI_KEY_MAX_COUNT', '0'); vi.stubEnv('OPENAPI_KEY_MAX_COUNT', '0');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment