Skip to content

Commit 1853e84

Browse files
feat: 用户增加mfa设置
1 parent 36d7acb commit 1853e84

File tree

11 files changed

+928
-882
lines changed

11 files changed

+928
-882
lines changed

init-kube.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33

44
arg1=$1
55
mkdir -p ~/.kube
6-
code=`curl -w %{http_code} -s -o ~/.kube/config http://localhost/api/v1/webkubectl/session?token=${arg1}`
6+
code=`curl -w %{http_code} -s -o ~/.kube/config http://localhost/kubepi/api/v1/webkubectl/session?token=${arg1}`
77

88
if [[ $code -ne '200' ]];then
99
echo "download kubeconfig failed"

internal/model/v1/user/user.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@ type User struct {
1111
IsAdmin bool `json:"isAdmin"`
1212
Authenticate Authenticate `json:"authenticate"`
1313
Type string `json:"type"`
14+
Mfa Mfa `json:"mfa"`
1415
}
1516

1617
type Authenticate struct {
1718
Password string `json:"password"`
1819
Token string `json:"token"`
1920
}
2021

22+
type Mfa struct {
23+
Enable bool `json:"enable"`
24+
Secret string `json:"secret"`
25+
}
26+
2127
const (
2228
LDAP = "LDAP"
2329
LOCAL = "LOCAL"

web/kubepi/package-lock.json

Lines changed: 844 additions & 846 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/kubepi/src/business/login/index.vue

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
<template xmlns:el-col="http://www.w3.org/1999/html">
22
<div class="login-background">
3+
<!-- <el-row>-->
4+
<!-- <el-col>-->
5+
<!-- <div style="text-align: center">-->
6+
<!-- <div>-->
7+
<!-- <span>{{ $t("commons.login.mfa_helper") }}</span>-->
8+
<!-- </div>-->
9+
<!-- <div>-->
10+
<!-- <img :src="otp.qrUrl">-->
11+
<!-- </div>-->
12+
<!-- <div>-->
13+
<!-- <span>Secret:{{otp.secret}}</span>-->
14+
<!-- </div>-->
15+
<!-- <div>-->
16+
<!-- <el-form>-->
17+
<!-- <el-form-item class="login">-->
18+
<!-- <el-input></el-input>-->
19+
<!-- </el-form-item>-->
20+
<!-- </el-form>-->
21+
<!-- <div>-->
22+
<!-- <el-button type="primary" class="submit" @click="submit('form')" size="default">-->
23+
<!-- {{ $t("commons.button.bind") }}-->
24+
<!-- </el-button>-->
25+
<!-- </div>-->
26+
<!-- </div>-->
27+
<!-- </div>-->
28+
<!-- </el-col>-->
29+
<!-- </el-row>-->
330
<div class="login-container">
431
<el-row type="flex" v-loading="loading">
532
<el-col :span="12">
@@ -37,7 +64,6 @@
3764
</template>
3865
<script>
3966
40-
4167
export default {
4268
name: "Login",
4369
data () {
@@ -68,7 +94,11 @@ export default {
6894
redirect: undefined,
6995
otherQuery: {},
7096
systemName: this.$t("commons.login.title"),
71-
loadingPage: false
97+
loadingPage: false,
98+
otp: {
99+
secret: "21121212",
100+
qrUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAABlBMVEX///8AAABVwtN+AAACZUlEQVR42uyZP3LmKhDEW0VAyBE4Chd7pT/li3EUjkBIQKlf9SCvPq83t9j9CGSX/EswM909CO/1Xv/kWkjy9EQ4AceDRNyR9DZPBDQAqyewIrGsgS0eNQEIUwGRdfV0FZ6IZCaPmjz74wDA1dXnHlnhyzIp4HMPp2ePRwWwTQjAisnVrcGVrSbri99L7oeB0by5h6MlV9aQrey/dfezgc/Vg9RHi2WrfxDURwNLg23J6Wnd3eIesi/bLaQ/DkB9C1XUiiSALZ4hs7h7KxMA0tBN29yROtZgug+W/66+mAJYWKCWkATlHnegxVOPu3EmAIAIbMysC4f9Nmxk+6VRjwA8O6BUs3u6gkDPU2cxFWDdfSL1sHuLDmjyrC9RbQYg9rBLSCl014+lAvFRAOlUQF2/mQT5YmLU72z/fMDsavdURWVIQ9vwhKkAS0Eb2bE1BSBle9ZXIX0A8Nm8fZzKqRfyLH7cnjUFAChrVqh592AHQj8bUHRiQ4Jgc6DKyt957QHASMWwvEY7EJ0FfXFfYvPDAfii13mIUbGQAyRP3v+HCQDYnAVnY0pkTU0hQi/yYwDzrMPUviWWhVmamVVnmAhgUZ5PuPJkyKOi+HEHzgkAuZO624xBjT1S54tnzQFQE8rID9BgPjr+JSb9OHB1sGX7bJ4FbPVysmmAzzsQyA6ciol2afYyDM4AXLesjodtUzO5bfODTwLGLWu3AylXrCeLmxGwK4Q+/ibjit8vkx8PaKQ9tU0Nt/KE15H2CcBwXvsCIrUfX0Bep8UZgOs7Tg/nSBIJI6/1MBHwXu/1l63/AwAA//8FHjSXDI6EdgAAAABJRU5ErkJggg=="
101+
},
72102
}
73103
},
74104
watch: {

web/kubepi/src/business/user-management/user/create/index.vue

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,18 @@
99
<el-form-item :label="$t('business.user.username')" prop="name">
1010
<el-input v-model="form.name"></el-input>
1111
</el-form-item>
12-
13-
1412
<el-form-item :label="$t('business.user.nickname')" prop="nickname">
1513
<el-input v-model="form.nickname"></el-input>
1614
</el-form-item>
17-
18-
1915
<el-form-item :label="$t('business.user.email')" prop="email">
2016
<el-input v-model="form.email"></el-input>
2117
</el-form-item>
22-
23-
2418
<el-form-item :label="$t('business.user.password')" prop="password">
2519
<el-input type="password" v-model="form.password"></el-input>
2620
</el-form-item>
27-
28-
2921
<el-form-item :label="$t('business.user.confirm_password')" prop="confirmPassword">
3022
<el-input type="password" v-model="form.confirmPassword"></el-input>
3123
</el-form-item>
32-
3324
<el-form-item :label="$t('business.user.role')" prop="roles">
3425
<el-select v-model="form.roles" multiple filterable
3526
style="width: 100%"
@@ -42,16 +33,16 @@
4233
</el-option>
4334
</el-select>
4435
</el-form-item>
45-
46-
36+
<el-form-item :label="$t('commons.table.mfa_enable')" prop="mfa.enable">
37+
<el-checkbox v-model="form.mfa.enable">{{$t('commons.enable.true')}}</el-checkbox>
38+
</el-form-item>
4739
<el-form-item>
4840
<div style="float: right">
4941
<el-button @click="onCancel()">{{ $t("commons.button.cancel") }}</el-button>
5042
<el-button type="primary" @click="onConfirm()">{{ $t("commons.button.confirm") }}
5143
</el-button>
5244
</div>
5345
</el-form-item>
54-
5546
</el-form>
5647
</div>
5748
</el-col>
@@ -116,6 +107,9 @@ export default {
116107
roles: [
117108
Rules.RequiredRule,
118109
],
110+
mfa:{
111+
// enable:Rules.RequiredRule,
112+
}
119113
},
120114
form: {
121115
name: "",
@@ -124,6 +118,9 @@ export default {
124118
password: "",
125119
confirmPassword: "",
126120
roles: [],
121+
mfa: {
122+
enbale: false
123+
}
127124
},
128125
}
129126
},

web/kubepi/src/business/user-management/user/edit/index.vue

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,15 @@
55
<el-col :span="10">
66
<div class="grid-content bg-purple-light">
77
<el-form ref="form" :rules="rules" :model="form" label-width="150px" label-position="left">
8-
98
<el-form-item :label="$t('business.user.username')" prop="name">
109
<el-input v-model="form.name" disabled></el-input>
1110
</el-form-item>
12-
1311
<el-form-item :label="$t('business.user.nickname')" prop="nickname">
1412
<el-input v-model="form.nickname" :disabled="form.type ==='LDAP'"></el-input>
1513
</el-form-item>
16-
17-
1814
<el-form-item :label="$t('business.user.email')" prop="email">
1915
<el-input v-model="form.email" :disabled="form.type ==='LDAP'"></el-input>
2016
</el-form-item>
21-
22-
2317
<el-form-item :label="$t('business.user.role')" prop="roles">
2418
<el-select v-model="form.roles" filterable
2519
multiple
@@ -33,13 +27,12 @@
3327
</el-option>
3428
</el-select>
3529
</el-form-item>
36-
37-
3830
<el-form-item :label="$t('business.user.password')" v-if="form.type !=='LDAP'">
3931
<el-link @click="openedChangePassword">{{ $t("business.user.change_password") }}</el-link>
4032
</el-form-item>
41-
42-
33+
<el-form-item :label="$t('commons.table.mfa_enable')" prop="mfa.enable">
34+
<el-checkbox v-model="form.mfa.enable">{{$t('commons.enable.true')}}</el-checkbox>
35+
</el-form-item>
4336
<el-form-item>
4437
<div style="float: right">
4538
<el-button @click="onCancel()">{{ $t("commons.button.cancel") }}</el-button>
@@ -131,6 +124,9 @@ export default {
131124
roles: [
132125
Rules.RequiredRule,
133126
],
127+
mfa:{
128+
// enable:Rules.RequiredRule,
129+
}
134130
},
135131
changePasswordOpened: false,
136132
passwordChangeRules: {
@@ -154,7 +150,10 @@ export default {
154150
nickname: "",
155151
email: "",
156152
roles: [],
157-
type: "LOCAL"
153+
type: "LOCAL",
154+
mfa: {
155+
156+
}
158157
},
159158
}
160159
},

web/kubepi/src/business/user-management/user/index.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,21 @@
2626
<el-tag style="margin-left: 5px" size="small" v-if="row.roles.length===0 && row.isAdmin">Supper User</el-tag>
2727
</template>
2828
</el-table-column>
29-
3029
<el-table-column :label="$t('business.user.email')" min-width="100" fix>
3130
<template v-slot:default="{row}">
3231
{{ row.email }}
3332
</template>
3433
</el-table-column>
35-
3634
<el-table-column :label="$t('commons.table.built_in')" min-width="100" fix>
3735
<template v-slot:default="{row}">
3836
{{ $t("commons.bool." + row.builtIn) }}
3937
</template>
4038
</el-table-column>
39+
<el-table-column :label="$t('commons.table.mfa_enable')" min-width="100" fix>
40+
<template v-slot:default="{row}">
41+
{{ $t("commons.enable." + row.mfa.enable) }}
42+
</template>
43+
</el-table-column>
4144
<el-table-column :label="$t('business.user.type')" min-width="100" fix>
4245
<template v-slot:default="{row}">
4346
{{ row.type ? row.type : "LOCAL" }}
@@ -49,7 +52,6 @@
4952
</template>
5053
</el-table-column>
5154

52-
5355
<fu-table-operations :buttons="buttons" :label="$t('commons.table.action')"/>
5456
</complex-table>
5557
</layout-content>
@@ -146,7 +148,7 @@ export default {
146148
}
147149
}
148150
}
149-
if (this.ps.length !== 0) {
151+
if (this.ps.length !== 0) {
150152
Promise.all(this.ps)
151153
.then(() => {
152154
this.search()

web/kubepi/src/i18n/lang/en-US.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const message = {
4141
upload: "Upload",
4242
search: "Search",
4343
rbac_manage: "RBAC Manage",
44-
sync: "Sync"
44+
sync: "Sync",
45+
bind: "Bind"
4546
},
4647
table: {
4748
name: "Name",
@@ -54,6 +55,7 @@ const message = {
5455
built_in: "Built in",
5556
description: "Description",
5657
empty_text: "There are no rows to show.",
58+
mfa_enable: "MFA Auth"
5759
},
5860
header: {
5961
help_doc: "document",
@@ -65,6 +67,10 @@ const message = {
6567
true: "true",
6668
false: "false"
6769
},
70+
enable: {
71+
true: "Enable",
72+
false: "Disable"
73+
},
6874
search: {
6975
quickSearch: "quick search"
7076
},
@@ -98,7 +104,8 @@ const message = {
98104
password: "password",
99105
title: "login KubePi",
100106
welcome: "Welcome back, please enter your user name and password to log in",
101-
expires: "The authentication information has expired. Please log in again."
107+
expires: "The authentication information has expired. Please log in again.",
108+
mfa_helper: "Scan the QR code below with the MFA Authenticator app to get a 6-digit verification code",
102109
},
103110
},
104111
business: {

web/kubepi/src/i18n/lang/zh-CN.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const message = {
4141
upload: "上传文件",
4242
search: "搜索",
4343
rbac_manage: "授权",
44-
sync: "同步"
44+
sync: "同步",
45+
bind: "绑定"
4546
},
4647
table: {
4748
name: "名称",
@@ -54,6 +55,7 @@ const message = {
5455
built_in: "内置",
5556
description: "描述",
5657
empty_text: "没有内容显示",
58+
mfa_enable: "MFA认证"
5759
},
5860
header: {
5961
help_doc: "帮助文档",
@@ -65,6 +67,10 @@ const message = {
6567
true: "是",
6668
false: "否"
6769
},
70+
enable: {
71+
true: "启用",
72+
false: "禁用"
73+
},
6874
search: {
6975
quickSearch: "搜索"
7076
},
@@ -99,6 +105,7 @@ const message = {
99105
title: "登录 KubePi",
100106
welcome: "欢迎回来,请输入用户名和密码登录",
101107
expires: "认证信息已过期,请重新登录",
108+
mfa_helper: "使用 MFA 验证器应用扫描以下二维码,获取6位验证码",
102109
},
103110
},
104111
business: {

web/kubepi/vue.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ module.exports = {
1919
target: 'http://0.0.0.0:4400',
2020
},
2121
'/kubepi/api': {
22-
target: 'http://0.0.0.0:80',
22+
target: 'http://0.0.0.0:2019',
2323
ws: true,
2424
secure: false,
2525
},
2626
'/webkubectl': {
27-
target: 'http://0.0.0.0:80',
27+
target: 'http://0.0.0.0:2019',
2828
ws: true,
2929
secure: false,
3030
},

web/terminal/proxy.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"/kubepi/api/": {
3-
"target": "http://localhost:80"
3+
"target": "http://localhost:2019"
44
}
55
}

0 commit comments

Comments
 (0)