Skip to content

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

chore: add redirect to sso login (#5491)

boojack2a607eba275c
diff --git a/frontend/src/utils/sso.ts b/frontend/src/utils/sso.ts
index 44dad6d803..5bd7269884 100644
--- a/frontend/src/utils/sso.ts
+++ b/frontend/src/utils/sso.ts
@@ -13,7 +13,8 @@ const defaultOIDCScopes = ["openid", "profile", "email"];
export async function openWindowForSSO(
identityProvider: IdentityProvider,
- openAsPopup = true
+ openAsPopup = true,
+ redirect = ""
) {
const stateQueryParameter = `bb.oauth.signin.${identityProvider.name}`;
sessionStorage.setItem(OAuthStateSessionKey, stateQueryParameter);
@@ -23,6 +24,7 @@ export async function openWindowForSSO(
JSON.stringify({
identityProviderName: identityProvider.name,
openAsPopup,
+ redirect,
})
);
diff --git a/frontend/src/views/OAuthCallback.vue b/frontend/src/views/OAuthCallback.vue
index c75f06642f..4499547c50 100644
--- a/frontend/src/views/OAuthCallback.vue
+++ b/frontend/src/views/OAuthCallback.vue
@@ -97,11 +97,11 @@ const triggerAuthCallback = async () => {
name: "auth.mfa",
query: {
mfaTempToken,
- redirect: "",
+ redirect: ssoConfig.redirect || "",
},
});
} else {
- router.push("/");
+ router.push(ssoConfig.redirect || "/");
}
}
} else if (
diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vue
index d75b824baf..d3665f70b4 100644
--- a/frontend/src/views/auth/Signin.vue
+++ b/frontend/src/views/auth/Signin.vue
@@ -141,7 +141,7 @@
<script lang="ts" setup>
import { computed, onMounted, reactive } from "vue";
-import { useRouter } from "vue-router";
+import { useRoute, useRouter } from "vue-router";
import { storeToRefs } from "pinia";
import { isValidEmail, openWindowForSSO } from "@/utils";
import {
@@ -158,10 +158,11 @@ interface LocalState {
showPassword: boolean;
}
+const router = useRouter();
+const route = useRoute();
const actuatorStore = useActuatorStore();
const authStore = useAuthStore();
const identityProviderStore = useIdentityProviderStore();
-const router = useRouter();
const state = reactive<LocalState>({
email: "",
@@ -215,7 +216,7 @@ const trySignin = async () => {
name: "auth.mfa",
query: {
mfaTempToken,
- redirect: "",
+ redirect: route.query.redirect as string,
},
});
} else {
@@ -226,6 +227,10 @@ const trySignin = async () => {
const trySigninWithIdentityProvider = async (
identityProvider: IdentityProvider
) => {
- await openWindowForSSO(identityProvider, false);
+ await openWindowForSSO(
+ identityProvider,
+ false,
+ route.query.redirect as string
+ );
};
</script>