Skip to content

Commit aeb494e

Browse files
committed
feat: 增加oauth2的认证
--story=1016294 --user=王孝刚 【东区】希望可以支持Oauth2【X-Pack】 https://www.tapd.cn/57709429/s/1610096
1 parent 359dc9f commit aeb494e

File tree

6 files changed

+364
-127
lines changed

6 files changed

+364
-127
lines changed

ui/src/locales/lang/en_US/index.ts

Lines changed: 87 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,90 @@
1-
import en from 'element-plus/es/locale/lang/en';
2-
import components from './components';
3-
import layout from './layout';
4-
import views from './views';
1+
import en from 'element-plus/es/locale/lang/en'
2+
import components from './components'
3+
import layout from './layout'
4+
import views from './views'
55

66
export default {
7-
lang: 'English',
8-
layout,
9-
views,
10-
components,
11-
en,
12-
login: {
13-
authentication: 'Login Authentication',
14-
ldap: {
15-
title: 'LDAP Settings',
16-
address: 'LDAP Address',
17-
serverPlaceholder: 'Please enter LDAP address',
18-
bindDN: 'Bind DN',
19-
bindDNPlaceholder: 'Please enter Bind DN',
20-
password: 'Password',
21-
passwordPlaceholder: 'Please enter password',
22-
ou: 'User OU',
23-
ouPlaceholder: 'Please enter User OU',
24-
ldap_filter: 'User Filter',
25-
ldap_filterPlaceholder: 'Please enter User Filter',
26-
ldap_mapping: 'LDAP Attribute Mapping',
27-
ldap_mappingPlaceholder: 'Please enter LDAP Attribute Mapping',
28-
test: 'Test Connection',
29-
enableAuthentication: 'Enable LDAP Authentication',
30-
save: 'Save',
31-
testConnectionSuccess: 'Test Connection Success',
32-
testConnectionFailed: 'Test Connection Failed',
33-
saveSuccess: 'Save Success',
34-
},
35-
cas: {
36-
title: 'CAS Settings',
37-
ldpUri: 'ldpUri',
38-
ldpUriPlaceholder: 'Please enter ldpUri',
39-
redirectUrl: 'Callback Address',
40-
redirectUrlPlaceholder: 'Please enter Callback Address',
41-
enableAuthentication: 'Enable CAS Authentication',
42-
saveSuccess: 'Save Success',
43-
save: 'Save',
44-
},
45-
oidc: {
46-
title: 'OIDC Settings',
47-
authEndpoint: 'Auth Endpoint',
48-
authEndpointPlaceholder: 'Please enter Auth Endpoint',
49-
tokenEndpoint: 'Token Endpoint',
50-
tokenEndpointPlaceholder: 'Please enter Token Endpoint',
51-
userInfoEndpoint: 'User Info Endpoint',
52-
userInfoEndpointPlaceholder: 'Please enter User Info Endpoint',
53-
clientId: 'Client ID',
54-
clientIdPlaceholder: 'Please enter Client ID',
55-
clientSecret: 'Client Secret',
56-
clientSecretPlaceholder: 'Please enter Client Secret',
57-
logoutEndpoint: 'Logout Endpoint',
58-
logoutEndpointPlaceholder: 'Please enter Logout Endpoint',
59-
redirectUrl: 'Redirect URL',
60-
redirectUrlPlaceholder: 'Please enter Redirect URL',
61-
enableAuthentication: 'Enable OIDC Authentication',
62-
},
63-
jump_tip: 'Jumping to the authentication source page for authentication',
64-
jump: 'Jump',
7+
lang: 'English',
8+
layout,
9+
views,
10+
components,
11+
en,
12+
login: {
13+
authentication: 'Login Authentication',
14+
ldap: {
15+
title: 'LDAP Settings',
16+
address: 'LDAP Address',
17+
serverPlaceholder: 'Please enter LDAP address',
18+
bindDN: 'Bind DN',
19+
bindDNPlaceholder: 'Please enter Bind DN',
20+
password: 'Password',
21+
passwordPlaceholder: 'Please enter password',
22+
ou: 'User OU',
23+
ouPlaceholder: 'Please enter User OU',
24+
ldap_filter: 'User Filter',
25+
ldap_filterPlaceholder: 'Please enter User Filter',
26+
ldap_mapping: 'LDAP Attribute Mapping',
27+
ldap_mappingPlaceholder: 'Please enter LDAP Attribute Mapping',
28+
test: 'Test Connection',
29+
enableAuthentication: 'Enable LDAP Authentication',
30+
save: 'Save',
31+
testConnectionSuccess: 'Test Connection Success',
32+
testConnectionFailed: 'Test Connection Failed',
33+
saveSuccess: 'Save Success'
6534
},
66-
};
35+
cas: {
36+
title: 'CAS Settings',
37+
ldpUri: 'ldpUri',
38+
ldpUriPlaceholder: 'Please enter ldpUri',
39+
validateUrl: 'Validation Address',
40+
validateUrlPlaceholder: 'Please enter Validation Address',
41+
redirectUrl: 'Callback Address',
42+
redirectUrlPlaceholder: 'Please enter Callback Address',
43+
enableAuthentication: 'Enable CAS Authentication',
44+
saveSuccess: 'Save Success',
45+
save: 'Save'
46+
},
47+
oidc: {
48+
title: 'OIDC Settings',
49+
authEndpoint: 'Auth Endpoint',
50+
authEndpointPlaceholder: 'Please enter Auth Endpoint',
51+
tokenEndpoint: 'Token Endpoint',
52+
tokenEndpointPlaceholder: 'Please enter Token Endpoint',
53+
userInfoEndpoint: 'User Info Endpoint',
54+
userInfoEndpointPlaceholder: 'Please enter User Info Endpoint',
55+
clientId: 'Client ID',
56+
clientIdPlaceholder: 'Please enter Client ID',
57+
clientSecret: 'Client Secret',
58+
clientSecretPlaceholder: 'Please enter Client Secret',
59+
logoutEndpoint: 'Logout Endpoint',
60+
logoutEndpointPlaceholder: 'Please enter Logout Endpoint',
61+
redirectUrl: 'Redirect URL',
62+
redirectUrlPlaceholder: 'Please enter Redirect URL',
63+
enableAuthentication: 'Enable OIDC Authentication'
64+
},
65+
jump_tip: 'Jumping to the authentication source page for authentication',
66+
jump: 'Jump',
67+
oauth2: {
68+
title: 'OAUTH2 Settings',
69+
authEndpoint: 'Auth Endpoint',
70+
authEndpointPlaceholder: 'Please enter Auth Endpoint',
71+
tokenEndpoint: 'Token Endpoint',
72+
tokenEndpointPlaceholder: 'Please enter Token Endpoint',
73+
userInfoEndpoint: 'User Info Endpoint',
74+
userInfoEndpointPlaceholder: 'Please enter User Info Endpoint',
75+
scope: 'Scope',
76+
scopePlaceholder: 'Please enter Scope',
77+
clientId: 'Client ID',
78+
clientIdPlaceholder: 'Please enter Client ID',
79+
clientSecret: 'Client Secret',
80+
clientSecretPlaceholder: 'Please enter Client Secret',
81+
redirectUrl: 'Redirect URL',
82+
redirectUrlPlaceholder: 'Please enter Redirect URL',
83+
filedMapping: 'Field Mapping',
84+
filedMappingPlaceholder: 'Please enter Field Mapping',
85+
enableAuthentication: 'Enable OAUTH2 Authentication',
86+
save: 'Save',
87+
saveSuccess: 'Save Success'
88+
}
89+
}
90+
}

ui/src/locales/lang/zh_CN/index.ts

Lines changed: 87 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,90 @@
1-
import zhCn from 'element-plus/es/locale/lang/zh-cn';
2-
import components from './components';
3-
import layout from './layout';
4-
import views from './views';
1+
import zhCn from 'element-plus/es/locale/lang/zh-cn'
2+
import components from './components'
3+
import layout from './layout'
4+
import views from './views'
55

66
export default {
7-
lang: '简体中文',
8-
layout,
9-
views,
10-
components,
11-
zhCn,
12-
login: {
13-
authentication: '登录认证',
14-
ldap: {
15-
title: 'LDAP 设置',
16-
address: 'LDAP 地址',
17-
serverPlaceholder: '请输入LDAP 地址',
18-
bindDN: '绑定DN',
19-
bindDNPlaceholder: '请输入绑定 DN',
20-
password: '密码',
21-
passwordPlaceholder: '请输入密码',
22-
ou: '用户OU',
23-
ouPlaceholder: '请输入用户 OU',
24-
ldap_filter: '用户过滤器',
25-
ldap_filterPlaceholder: '请输入用户过滤器',
26-
ldap_mapping: 'LDAP 属性映射',
27-
ldap_mappingPlaceholder: '请输入 LDAP 属性映射',
28-
test: '测试连接',
29-
enableAuthentication: '启用 LDAP 认证',
30-
save: '保存',
31-
testConnectionSuccess: '测试连接成功',
32-
testConnectionFailed: '测试连接失败',
33-
saveSuccess: '保存成功',
34-
},
35-
cas: {
36-
title: 'CAS 设置',
37-
ldpUri: 'ldpUri',
38-
ldpUriPlaceholder: '请输入ldpUri',
39-
redirectUrl: '回调地址',
40-
redirectUrlPlaceholder: '请输入回调地址',
41-
enableAuthentication: '启用CAS认证',
42-
saveSuccess: '保存成功',
43-
save: '保存',
44-
},
45-
oidc: {
46-
title: 'OIDC 设置',
47-
authEndpoint: '授权端地址',
48-
authEndpointPlaceholder: '请输入授权端地址',
49-
tokenEndpoint: 'Token端地址',
50-
tokenEndpointPlaceholder: '请输入Token端地址',
51-
userInfoEndpoint: '用户信息端地址',
52-
userInfoEndpointPlaceholder: '请输入用户信息端地址',
53-
clientId: '客户端ID',
54-
clientIdPlaceholder: '请输入客户端ID',
55-
clientSecret: '客户端密钥',
56-
clientSecretPlaceholder: '请输入客户端密钥',
57-
logoutEndpoint: '注销端地址',
58-
logoutEndpointPlaceholder: '请输入注销端地址',
59-
redirectUrl: '回调地址',
60-
redirectUrlPlaceholder: '请输入回调地址',
61-
enableAuthentication: '启用OIDC认证',
62-
},
63-
jump_tip: '即将跳转至认证源页面进行认证',
64-
jump: '跳转',
7+
lang: '简体中文',
8+
layout,
9+
views,
10+
components,
11+
zhCn,
12+
login: {
13+
authentication: '登录认证',
14+
ldap: {
15+
title: 'LDAP 设置',
16+
address: 'LDAP 地址',
17+
serverPlaceholder: '请输入LDAP 地址',
18+
bindDN: '绑定DN',
19+
bindDNPlaceholder: '请输入绑定 DN',
20+
password: '密码',
21+
passwordPlaceholder: '请输入密码',
22+
ou: '用户OU',
23+
ouPlaceholder: '请输入用户 OU',
24+
ldap_filter: '用户过滤器',
25+
ldap_filterPlaceholder: '请输入用户过滤器',
26+
ldap_mapping: 'LDAP 属性映射',
27+
ldap_mappingPlaceholder: '请输入 LDAP 属性映射',
28+
test: '测试连接',
29+
enableAuthentication: '启用 LDAP 认证',
30+
save: '保存',
31+
testConnectionSuccess: '测试连接成功',
32+
testConnectionFailed: '测试连接失败',
33+
saveSuccess: '保存成功'
6534
},
66-
};
35+
cas: {
36+
title: 'CAS 设置',
37+
ldpUri: 'ldpUri',
38+
ldpUriPlaceholder: '请输入ldpUri',
39+
validateUrl: '验证地址',
40+
validateUrlPlaceholder: '请输入验证地址',
41+
redirectUrl: '回调地址',
42+
redirectUrlPlaceholder: '请输入回调地址',
43+
enableAuthentication: '启用CAS认证',
44+
saveSuccess: '保存成功',
45+
save: '保存'
46+
},
47+
oidc: {
48+
title: 'OIDC 设置',
49+
authEndpoint: '授权端地址',
50+
authEndpointPlaceholder: '请输入授权端地址',
51+
tokenEndpoint: 'Token端地址',
52+
tokenEndpointPlaceholder: '请输入Token端地址',
53+
userInfoEndpoint: '用户信息端地址',
54+
userInfoEndpointPlaceholder: '请输入用户信息端地址',
55+
clientId: '客户端ID',
56+
clientIdPlaceholder: '请输入客户端ID',
57+
clientSecret: '客户端密钥',
58+
clientSecretPlaceholder: '请输入客户端密钥',
59+
logoutEndpoint: '注销端地址',
60+
logoutEndpointPlaceholder: '请输入注销端地址',
61+
redirectUrl: '回调地址',
62+
redirectUrlPlaceholder: '请输入回调地址',
63+
enableAuthentication: '启用OIDC认证'
64+
},
65+
jump_tip: '即将跳转至认证源页面进行认证',
66+
jump: '跳转',
67+
oauth2: {
68+
title: 'OAUTH2 设置',
69+
authEndpoint: '授权端地址',
70+
authEndpointPlaceholder: '请输入授权端地址',
71+
tokenEndpoint: 'Token端地址',
72+
tokenEndpointPlaceholder: '请输入Token端地址',
73+
userInfoEndpoint: '用户信息端地址',
74+
userInfoEndpointPlaceholder: '请输入用户信息端地址',
75+
scope: '连接范围',
76+
scopePlaceholder: '请输入连接范围',
77+
clientId: '客户端ID',
78+
clientIdPlaceholder: '请输入客户端ID',
79+
clientSecret: '客户端密钥',
80+
clientSecretPlaceholder: '请输入客户端密钥',
81+
redirectUrl: '回调地址',
82+
redirectUrlPlaceholder: '请输入回调地址',
83+
filedMapping: '字段映射',
84+
filedMappingPlaceholder: '请输入字段映射',
85+
enableAuthentication: '启用OAUTH2认证',
86+
save: '保存',
87+
saveSuccess: '保存成功'
88+
}
89+
}
90+
}

ui/src/views/authentication/component/CAS.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
:placeholder="$t('login.cas.ldpUriPlaceholder')"
1616
/>
1717
</el-form-item>
18+
<el-form-item :label="$t('login.cas.validateUrl')" prop="config_data.validateUrl">
19+
<el-input
20+
v-model="form.config_data.validateUrl"
21+
:placeholder="$t('login.cas.validateUrlPlaceholder')"
22+
/>
23+
</el-form-item>
1824
<el-form-item :label="$t('login.cas.redirectUrl')" prop="config_data.redirectUrl">
1925
<el-input
2026
v-model="form.config_data.redirectUrl"
@@ -49,6 +55,7 @@ const form = ref<any>({
4955
auth_type: 'CAS',
5056
config_data: {
5157
ldpUri: '',
58+
validateUrl: '',
5259
redirectUrl: ''
5360
},
5461
is_active: true
@@ -62,6 +69,9 @@ const rules = reactive<FormRules<any>>({
6269
'config_data.ldpUri': [
6370
{ required: true, message: t('login.cas.ldpUriPlaceholder'), trigger: 'blur' }
6471
],
72+
'config_data.validateUrl': [
73+
{ required: true, message: t('login.cas.validateUrlPlaceholder'), trigger: 'blur' }
74+
],
6575
'config_data.redirectUrl': [
6676
{
6777
required: true,
@@ -85,6 +95,9 @@ const submit = async (formEl: FormInstance | undefined) => {
8595
function getDetail() {
8696
authApi.getAuthSetting(form.value.auth_type, loading).then((res: any) => {
8797
if (res.data && JSON.stringify(res.data) !== '{}') {
98+
if (!res.data.config_data.validateUrl) {
99+
res.data.config_data.validateUrl = res.data.config_data.ldpUri
100+
}
88101
form.value = res.data
89102
}
90103
})

0 commit comments

Comments
 (0)