From 237dd8c2096918cb91e90ee0a975ede96abc60a5 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Mon, 17 Feb 2025 19:00:34 +0800 Subject: [PATCH] refactor: oidc add scope --- ui/src/locales/lang/en-US/views/system.ts | 1 + ui/src/locales/lang/zh-CN/views/system.ts | 1 + ui/src/locales/lang/zh-Hant/views/system.ts | 1 + ui/src/views/authentication/component/OIDC.vue | 11 +++++++++++ ui/src/views/login/index.vue | 3 ++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ui/src/locales/lang/en-US/views/system.ts b/ui/src/locales/lang/en-US/views/system.ts index 305b13f7a..bc4a9075f 100644 --- a/ui/src/locales/lang/en-US/views/system.ts +++ b/ui/src/locales/lang/en-US/views/system.ts @@ -40,6 +40,7 @@ export default { userInfoEndpointPlaceholder: 'Please enter user information endpoint', clientId: 'Client ID', clientIdPlaceholder: 'Please enter client ID', + scopePlaceholder: 'Please enter scope', clientSecret: 'Client Secret', clientSecretPlaceholder: 'Please enter client secret', logoutEndpoint: 'Logout Endpoint', diff --git a/ui/src/locales/lang/zh-CN/views/system.ts b/ui/src/locales/lang/zh-CN/views/system.ts index f11b95c20..9ce23d90d 100644 --- a/ui/src/locales/lang/zh-CN/views/system.ts +++ b/ui/src/locales/lang/zh-CN/views/system.ts @@ -38,6 +38,7 @@ export default { tokenEndpointPlaceholder: '请输入 Token 端地址', userInfoEndpoint: '用户信息端地址', userInfoEndpointPlaceholder: '请输入用户信息端地址', + scopePlaceholder: '请输入连接范围', clientId: '客户端 ID', clientIdPlaceholder: '请输入客户端 ID', clientSecret: '客户端密钥', diff --git a/ui/src/locales/lang/zh-Hant/views/system.ts b/ui/src/locales/lang/zh-Hant/views/system.ts index de185dfee..10259390b 100644 --- a/ui/src/locales/lang/zh-Hant/views/system.ts +++ b/ui/src/locales/lang/zh-Hant/views/system.ts @@ -40,6 +40,7 @@ export default { userInfoEndpoint: '使用者資訊端位址', userInfoEndpointPlaceholder: '請輸入使用者資訊端位址', clientId: '用戶端 ID', + scopePlaceholder: '請輸入連線範圍', clientIdPlaceholder: '請輸入用戶端 ID', clientSecret: '用戶端密鑰', clientSecretPlaceholder: '請輸入用戶端密鑰', diff --git a/ui/src/views/authentication/component/OIDC.vue b/ui/src/views/authentication/component/OIDC.vue index 5c94dd432..a8ed1d98e 100644 --- a/ui/src/views/authentication/component/OIDC.vue +++ b/ui/src/views/authentication/component/OIDC.vue @@ -36,6 +36,9 @@ :placeholder="$t('views.system.authentication.oidc.userInfoEndpointPlaceholder')" /> + + + ({ authEndpoint: '', tokenEndpoint: '', userInfoEndpoint: '', + scope: '', clientId: '', clientSecret: '', redirectUrl: '' @@ -127,6 +131,13 @@ const rules = reactive>({ trigger: 'blur' } ], + 'config_data.scope': [ + { + required: true, + message: t('views.system.authentication.oidc.scopePlaceholder'), + trigger: 'blur' + } + ], 'config_data.clientId': [ { required: true, diff --git a/ui/src/views/login/index.vue b/ui/src/views/login/index.vue index 85145db85..765264117 100644 --- a/ui/src/views/login/index.vue +++ b/ui/src/views/login/index.vue @@ -177,7 +177,8 @@ function redirectAuth(authType: string) { } } if (authType === 'OIDC') { - url = `${config.authEndpoint}?client_id=${config.clientId}&redirect_uri=${redirectUrl}&response_type=code&scope=openid+profile+email` + const scope = config.scope || 'openid+profile+email' + url = `${config.authEndpoint}?client_id=${config.clientId}&redirect_uri=${redirectUrl}&response_type=code&scope=${scope}` } if (authType === 'OAuth2') { url =