diff --git a/web/berry/src/config.js b/web/berry/src/config.js
index eeeda99a..b5eaa831 100644
--- a/web/berry/src/config.js
+++ b/web/berry/src/config.js
@@ -22,7 +22,11 @@ const config = {
turnstile_site_key: '',
version: '',
wechat_login: false,
- wechat_qrcode: ''
+ wechat_qrcode: '',
+ oauth2: false,
+ oauth2_app_id: '',
+ oauth2_authorization_endpoint: '',
+ oauth2_token_endpoint: '',
}
};
diff --git a/web/berry/src/utils/common.js b/web/berry/src/utils/common.js
index d74d032e..a471c2cf 100644
--- a/web/berry/src/utils/common.js
+++ b/web/berry/src/utils/common.js
@@ -98,6 +98,21 @@ export async function onLarkOAuthClicked(lark_client_id) {
window.open(`https://open.feishu.cn/open-apis/authen/v1/index?redirect_uri=${redirect_uri}&app_id=${lark_client_id}&state=${state}`);
}
+export async function onOAuth2Clicked(auth_url, client_id, openInNewTab = false) {
+ const state = await getOAuthState();
+ if (!state) return;
+ const redirect_uri = `${window.location.origin}/oauth/oidc`;
+ const response_type = "code";
+ const scope = "profile email";
+ const url = `${auth_url}?client_id=${client_id}&redirect_uri=${redirect_uri}&response_type=${response_type}&scope=${scope}&state=${state}`;
+ if (openInNewTab) {
+ window.open(url);
+ } else
+ {
+ window.location.href = url;
+ }
+}
+
export function isAdmin() {
let user = localStorage.getItem('user');
if (!user) return false;
diff --git a/web/berry/src/views/Authentication/AuthForms/AuthLogin.js b/web/berry/src/views/Authentication/AuthForms/AuthLogin.js
index bc7a35c0..582fdfbe 100644
--- a/web/berry/src/views/Authentication/AuthForms/AuthLogin.js
+++ b/web/berry/src/views/Authentication/AuthForms/AuthLogin.js
@@ -36,7 +36,7 @@ import VisibilityOff from '@mui/icons-material/VisibilityOff';
import Github from 'assets/images/icons/github.svg';
import Wechat from 'assets/images/icons/wechat.svg';
import Lark from 'assets/images/icons/lark.svg';
-import { onGitHubOAuthClicked, onLarkOAuthClicked } from 'utils/common';
+import { onGitHubOAuthClicked, onLarkOAuthClicked, onOAuth2Clicked } from 'utils/common';
// ============================|| FIREBASE - LOGIN ||============================ //
@@ -50,7 +50,7 @@ const LoginForm = ({ ...others }) => {
// const [checked, setChecked] = useState(true);
let tripartiteLogin = false;
- if (siteInfo.github_oauth || siteInfo.wechat_login || siteInfo.lark_client_id) {
+ if (siteInfo.github_oauth || siteInfo.wechat_login || siteInfo.lark_client_id || siteInfo.oauth2) {
tripartiteLogin = true;
}
@@ -145,6 +145,29 @@ const LoginForm = ({ ...others }) => {
)}
+ {siteInfo.oauth2 && (
+
+
+
+
+
+ )}