Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(oauth-app): raise redirect URI cap from 5 to 20 (#22132)

Arvin Xu433a0a860157
diff --git a/locales/en-US/auth.json b/locales/en-US/auth.json
index d3b1b0f29c0..fa80d3ce559 100644
--- a/locales/en-US/auth.json
+++ b/locales/en-US/auth.json
@@ -300,6 +300,7 @@
"oauthApp.list.neverUsed": "Never used",
"oauthApp.redirectUris.add": "Add redirect URI",
"oauthApp.redirectUris.empty": "No redirect URIs yet. Add one so users can sign in with this app.",
+ "oauthApp.redirectUris.limitReached": "Reached the limit of {{count}} redirect URIs",
"oauthApp.redirectUris.remove": "Remove",
"oauthApp.redirectUris.title": "Redirect URIs",
"oauthApp.secret.copy": "Copy secret",
diff --git a/locales/zh-CN/auth.json b/locales/zh-CN/auth.json
index fd919596ed4..82d92edb3c2 100644
--- a/locales/zh-CN/auth.json
+++ b/locales/zh-CN/auth.json
@@ -300,6 +300,7 @@
"oauthApp.list.neverUsed": "从未使用",
"oauthApp.redirectUris.add": "添加回调地址",
"oauthApp.redirectUris.empty": "还没有回调地址。添加一个后,用户才能通过此应用登录。",
+ "oauthApp.redirectUris.limitReached": "已达到上限,最多 {{count}} 个回调地址",
"oauthApp.redirectUris.remove": "移除",
"oauthApp.redirectUris.title": "回调地址",
"oauthApp.secret.copy": "复制密钥",
diff --git a/packages/locales/src/default/auth.ts b/packages/locales/src/default/auth.ts
index 467ca04adb3..e9c225475c0 100644
--- a/packages/locales/src/default/auth.ts
+++ b/packages/locales/src/default/auth.ts
@@ -334,6 +334,7 @@ export default {
'oauthApp.redirectUris.add': 'Add redirect URI',
'oauthApp.redirectUris.empty':
'No redirect URIs yet. Add one so users can sign in with this app.',
+ 'oauthApp.redirectUris.limitReached': 'Reached the limit of {{count}} redirect URIs',
'oauthApp.redirectUris.remove': 'Remove',
'oauthApp.redirectUris.title': 'Redirect URIs',
'oauthApp.secret.copy': 'Copy secret',
diff --git a/packages/utils/src/oauthApp.ts b/packages/utils/src/oauthApp.ts
index 04318b17adb..751302bfa91 100644
--- a/packages/utils/src/oauthApp.ts
+++ b/packages/utils/src/oauthApp.ts
@@ -8,8 +8,12 @@
* client-side pass.
*/
-/** Web apps redirect back to a handful of environments at most (prod + staging + local). */
-export const MAX_OAUTH_REDIRECT_URIS = 5;
+/**
+ * Matching is exact and wildcards are refused, so one app shared by several
+ * deployments (prod, staging, regional or white-label hosts, local) needs one
+ * entry per host. The cap only bounds the row size.
+ */
+export const MAX_OAUTH_REDIRECT_URIS = 20;
export type RedirectUriIssue =
/** Not parseable as an absolute URL. */
diff --git a/src/features/Settings/oauth-apps/features/AppDetail/RedirectUrisCard.tsx b/src/features/Settings/oauth-apps/features/AppDetail/RedirectUrisCard.tsx
index 2d7a8c192c7..d36a13f3eee 100644
--- a/src/features/Settings/oauth-apps/features/AppDetail/RedirectUrisCard.tsx
+++ b/src/features/Settings/oauth-apps/features/AppDetail/RedirectUrisCard.tsx
@@ -164,6 +164,11 @@ const RedirectUrisCard: FC<RedirectUrisCardProps> = ({ canEdit, detail, onSubmit
>
{t('oauthApp.redirectUris.add')}
</Button>
+ {fields.length >= MAX_OAUTH_REDIRECT_URIS && (
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {t('oauthApp.redirectUris.limitReached', { count: MAX_OAUTH_REDIRECT_URIS })}
+ </Text>
+ )}
</Flexbox>
)}
</Form.List>
diff --git a/src/features/Settings/oauth-apps/redirectUris.test.ts b/src/features/Settings/oauth-apps/redirectUris.test.ts
index 4547522f3b9..d9889093559 100644
--- a/src/features/Settings/oauth-apps/redirectUris.test.ts
+++ b/src/features/Settings/oauth-apps/redirectUris.test.ts
@@ -1,6 +1,10 @@
import { describe, expect, it } from 'vitest';
-import { redirectUriListMessageKey, redirectUriMessageKey } from './redirectUris';
+import {
+ MAX_OAUTH_REDIRECT_URIS,
+ redirectUriListMessageKey,
+ redirectUriMessageKey,
+} from './redirectUris';
describe('redirectUriMessageKey', () => {
it('accepts a valid URI and a blank row', () => {
@@ -28,7 +32,10 @@ describe('redirectUriListMessageKey', () => {
});
it('refuses more URIs than the cap', () => {
- const uris = Array.from({ length: 6 }, (_, i) => `https://a${i}.com/cb`);
+ const uris = Array.from(
+ { length: MAX_OAUTH_REDIRECT_URIS + 1 },
+ (_, i) => `https://a${i}.com/cb`,
+ );
expect(redirectUriListMessageKey(uris)).toBe('oauthApp.validation.redirectUriTooMany');
});