From 11678f3db4814f7b61ee6fdfe7b2db349e52b5ac Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 9 Aug 2024 11:20:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81cas=E5=92=8Coidc?= =?UTF-8?q?=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1015857 --user=王孝刚 【登录认证】-X-Pack支持 OIDC设置 https://www.tapd.cn/57709429/s/1560406 --story=1015856 --user=王孝刚 【登录认证】-X-Pack 支持 CAS设置 https://www.tapd.cn/57709429/s/1560408 --- ui/src/api/auth-setting.ts | 2 +- ui/src/locales/lang/en_US/index.ts | 34 ++++- ui/src/locales/lang/zh_CN/index.ts | 50 +++++-- ui/src/router/index.ts | 3 + ui/src/views/application/index.vue | 4 + ui/src/views/authentication/component/CAS.vue | 86 +++++++++++ .../views/authentication/component/OIDC.vue | 112 ++++++++++++++ ui/src/views/authentication/index.vue | 12 ++ ui/src/views/login/index.vue | 141 ++++++++++++------ 9 files changed, 383 insertions(+), 61 deletions(-) create mode 100644 ui/src/views/authentication/component/CAS.vue create mode 100644 ui/src/views/authentication/component/OIDC.vue diff --git a/ui/src/api/auth-setting.ts b/ui/src/api/auth-setting.ts index 2c694620ee4..e1d239ba2e7 100644 --- a/ui/src/api/auth-setting.ts +++ b/ui/src/api/auth-setting.ts @@ -8,7 +8,7 @@ const prefix = '/auth' * 获取认证设置 */ const getAuthSetting: (auth_type: string, loading?: Ref) => Promise> = (auth_type, loading) => { - return get(`${prefix}/${auth_type}/info`, undefined, loading) + return get(`${prefix}/${auth_type}/detail`, undefined, loading) } /** diff --git a/ui/src/locales/lang/en_US/index.ts b/ui/src/locales/lang/en_US/index.ts index 98def89da90..3e80c0adc93 100644 --- a/ui/src/locales/lang/en_US/index.ts +++ b/ui/src/locales/lang/en_US/index.ts @@ -31,6 +31,36 @@ export default { testConnectionSuccess: 'Test Connection Success', testConnectionFailed: 'Test Connection Failed', saveSuccess: 'Save Success', - } - } + }, + cas: { + title: 'CAS Settings', + ldpUri: 'ldpUri', + ldpUriPlaceholder: 'Please enter ldpUri', + redirectUrl: 'Callback Address', + redirectUrlPlaceholder: 'Please enter Callback Address', + enableAuthentication: 'Enable CAS Authentication', + saveSuccess: 'Save Success', + save: 'Save', + }, + oidc: { + title: 'OIDC Settings', + authEndpoint: 'Auth Endpoint', + authEndpointPlaceholder: 'Please enter Auth Endpoint', + tokenEndpoint: 'Token Endpoint', + tokenEndpointPlaceholder: 'Please enter Token Endpoint', + userInfoEndpoint: 'User Info Endpoint', + userInfoEndpointPlaceholder: 'Please enter User Info Endpoint', + clientId: 'Client ID', + clientIdPlaceholder: 'Please enter Client ID', + clientSecret: 'Client Secret', + clientSecretPlaceholder: 'Please enter Client Secret', + logoutEndpoint: 'Logout Endpoint', + logoutEndpointPlaceholder: 'Please enter Logout Endpoint', + redirectUrl: 'Redirect URL', + redirectUrlPlaceholder: 'Please enter Redirect URL', + enableAuthentication: 'Enable OIDC Authentication', + }, + jump_tip: 'Jumping to the authentication source page for authentication', + jump: 'Jump', + }, }; diff --git a/ui/src/locales/lang/zh_CN/index.ts b/ui/src/locales/lang/zh_CN/index.ts index e39e37376a5..26a9a0c10a7 100644 --- a/ui/src/locales/lang/zh_CN/index.ts +++ b/ui/src/locales/lang/zh_CN/index.ts @@ -12,25 +12,55 @@ export default { login: { authentication: '登录认证', ldap: { - title: 'LDAP设置', - address: 'LDAP地址', - serverPlaceholder: '请输入LDAP地址', + title: 'LDAP 设置', + address: 'LDAP 地址', + serverPlaceholder: '请输入LDAP 地址', bindDN: '绑定DN', - bindDNPlaceholder: '请输入绑定DN', + bindDNPlaceholder: '请输入绑定 DN', password: '密码', passwordPlaceholder: '请输入密码', ou: '用户OU', - ouPlaceholder: '请输入用户OU', + ouPlaceholder: '请输入用户 OU', ldap_filter: '用户过滤器', ldap_filterPlaceholder: '请输入用户过滤器', - ldap_mapping: 'LDAP属性映射', - ldap_mappingPlaceholder: '请输入LDAP属性映射', + ldap_mapping: 'LDAP 属性映射', + ldap_mappingPlaceholder: '请输入 LDAP 属性映射', test: '测试连接', - enableAuthentication: '启用LDAP认证', + enableAuthentication: '启用 LDAP 认证', save: '保存', testConnectionSuccess: '测试连接成功', testConnectionFailed: '测试连接失败', saveSuccess: '保存成功', - } - } + }, + cas: { + title: 'CAS 设置', + ldpUri: 'ldpUri', + ldpUriPlaceholder: '请输入ldpUri', + redirectUrl: '回调地址', + redirectUrlPlaceholder: '请输入回调地址', + enableAuthentication: '启用CAS认证', + saveSuccess: '保存成功', + save: '保存', + }, + oidc: { + title: 'OIDC 设置', + authEndpoint: '授权端地址', + authEndpointPlaceholder: '请输入授权端地址', + tokenEndpoint: 'Token端地址', + tokenEndpointPlaceholder: '请输入Token端地址', + userInfoEndpoint: '用户信息端地址', + userInfoEndpointPlaceholder: '请输入用户信息端地址', + clientId: '客户端ID', + clientIdPlaceholder: '请输入客户端ID', + clientSecret: '客户端密钥', + clientSecretPlaceholder: '请输入客户端密钥', + logoutEndpoint: '注销端地址', + logoutEndpointPlaceholder: '请输入注销端地址', + redirectUrl: '回调地址', + redirectUrlPlaceholder: '请输入回调地址', + enableAuthentication: '启用OIDC认证', + }, + jump_tip: '即将跳转至认证源页面进行认证', + jump: '跳转', + }, }; diff --git a/ui/src/router/index.ts b/ui/src/router/index.ts index a8259a2452c..b760c85960f 100644 --- a/ui/src/router/index.ts +++ b/ui/src/router/index.ts @@ -25,6 +25,9 @@ router.beforeEach( const notAuthRouteNameList = ['register', 'login', 'forgot_password', 'reset_password', 'Chat'] if (!notAuthRouteNameList.includes(to.name ? to.name.toString() : '')) { + if (to.query && to.query.token) { + localStorage.setItem('token', to.query.token.toString()) + } const token = user.getToken() if (!token) { next({ diff --git a/ui/src/views/application/index.vue b/ui/src/views/application/index.vue index bce33ba5bc9..74bcfcd0394 100644 --- a/ui/src/views/application/index.vue +++ b/ui/src/views/application/index.vue @@ -189,8 +189,12 @@ function getList() { } onMounted(() => { + console.log(router) getList() }) + + + diff --git a/ui/src/views/authentication/component/OIDC.vue b/ui/src/views/authentication/component/OIDC.vue new file mode 100644 index 00000000000..40089a23dd4 --- /dev/null +++ b/ui/src/views/authentication/component/OIDC.vue @@ -0,0 +1,112 @@ + + + diff --git a/ui/src/views/authentication/index.vue b/ui/src/views/authentication/index.vue index cec1a862718..7c89263e0cd 100644 --- a/ui/src/views/authentication/index.vue +++ b/ui/src/views/authentication/index.vue @@ -20,6 +20,8 @@ import { ref, computed, onMounted } from 'vue' import { useRouter } from 'vue-router' import LDAP from './component/LDAP.vue' +import CAS from './component/CAS.vue' +import OIDC from './component/OIDC.vue' import { t } from '@/locales' import useStore from '@/stores' @@ -32,6 +34,16 @@ const tabList = [ label: t('login.ldap.title'), name: 'LDAP', component: LDAP + }, + { + label: t('login.cas.title'), + name: 'CAS', + component: CAS + }, + { + label: t('login.oidc.title'), + name: 'OIDC', + component: OIDC } ] diff --git a/ui/src/views/login/index.vue b/ui/src/views/login/index.vue index ca2e6de83ff..b2cc5dd9ff5 100644 --- a/ui/src/views/login/index.vue +++ b/ui/src/views/login/index.vue @@ -3,19 +3,19 @@

{{ loginMode || '普通登录' }}