From 0a12561764b23fb1b3b1be0b8b077a6db1dc2862 Mon Sep 17 00:00:00 2001 From: cipchk Date: Mon, 11 Mar 2024 17:46:00 +0800 Subject: [PATCH] feat(auth): ignore all local resource --- packages/auth/docs/getting-started.en-US.md | 2 +- packages/auth/docs/getting-started.zh-CN.md | 2 +- packages/auth/src/auth.config.ts | 3 ++- packages/util/config/auth/auth.type.ts | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/auth/docs/getting-started.en-US.md b/packages/auth/docs/getting-started.en-US.md index 7b9b64a26..e7abe0b84 100644 --- a/packages/auth/docs/getting-started.en-US.md +++ b/packages/auth/docs/getting-started.en-US.md @@ -64,7 +64,7 @@ providers: [ | `[token_send_template]` | `string` | `${token}` | Send a token template with a `${property name}` placeholder | ✅ | | `[token_send_place]` | `header,body,url` | `header` | Send token parameter position | ✅ | | `[login_url]` | `string` | `/login` | Login page routing address | ✅ | -| `[ignores]` | `RegExp[]` | `[ /\/login/, /assets\// ]` | Ignore the list of URL addresses. In addition, you can also control whether to ignore through [ALLOW_ANONYMOUS](/auth/qa/en). | ✅ | +| `[ignores]` | `RegExp[]` | `[/\/assets\//]` | Ignore the list of URL addresses. In addition, you can also control whether to ignore through [ALLOW_ANONYMOUS](/auth/qa/en). | ✅ | | `[refreshTime]` | `number` | `3000` | Refresh time (unit: ms) | ✅ | | `[refreshOffset]` | `number` | `6000` | Offset value (unit: ms), it is recommended to set according to the multiple of `refreshTime` | ✅ | diff --git a/packages/auth/docs/getting-started.zh-CN.md b/packages/auth/docs/getting-started.zh-CN.md index a46d4807b..112fd24ed 100644 --- a/packages/auth/docs/getting-started.zh-CN.md +++ b/packages/auth/docs/getting-started.zh-CN.md @@ -64,7 +64,7 @@ providers: [ | `[token_send_template]` | `string` | `${token}` | 发送token模板,以 `${属性名}` 表示占位符,属性名要确保存在否则以空字符代替 | ✅ | | `[token_send_place]` | `header,body,url` | `header` | 发送token参数位置 | ✅ | | `[login_url]` | `string` | `/login` | 登录页路由地址 | ✅ | -| `[ignores]` | `RegExp[]` | `[ /\/login/, /assets\// ]` | 忽略 URL 地址清单,除此之外还可以通过 [ALLOW_ANONYMOUS](/auth/qa/zh) 进行控制是否忽略。 | ✅ | +| `[ignores]` | `RegExp[]` | `[/\/assets\//]` | 忽略 URL 地址清单,除此之外还可以通过 [ALLOW_ANONYMOUS](/auth/qa/zh) 进行控制是否忽略。 | ✅ | | `[refreshTime]` | `number` | `3000` | 刷新时长(单位:ms) | ✅ | | `[refreshOffset]` | `number` | `6000` | 偏移值(单位:ms),建议根据 `refreshTime` 倍数来设置 | ✅ | diff --git a/packages/auth/src/auth.config.ts b/packages/auth/src/auth.config.ts index ca558d952..cbe805f2b 100644 --- a/packages/auth/src/auth.config.ts +++ b/packages/auth/src/auth.config.ts @@ -9,7 +9,8 @@ export const AUTH_DEFAULT_CONFIG: AlainAuthConfig = { token_send_place: 'header', login_url: '/login', refreshTime: 3000, - refreshOffset: 6000 + refreshOffset: 6000, + ignores: [/\/assets\//] }; export function mergeConfig(srv: AlainConfigService): AlainAuthConfig { diff --git a/packages/util/config/auth/auth.type.ts b/packages/util/config/auth/auth.type.ts index 0b1884a20..528542f09 100644 --- a/packages/util/config/auth/auth.type.ts +++ b/packages/util/config/auth/auth.type.ts @@ -32,7 +32,7 @@ export interface AlainAuthConfig { */ login_url?: string; /** - * 忽略TOKEN的URL地址列表,默认值为:`[/\/login/, /assets\//, /passport\//]` + * 忽略TOKEN的URL地址列表,默认值为:`[/\/assets\//]` */ ignores?: RegExp[]; /**