From 1106bcabf2ac2e482f6eb3d33c7f623536c6f6da Mon Sep 17 00:00:00 2001 From: OnEvent Date: Thu, 8 Aug 2024 16:51:01 +0800 Subject: [PATCH] feat: add the ui for configuring the third-party standard OAuth2.0/OIDC. - update SystemSetting.js - add setup ui - add configuration --- .../views/Setting/component/SystemSetting.js | 116 +++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/web/berry/src/views/Setting/component/SystemSetting.js b/web/berry/src/views/Setting/component/SystemSetting.js index 6f82fb26..417f4fc9 100644 --- a/web/berry/src/views/Setting/component/SystemSetting.js +++ b/web/berry/src/views/Setting/component/SystemSetting.js @@ -33,6 +33,11 @@ const SystemSetting = () => { GitHubClientSecret: '', LarkClientId: '', LarkClientSecret: '', + OAuth2Enabled: '', + OAuth2AppId: '', + OAuth2AppSecret: '', + OAuth2AuthorizationEndpoint: '', + OAuth2TokenEndpoint: '', Notice: '', SMTPServer: '', SMTPPort: '', @@ -142,8 +147,13 @@ const SystemSetting = () => { name === 'MessagePusherAddress' || name === 'MessagePusherToken' || name === 'LarkClientId' || - name === 'LarkClientSecret' - ) { + name === 'LarkClientSecret' || + name === 'OAuth2AppId' || + name === 'OAuth2AppSecret' || + name === 'OAuth2AuthorizationEndpoint' || + name === 'OAuth2TokenEndpoint' + ) + { setInputs((inputs) => ({ ...inputs, [name]: value })); } else { await updateOption(name, value); @@ -225,6 +235,28 @@ const SystemSetting = () => { } }; + const submitOAuth2 = async () => { + const OAuth2Config = { + OAuth2AppId: inputs.OAuth2AppId, + OAuth2AppSecret: inputs.OAuth2AppSecret, + OAuth2AuthorizationEndpoint: inputs.OAuth2AuthorizationEndpoint, + OAuth2TokenEndpoint: inputs.OAuth2TokenEndpoint + }; + console.log(OAuth2Config); + if (originInputs['OAuth2AppId'] !== inputs.OAuth2AppId) { + await updateOption('OAuth2AppId', inputs.OAuth2AppId); + } + if (originInputs['OAuth2AppSecret'] !== inputs.OAuth2AppSecret && inputs.OAuth2AppSecret !== '') { + await updateOption('OAuth2AppSecret', inputs.OAuth2AppSecret); + } + if (originInputs['OAuth2AuthorizationEndpoint'] !== inputs.OAuth2AuthorizationEndpoint) { + await updateOption('OAuth2AuthorizationEndpoint', inputs.OAuth2AuthorizationEndpoint); + } + if (originInputs['OAuth2TokenEndpoint'] !== inputs.OAuth2TokenEndpoint) { + await updateOption('OAuth2TokenEndpoint', inputs.OAuth2TokenEndpoint); + } + }; + return ( <> @@ -616,6 +648,86 @@ const SystemSetting = () => { + + + 用以支持通过第三方 OAuth2 登录,例如 Okta、Auth0 或自建的兼容 OAuth2.0 协议的 IdP 等 + + } + > + + + + 主页链接填 { inputs.ServerAddress } + ,重定向 URL 填 { `${ inputs.ServerAddress }/oauth/oidc` } + + + + + App ID + + + + + + App Secret + + + + + + 授权地址 + + + + + + 认证地址 + + + + + + + + +