@liujitcn/kratos-admin-core 0.0.56 → 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/package/declarations/src/api/system/admin/v1/auth.d.ts +3 -1
- package/dist/package/declarations/src/components/PasswordStrength/index.vue.d.ts +7 -0
- package/dist/package/declarations/src/locales/generated.d.ts +24 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/auth.d.ts +16 -0
- package/dist/package/src/api/system/admin/v1/auth.ts +11 -0
- package/dist/package/src/components/PasswordStrength/index.vue +44 -3
- package/dist/package/src/locales/en-US.json +6 -0
- package/dist/package/src/locales/ja-JP.json +6 -0
- package/dist/package/src/locales/zh-CN.json +6 -0
- package/dist/package/src/locales/zh-TW.json +6 -0
- package/dist/package/src/rpc/system/admin/v1/auth.ts +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ packages/core
|
|
|
86
86
|
| `src/components/Grid/` | 响应式表单网格及类型。 |
|
|
87
87
|
| `src/components/ImportExcel/` | Excel 导入交互。 |
|
|
88
88
|
| `src/components/Loading/` | 局部和全屏加载状态。 |
|
|
89
|
-
| `src/components/PasswordStrength/` |
|
|
89
|
+
| `src/components/PasswordStrength/` | 密码强度与当前用户生效策略摘要。 |
|
|
90
90
|
| `src/components/ProForm/` | 配置驱动表单、动态列表、键值列表和类型。 |
|
|
91
91
|
| `src/components/ProTable/` | 配置驱动表格、分页、列设置和类型。 |
|
|
92
92
|
| `src/components/RichTextPreview/` | 经过清洗的富文本预览。 |
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { GetUserInfoRequest, ListUserButtonRequest, TreeRouteResponse, TreeUserMenuRequest, UserInfoForm } from "../../../../rpc/system/admin/v1/auth";
|
|
1
|
+
import type { CurrentPasswordPolicy, GetCurrentPasswordPolicyRequest, GetUserInfoRequest, ListUserButtonRequest, TreeRouteResponse, TreeUserMenuRequest, UserInfoForm } from "../../../../rpc/system/admin/v1/auth";
|
|
2
2
|
import type { StringValues } from "../../../../rpc/common/v1/types";
|
|
3
3
|
/** AuthServiceImpl 管理端运行壳认证服务。 */
|
|
4
4
|
export declare class AuthServiceImpl {
|
|
5
|
+
/** 获取当前用户生效的密码策略。 */
|
|
6
|
+
GetCurrentPasswordPolicy(request: GetCurrentPasswordPolicyRequest): Promise<CurrentPasswordPolicy>;
|
|
5
7
|
/** 获取当前登录用户。 */
|
|
6
8
|
GetUserInfo(request: GetUserInfoRequest): Promise<UserInfoForm>;
|
|
7
9
|
/** 获取当前用户菜单。 */
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import type { CurrentPasswordPolicy } from "../../rpc/system/admin/v1/auth";
|
|
1
2
|
/** 密码强度组件属性。 */
|
|
2
3
|
interface PasswordStrengthProps {
|
|
3
4
|
/** 当前密码值。 */
|
|
4
5
|
password?: string;
|
|
5
6
|
/** 底部提示文案。 */
|
|
6
7
|
tip?: string;
|
|
8
|
+
/** 已知的密码策略;传入后直接用于摘要展示。 */
|
|
9
|
+
policy?: CurrentPasswordPolicy;
|
|
10
|
+
/** 是否加载当前登录用户生效的密码策略。 */
|
|
11
|
+
loadCurrentPolicy?: boolean;
|
|
7
12
|
}
|
|
8
13
|
declare const __VLS_export: import("vue").DefineComponent<PasswordStrengthProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<PasswordStrengthProps> & Readonly<{}>, {
|
|
9
14
|
password: string;
|
|
10
15
|
tip: string;
|
|
16
|
+
policy: CurrentPasswordPolicy;
|
|
17
|
+
loadCurrentPolicy: boolean;
|
|
11
18
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
19
|
declare const _default: typeof __VLS_export;
|
|
13
20
|
export default _default;
|
|
@@ -253,6 +253,12 @@ export declare const LOCALE_MESSAGES: {
|
|
|
253
253
|
"core.password.strength.low": string;
|
|
254
254
|
"core.password.strength.medium": string;
|
|
255
255
|
"core.password.tip": string;
|
|
256
|
+
"core.password.policy.min_length": string;
|
|
257
|
+
"core.password.policy.complexity": string;
|
|
258
|
+
"core.password.policy.history": string;
|
|
259
|
+
"core.password.policy.max_age": string;
|
|
260
|
+
"core.password.policy.no_expiry": string;
|
|
261
|
+
"core.password.policy.separator": string;
|
|
256
262
|
"core.theme.accordion": string;
|
|
257
263
|
"core.theme.aside_inverted": string;
|
|
258
264
|
"core.theme.aside_inverted_tip": string;
|
|
@@ -622,6 +628,12 @@ export declare const LOCALE_MESSAGES: {
|
|
|
622
628
|
"core.password.strength.low": string;
|
|
623
629
|
"core.password.strength.medium": string;
|
|
624
630
|
"core.password.tip": string;
|
|
631
|
+
"core.password.policy.min_length": string;
|
|
632
|
+
"core.password.policy.complexity": string;
|
|
633
|
+
"core.password.policy.history": string;
|
|
634
|
+
"core.password.policy.max_age": string;
|
|
635
|
+
"core.password.policy.no_expiry": string;
|
|
636
|
+
"core.password.policy.separator": string;
|
|
625
637
|
"core.theme.accordion": string;
|
|
626
638
|
"core.theme.aside_inverted": string;
|
|
627
639
|
"core.theme.aside_inverted_tip": string;
|
|
@@ -991,6 +1003,12 @@ export declare const LOCALE_MESSAGES: {
|
|
|
991
1003
|
"core.password.strength.low": string;
|
|
992
1004
|
"core.password.strength.medium": string;
|
|
993
1005
|
"core.password.tip": string;
|
|
1006
|
+
"core.password.policy.min_length": string;
|
|
1007
|
+
"core.password.policy.complexity": string;
|
|
1008
|
+
"core.password.policy.history": string;
|
|
1009
|
+
"core.password.policy.max_age": string;
|
|
1010
|
+
"core.password.policy.no_expiry": string;
|
|
1011
|
+
"core.password.policy.separator": string;
|
|
994
1012
|
"core.theme.accordion": string;
|
|
995
1013
|
"core.theme.aside_inverted": string;
|
|
996
1014
|
"core.theme.aside_inverted_tip": string;
|
|
@@ -1360,6 +1378,12 @@ export declare const LOCALE_MESSAGES: {
|
|
|
1360
1378
|
"core.password.strength.low": string;
|
|
1361
1379
|
"core.password.strength.medium": string;
|
|
1362
1380
|
"core.password.tip": string;
|
|
1381
|
+
"core.password.policy.min_length": string;
|
|
1382
|
+
"core.password.policy.complexity": string;
|
|
1383
|
+
"core.password.policy.history": string;
|
|
1384
|
+
"core.password.policy.max_age": string;
|
|
1385
|
+
"core.password.policy.no_expiry": string;
|
|
1386
|
+
"core.password.policy.separator": string;
|
|
1363
1387
|
"core.theme.accordion": string;
|
|
1364
1388
|
"core.theme.aside_inverted": string;
|
|
1365
1389
|
"core.theme.aside_inverted_tip": string;
|
|
@@ -46,6 +46,20 @@ export interface UserInfoForm {
|
|
|
46
46
|
/** 获取个人中心用户信息请求参数 */
|
|
47
47
|
export interface GetUserProfileRequest {
|
|
48
48
|
}
|
|
49
|
+
/** 获取当前用户密码策略请求参数 */
|
|
50
|
+
export interface GetCurrentPasswordPolicyRequest {
|
|
51
|
+
}
|
|
52
|
+
/** 当前用户生效的密码策略 */
|
|
53
|
+
export interface CurrentPasswordPolicy {
|
|
54
|
+
/** 密码最小长度 */
|
|
55
|
+
min_length: number;
|
|
56
|
+
/** 密码至少满足的字符类别数量 */
|
|
57
|
+
min_complexity_classes: number;
|
|
58
|
+
/** 禁止重复使用的历史密码数量,零表示不启用 */
|
|
59
|
+
history_count: number;
|
|
60
|
+
/** 密码有效期天数,零表示长期有效 */
|
|
61
|
+
max_age_days: number;
|
|
62
|
+
}
|
|
49
63
|
/** 用户资料表单 */
|
|
50
64
|
export interface UserProfileForm {
|
|
51
65
|
/** 用户名 */
|
|
@@ -158,6 +172,8 @@ export interface AuthService {
|
|
|
158
172
|
GetUserInfo(request: GetUserInfoRequest): Promise<UserInfoForm>;
|
|
159
173
|
/** 获取个人中心用户信息 */
|
|
160
174
|
GetUserProfile(request: GetUserProfileRequest): Promise<UserProfileForm>;
|
|
175
|
+
/** 获取当前用户生效的密码策略 */
|
|
176
|
+
GetCurrentPasswordPolicy(request: GetCurrentPasswordPolicyRequest): Promise<CurrentPasswordPolicy>;
|
|
161
177
|
/** 修改个人中心密码 */
|
|
162
178
|
UpdateUserPassword(request: UpdateUserPasswordRequest): Promise<Empty>;
|
|
163
179
|
/** 修改个人中心手机号 */
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import service from "../../../../utils/request";
|
|
2
2
|
import type {
|
|
3
|
+
CurrentPasswordPolicy,
|
|
4
|
+
GetCurrentPasswordPolicyRequest,
|
|
3
5
|
GetUserInfoRequest,
|
|
4
6
|
ListUserButtonRequest,
|
|
5
7
|
TreeRouteResponse,
|
|
@@ -12,6 +14,15 @@ const AUTH_URL = "/v1/admin/auth";
|
|
|
12
14
|
|
|
13
15
|
/** AuthServiceImpl 管理端运行壳认证服务。 */
|
|
14
16
|
export class AuthServiceImpl {
|
|
17
|
+
/** 获取当前用户生效的密码策略。 */
|
|
18
|
+
GetCurrentPasswordPolicy(request: GetCurrentPasswordPolicyRequest): Promise<CurrentPasswordPolicy> {
|
|
19
|
+
return service<GetCurrentPasswordPolicyRequest, CurrentPasswordPolicy>({
|
|
20
|
+
url: `${AUTH_URL}/password-policy`,
|
|
21
|
+
method: "get",
|
|
22
|
+
params: request
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
15
26
|
/** 获取当前登录用户。 */
|
|
16
27
|
GetUserInfo(request: GetUserInfoRequest): Promise<UserInfoForm> {
|
|
17
28
|
return service<GetUserInfoRequest, UserInfoForm>({
|
|
@@ -17,12 +17,14 @@
|
|
|
17
17
|
}"
|
|
18
18
|
/>
|
|
19
19
|
</div>
|
|
20
|
-
<p class="password-strength__tip">{{
|
|
20
|
+
<p class="password-strength__tip">{{ displayedTip }}</p>
|
|
21
21
|
</div>
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
24
|
<script setup lang="ts">
|
|
25
|
-
import { computed } from "vue";
|
|
25
|
+
import { computed, onMounted, ref } from "vue";
|
|
26
|
+
import { defAuthService } from "../../api/system/admin/v1/auth";
|
|
27
|
+
import type { CurrentPasswordPolicy } from "../../rpc/system/admin/v1/auth";
|
|
26
28
|
import { getPasswordStrength } from "../../utils/passwordStrength";
|
|
27
29
|
import { useLocaleStore } from "../../locales";
|
|
28
30
|
|
|
@@ -34,18 +36,57 @@ interface PasswordStrengthProps {
|
|
|
34
36
|
password?: string;
|
|
35
37
|
/** 底部提示文案。 */
|
|
36
38
|
tip?: string;
|
|
39
|
+
/** 已知的密码策略;传入后直接用于摘要展示。 */
|
|
40
|
+
policy?: CurrentPasswordPolicy;
|
|
41
|
+
/** 是否加载当前登录用户生效的密码策略。 */
|
|
42
|
+
loadCurrentPolicy?: boolean;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
const props = withDefaults(defineProps<PasswordStrengthProps>(), {
|
|
40
46
|
password: "",
|
|
41
|
-
tip: ""
|
|
47
|
+
tip: "",
|
|
48
|
+
policy: undefined,
|
|
49
|
+
loadCurrentPolicy: false
|
|
42
50
|
});
|
|
43
51
|
|
|
52
|
+
const currentPolicy = ref<CurrentPasswordPolicy>();
|
|
53
|
+
|
|
44
54
|
/** 强度条固定为三段,保持所有页面一致。 */
|
|
45
55
|
const segments = [1, 2, 3];
|
|
46
56
|
|
|
47
57
|
/** 根据输入密码实时输出强度结果。 */
|
|
48
58
|
const strength = computed(() => getPasswordStrength(props.password));
|
|
59
|
+
|
|
60
|
+
/** 将生效策略压缩为用户可直接理解的一句话。 */
|
|
61
|
+
const displayedTip = computed(() => {
|
|
62
|
+
if (props.tip) return props.tip;
|
|
63
|
+
const policy = props.policy ?? currentPolicy.value;
|
|
64
|
+
if (!policy) return t("core.password.tip");
|
|
65
|
+
|
|
66
|
+
const requirements = [
|
|
67
|
+
t("core.password.policy.min_length", { count: policy.min_length }),
|
|
68
|
+
t("core.password.policy.complexity", { count: policy.min_complexity_classes })
|
|
69
|
+
];
|
|
70
|
+
if (policy.history_count > 0) {
|
|
71
|
+
requirements.push(t("core.password.policy.history", { count: policy.history_count }));
|
|
72
|
+
}
|
|
73
|
+
requirements.push(
|
|
74
|
+
policy.max_age_days > 0
|
|
75
|
+
? t("core.password.policy.max_age", { count: policy.max_age_days })
|
|
76
|
+
: t("core.password.policy.no_expiry")
|
|
77
|
+
);
|
|
78
|
+
return requirements.join(t("core.password.policy.separator"));
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/** 按需加载当前登录用户实际生效的密码策略。 */
|
|
82
|
+
onMounted(async () => {
|
|
83
|
+
if (!props.loadCurrentPolicy || props.policy) return;
|
|
84
|
+
try {
|
|
85
|
+
currentPolicy.value = await defAuthService.GetCurrentPasswordPolicy({});
|
|
86
|
+
} catch (_error) {
|
|
87
|
+
currentPolicy.value = undefined;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
49
90
|
</script>
|
|
50
91
|
|
|
51
92
|
<style scoped lang="scss">
|
|
@@ -248,6 +248,12 @@
|
|
|
248
248
|
"core.password.strength.low": "Low",
|
|
249
249
|
"core.password.strength.medium": "Medium",
|
|
250
250
|
"core.password.tip": "Password requirements follow the active password policy.",
|
|
251
|
+
"core.password.policy.min_length": "At least {count} characters",
|
|
252
|
+
"core.password.policy.complexity": "Use at least {count} of uppercase letters, lowercase letters, numbers, and symbols",
|
|
253
|
+
"core.password.policy.history": "Do not reuse the last {count} passwords",
|
|
254
|
+
"core.password.policy.max_age": "Password expires after {count} days",
|
|
255
|
+
"core.password.policy.no_expiry": "Password does not expire",
|
|
256
|
+
"core.password.policy.separator": "; ",
|
|
251
257
|
"core.theme.accordion": "Accordion menu",
|
|
252
258
|
"core.theme.aside_inverted": "Dark sidebar",
|
|
253
259
|
"core.theme.aside_inverted_tip": "Use dark colors for the sidebar",
|
|
@@ -248,6 +248,12 @@
|
|
|
248
248
|
"core.password.strength.low": "低",
|
|
249
249
|
"core.password.strength.medium": "中",
|
|
250
250
|
"core.password.tip": "パスワード要件は現在有効なパスワードポリシーに従います。",
|
|
251
|
+
"core.password.policy.min_length": "{count} 文字以上",
|
|
252
|
+
"core.password.policy.complexity": "大文字、小文字、数字、記号のうち {count} 種類以上を使用",
|
|
253
|
+
"core.password.policy.history": "直近 {count} 個のパスワードは再利用不可",
|
|
254
|
+
"core.password.policy.max_age": "パスワードの有効期限は {count} 日",
|
|
255
|
+
"core.password.policy.no_expiry": "パスワードの有効期限なし",
|
|
256
|
+
"core.password.policy.separator": ";",
|
|
251
257
|
"core.theme.accordion": "メニュー アコーディオン",
|
|
252
258
|
"core.theme.aside_inverted": "サイドバーの反転色",
|
|
253
259
|
"core.theme.aside_inverted_tip": "サイドバーの色がダークモードに変わります",
|
|
@@ -248,6 +248,12 @@
|
|
|
248
248
|
"core.password.strength.low": "低",
|
|
249
249
|
"core.password.strength.medium": "中",
|
|
250
250
|
"core.password.tip": "密码要求以当前生效的密码策略为准。",
|
|
251
|
+
"core.password.policy.min_length": "至少 {count} 位",
|
|
252
|
+
"core.password.policy.complexity": "大写字母、小写字母、数字、特殊字符中至少包含 {count} 类",
|
|
253
|
+
"core.password.policy.history": "不可重复使用最近 {count} 个密码",
|
|
254
|
+
"core.password.policy.max_age": "密码有效期 {count} 天",
|
|
255
|
+
"core.password.policy.no_expiry": "密码长期有效",
|
|
256
|
+
"core.password.policy.separator": ";",
|
|
251
257
|
"core.theme.accordion": "菜单手风琴",
|
|
252
258
|
"core.theme.aside_inverted": "侧边栏反转色",
|
|
253
259
|
"core.theme.aside_inverted_tip": "侧边栏颜色变为深色模式",
|
|
@@ -248,6 +248,12 @@
|
|
|
248
248
|
"core.password.strength.low": "低",
|
|
249
249
|
"core.password.strength.medium": "中",
|
|
250
250
|
"core.password.tip": "密碼要求以目前生效的密碼策略為準。",
|
|
251
|
+
"core.password.policy.min_length": "至少 {count} 位",
|
|
252
|
+
"core.password.policy.complexity": "大寫字母、小寫字母、數字、特殊字元中至少包含 {count} 類",
|
|
253
|
+
"core.password.policy.history": "不可重複使用最近 {count} 個密碼",
|
|
254
|
+
"core.password.policy.max_age": "密碼有效期 {count} 天",
|
|
255
|
+
"core.password.policy.no_expiry": "密碼長期有效",
|
|
256
|
+
"core.password.policy.separator": ";",
|
|
251
257
|
"core.theme.accordion": "選單手風琴",
|
|
252
258
|
"core.theme.aside_inverted": "側邊欄反轉色",
|
|
253
259
|
"core.theme.aside_inverted_tip": "側邊欄顏色變為深色模式",
|
|
@@ -60,6 +60,22 @@ export interface UserInfoForm {
|
|
|
60
60
|
export interface GetUserProfileRequest {
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/** 获取当前用户密码策略请求参数 */
|
|
64
|
+
export interface GetCurrentPasswordPolicyRequest {
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** 当前用户生效的密码策略 */
|
|
68
|
+
export interface CurrentPasswordPolicy {
|
|
69
|
+
/** 密码最小长度 */
|
|
70
|
+
min_length: number;
|
|
71
|
+
/** 密码至少满足的字符类别数量 */
|
|
72
|
+
min_complexity_classes: number;
|
|
73
|
+
/** 禁止重复使用的历史密码数量,零表示不启用 */
|
|
74
|
+
history_count: number;
|
|
75
|
+
/** 密码有效期天数,零表示长期有效 */
|
|
76
|
+
max_age_days: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
63
79
|
/** 用户资料表单 */
|
|
64
80
|
export interface UserProfileForm {
|
|
65
81
|
/** 用户名 */
|
|
@@ -210,6 +226,8 @@ export interface AuthService {
|
|
|
210
226
|
GetUserInfo(request: GetUserInfoRequest): Promise<UserInfoForm>;
|
|
211
227
|
/** 获取个人中心用户信息 */
|
|
212
228
|
GetUserProfile(request: GetUserProfileRequest): Promise<UserProfileForm>;
|
|
229
|
+
/** 获取当前用户生效的密码策略 */
|
|
230
|
+
GetCurrentPasswordPolicy(request: GetCurrentPasswordPolicyRequest): Promise<CurrentPasswordPolicy>;
|
|
213
231
|
/** 修改个人中心密码 */
|
|
214
232
|
UpdateUserPassword(request: UpdateUserPasswordRequest): Promise<Empty>;
|
|
215
233
|
/** 修改个人中心手机号 */
|