Skip to content

Commit

Permalink
fix(web): 对作业名、创建租户、充值等输入做长度控制,修改示例配置文件增加对用户ID和账户的默认配置,避免用户输入过长或输入非法字符 (
Browse files Browse the repository at this point in the history
#948)

## 对输入端做长度控制,避免用户输入过长,导致slurm或数据库报错、布局破坏:

- 提交作业和应用时“作业名”长度输入为50字符;
- 创建租户时,租户名:限制255字符
- 创建用户时,姓名:限制50字符
- 账户充值、租户充值时“类型”长度限制50字符,"备注”限制255字符;

## 修改了./cli init
生成的示例配置文件mis.yaml,增加默认配置(之前已部署的scow,如不更改mis.yaml,以下内容不生效):
 - 创建账户时,账户名:3-20位数字、小写字母、下划线,以小写字母开头
 - 创建用户时,用户ID:3-20位数字、小写字母、下划线,以小写字母开头
  • Loading branch information
tongchong authored Nov 5, 2023
1 parent ee48e8c commit 5a9bda6
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 39 deletions.
7 changes: 7 additions & 0 deletions .changeset/blue-donuts-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@scow/portal-web": patch
"@scow/mis-web": patch
"@scow/docs": patch
---

对提交作业和应用的作业名,创建用户时的姓名、创建租户时租户名、充值时的类型、备注输入做长度控制,避免用户输入过长
5 changes: 5 additions & 0 deletions .changeset/gorgeous-countries-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scow/cli": patch
---

修改了示例配置文件,新的示例配置文件中默认配置了账户和用户的ID的格式,皆改为: 3-20位数字、小写字母、下划线,以小写字母开头
24 changes: 12 additions & 12 deletions apps/cli/assets/config/mis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,34 @@ predefinedChargingTypes:
- 测试

# 创建账户时,账户名的规则。不设置就没有限制
# accountNamePattern:
accountNamePattern:
# 正则表达式
# regex: ""
regex: "^[a-z][a-z0-9_]{2,19}$"

# 出错时的消息
# 出错时的消息,对应上面的正则表达式
# 此文本支持国际化
# errorMessage: ""
errorMessage: "要求输入长度为3-20位,由小写字母、数字、下划线组成,且以小写字母开头的字符串"

# 创建用户相关配置
# createUser:
createUser:

# 是否允许用户从SCOW中创建用户
# enabled: true
enabled: true

# SCOW中创建用户界面是使用内置的(builtin)或者使用外置页面(external)
# 默认builtin
# type: builtin
type: builtin

# 内置创建用户界面配置
# builtin:
# 用户ID的格式
# userIdPattern:
builtin:
# 用户ID的格式,不设置就没有限制
userIdPattern:
# 正则表达式
# regex: ""
regex: "^[a-z][a-z0-9_]{2,19}$"

# 出错时的消息
# 此文本支持国际化
# errorMessage: ""
errorMessage: "要求输入长度为3-20位,由小写字母、数字、下划线组成,且以小写字母开头的字符串"

# 外置页面配置
# external:
Expand Down
1 change: 1 addition & 0 deletions apps/mis-web/src/pageComponents/admin/CreateTenantForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const CreateTenantForm: React.FC = () => {
name="tenantName"
rules={[
{ required: true },
{ max: 255 },
]}
>
<Input />
Expand Down
7 changes: 5 additions & 2 deletions apps/mis-web/src/pageComponents/finance/ChargeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export const ChargeForm: React.FC = () => {
<Form.Item
name="type"
label={t(pCommon("type"))}
required
rules={[
{ required: true },
{ max: 50 },
]}
extra={(
<div style={{ margin: "8px 0" }}>
<UsedType
Expand All @@ -128,7 +131,7 @@ export const ChargeForm: React.FC = () => {
>
<Input />
</Form.Item>
<Form.Item name="comment" label={t(pCommon("comment"))}>
<Form.Item name="comment" label={t(pCommon("comment"))} rules={[{ max: 255 }]}>
<Input.TextArea />
</Form.Item>
<Form.Item wrapperCol={{ span: 6, offset: 4 }}>
Expand Down
9 changes: 8 additions & 1 deletion apps/mis-web/src/pageComponents/users/CreateUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ export const CreateUserForm: React.FC = () => {
>
<Input placeholder={userIdRule?.message} />
</Form.Item>
<Form.Item label={t(pCommon("userFullName"))} name="name" rules={[{ required: true }]}>
<Form.Item
label={t(pCommon("userFullName"))}
name="name"
rules={[
{ required: true },
{ max: 50 },
]}
>
<Input />
</Form.Item>
<Form.Item
Expand Down
2 changes: 1 addition & 1 deletion apps/portal-web/src/pageComponents/app/LaunchAppForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export const LaunchAppForm: React.FC<Props> = ({ clusterId, appId, attributes, a
}}
>
<Spin spinning={loading} tip={isSubmitting ? "" : t(p("loading"))}>
<Form.Item name="appJobName" label={t(p("appJobName"))} rules={[{ required: true }]}>
<Form.Item name="appJobName" label={t(p("appJobName"))} rules={[{ required: true }, { max: 50 }]}>
<Input />
</Form.Item>
<Form.Item
Expand Down
2 changes: 1 addition & 1 deletion apps/portal-web/src/pageComponents/job/SubmitJobForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export const SubmitJobForm: React.FC<Props> = ({ initial = initialValues, submit
</Form.Item>
</Col>
<Col span={24} sm={12}>
<Form.Item<JobForm> label={t(p("jobName"))} name="jobName" rules={[{ required: true }]}>
<Form.Item<JobForm> label={t(p("jobName"))} name="jobName" rules={[{ required: true }, { max: 50 }]}>
<Input />
</Form.Item>
</Col>
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/deploy/config/mis/create-user/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ createUser:

# 内置创建用户功能配置
builtin:
# 新用户ID的格式
# 创建用户时,用户ID的规则。不设置就没有限制
userIdPattern:
# 正则表达式
regex: "[a-zA-Z0-9]+"
# 出错时的消息,可选
message: 用户ID应仅包含字母和数字
regex: "^[a-z][a-z0-9_]{2,19}$"
# 出错时的消息
errorMessage: "要求输入长度为3-20位,由小写字母、数字、下划线组成,且以小写字母开头的字符串"
```
创建时对密码的要求,请参考[用户密码正则配置](../../customization/password-pattern.md)
Expand Down
44 changes: 26 additions & 18 deletions docs/docs/deploy/config/mis/intro.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 3
sidebar_position: 1
title: 配置管理系统
---

Expand Down Expand Up @@ -87,27 +87,35 @@ periodicSyncUserAccountBlockStatus:
predefinedChargingTypes:
- 测试
# 账户名的规则
# accountNamePattern:
# 创建账户时,账户名的规则。不设置就没有限制
accountNamePattern:
# 正则表达式
# regex: ""
regex: "^[a-z][a-z0-9_]{2,19}$"
# 出错时的消息
# errorMessage: ""
# 出错时的消息,对应上面的正则表达式
# 此文本支持国际化
errorMessage: "要求输入长度为3-20位,由小写字母、数字、下划线组成,且以小写字母开头的字符串"
# 创建用户相关配置
# createUser:
# 当认证系统允许创建用户时,是否启用SCOW中创建用户的配置
# enabled: true
# 用户ID的规则
# userIdPattern:
# 正则表达式
# regex: ""
createUser:
# 允许用户创建用户。默认为true
enabled: true
# 出错时的消息
# errorMessage: ""
# 使用SCOW内置的创建用户功能。默认为builtin
type: builtin
# 内置创建用户功能配置
builtin:
# 创建用户时,用户ID的规则。不设置就没有限制
userIdPattern:
# 正则表达式
regex: "^[a-z][a-z0-9_]{2,19}$"
# 出错时的消息
errorMessage: "要求输入长度为3-20位,由小写字母、数字、下划线组成,且以小写字母开头的字符串"
# errorMessage:
# i18n:
# default: "要求输入长度为3-20位,小写字母、数字、下划线组成的字符串,且以小写字母开头"
# en: "It is required to enter a string of 3-20 characters in length, consisting of lowercase letters, numbers, and underscores, and starting with a lowercase letter."
# zh_cn: "要求输入长度为3-20位,由小写字母、数字、下划线组成,且以小写字母开头的字符串"
# # 新增导航链接相关配置
# navLinks:
Expand Down

0 comments on commit 5a9bda6

Please sign in to comment.