Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: hide login buttons with vcs (#4729)

boojack2b3b5af8a85c
diff --git a/frontend/src/utils/idp.ts b/frontend/src/utils/idp.ts
index e4daded8b0..5d4dcfe568 100644
--- a/frontend/src/utils/idp.ts
+++ b/frontend/src/utils/idp.ts
@@ -60,7 +60,7 @@ export const identityProviderTemplateList: IdentityProviderTemplate[] = [
fieldMapping: {
identifier: "username",
displayName: "name",
- email: "public_email",
+ email: "email",
},
},
},
diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vue
index fcd3dc94d1..81e1906528 100644
--- a/frontend/src/views/auth/Signin.vue
+++ b/frontend/src/views/auth/Signin.vue
@@ -6,51 +6,7 @@
alt="Bytebase"
/>
- <div class="mt-8 mb-3">
- <template
- v-for="authProvider in authProviderList"
- :key="authProvider.type"
- >
- <button
- type="button"
- class="btn-normal flex justify-center w-full h-10 mb-2 tooltip-wrapper"
- :disabled="!hasSSOFeature"
- @click="trySigninWithOAuth(authProvider)"
- >
- <img
- class="w-5 mr-1"
- :src="AuthProviderConfig[authProvider.type].iconPath"
- />
- <span class="text-center font-semibold align-middle">
- {{
- authProviderList.length == 1
- ? authProvider.type.includes("GITHUB")
- ? $t("auth.sign-in.github")
- : $t("auth.sign-in.gitlab")
- : authProvider.name
- }}
- </span>
- </button>
- </template>
-
- <template v-if="authProviderList.length == 0">
- <button
- disabled
- type="button"
- class="btn-normal flex justify-center w-full h-10 mb-2"
- >
- <img
- class="w-5 mr-1"
- :src="AuthProviderConfig['GITLAB_SELF_HOST'].iconPath"
- />
- <span class="text-center font-semibold align-middle">
- {{ $t("auth.sign-in.gitlab-oauth") }}
- </span>
- </button>
- </template>
- </div>
-
- <div class="mt-4">
+ <div class="mt-8">
<form class="space-y-6" @submit.prevent="trySignin">
<div>
<label
@@ -188,11 +144,7 @@
import { computed, onMounted, onUnmounted, reactive, watch } from "vue";
import { useRouter } from "vue-router";
import { storeToRefs } from "pinia";
-import {
- AuthProvider,
- OAuthWindowEventPayload,
- openWindowForOAuth,
-} from "@/types";
+import { AuthProvider, OAuthWindowEventPayload } from "@/types";
import { isValidEmail, openWindowForSSO } from "@/utils";
import {
featureToRef,
@@ -206,19 +158,6 @@ import {
} from "@/types/proto/v1/idp_service";
import AuthFooter from "./AuthFooter.vue";
-const AuthProviderConfig = {
- GITLAB_SELF_HOST: {
- apiPath: "oauth/authorize",
- // see https://vitejs.cn/guide/assets.html#the-public-directory for static resource import during run time
- iconPath: new URL("../../assets/gitlab-logo.svg", import.meta.url).href,
- },
- GITHUB_COM: {
- apiPath: "login/oauth/authorize",
- // see https://vitejs.cn/guide/assets.html#the-public-directory for static resource import during run time
- iconPath: new URL("../../assets/github-logo.svg", import.meta.url).href,
- },
-};
-
interface LocalState {
email: string;
password: string;
@@ -232,8 +171,6 @@ const authStore = useAuthStore();
const identityProviderStore = useIdentityProviderStore();
const router = useRouter();
-const { authProviderList } = storeToRefs(authStore);
-
const state = reactive<LocalState>({
email: "",
password: "",
@@ -264,13 +201,6 @@ onMounted(async () => {
});
onUnmounted(() => {
- if (state.activeAuthProvider) {
- window.removeEventListener(
- `bb.oauth.signin.${state.activeAuthProvider?.type}-${state.activeAuthProvider?.applicationId}`,
- loginWithVCSEventListener,
- false
- );
- }
if (state.activeIdentityProvider) {
window.removeEventListener(
`bb.oauth.signin.${state.activeIdentityProvider.name}`,
@@ -296,42 +226,6 @@ watch(
}
);
-watch(
- () => state.activeAuthProvider,
- (newValue, oldValue) => {
- window.removeEventListener(
- `bb.oauth.signin.${oldValue?.type}-${oldValue?.applicationId}`,
- loginWithVCSEventListener,
- false
- );
- window.addEventListener(
- `bb.oauth.signin.${newValue?.type}-${newValue?.applicationId}`,
- loginWithVCSEventListener,
- false
- );
- }
-);
-
-const loginWithVCSEventListener = (event: Event) => {
- if (!state.activeAuthProvider) {
- return;
- }
-
- const payload = (event as CustomEvent).detail as OAuthWindowEventPayload;
- if (payload.error) {
- return;
- }
- authStore
- .vcsLogin(state.activeAuthProvider.type, {
- vcsId: state.activeAuthProvider.id,
- name: state.activeAuthProvider.name,
- code: payload.code,
- })
- .then(() => {
- router.push("/");
- });
-};
-
const loginWithIdentityProviderEventListener = async (event: Event) => {
if (!state.activeIdentityProvider) {
return;
@@ -373,22 +267,6 @@ const trySignin = async () => {
router.push("/");
};
-const trySigninWithOAuth = (authProvider: AuthProvider) => {
- if (authProvider.type == "BYTEBASE") {
- return;
- }
-
- state.activeAuthProvider = authProvider;
- openWindowForOAuth(
- `${authProvider.instanceUrl}/${
- AuthProviderConfig[authProvider.type].apiPath
- }`,
- authProvider.applicationId,
- "bb.oauth.signin",
- authProvider.type
- );
-};
-
const trySigninWithIdentityProvider = async (
identityProvider: IdentityProvider
) => {