diff --git a/packages/frontend-2/components/settings/workspaces/security/sso/Form.vue b/packages/frontend-2/components/settings/workspaces/security/sso/Form.vue index 6ca2970d01..032cbb3828 100644 --- a/packages/frontend-2/components/settings/workspaces/security/sso/Form.vue +++ b/packages/frontend-2/components/settings/workspaces/security/sso/Form.vue @@ -66,6 +66,11 @@ import { useMixpanel } from '~/lib/core/composables/mp' const props = defineProps<{ workspaceSlug: string + providerInfo?: { + providerName: string + clientId: string + issuerUrl: string + } }>() defineEmits<{ @@ -78,10 +83,10 @@ const { challenge } = useLoginOrRegisterUtils() const mixpanel = useMixpanel() const formData = ref({ - providerName: '', - clientId: '', + providerName: props.providerInfo?.providerName || '', + clientId: props.providerInfo?.clientId || '', clientSecret: '', - issuerUrl: '' + issuerUrl: props.providerInfo?.issuerUrl || '' }) const { handleSubmit } = useForm() @@ -112,4 +117,19 @@ const onSubmit = handleSubmit(() => { external: true }) }) + +watch( + () => props.providerInfo, + (newInfo) => { + if (newInfo) { + formData.value = { + ...formData.value, + providerName: newInfo.providerName, + clientId: newInfo.clientId, + issuerUrl: newInfo.issuerUrl + } + } + }, + { immediate: true } +) diff --git a/packages/frontend-2/components/settings/workspaces/security/sso/Wrapper.vue b/packages/frontend-2/components/settings/workspaces/security/sso/Wrapper.vue index 9c1159b76d..a8c301e362 100644 --- a/packages/frontend-2/components/settings/workspaces/security/sso/Wrapper.vue +++ b/packages/frontend-2/components/settings/workspaces/security/sso/Wrapper.vue @@ -75,6 +75,7 @@ @@ -116,6 +117,7 @@ @@ -235,4 +237,64 @@ const redirectUrl = computed(() => { const goToBilling = () => { goToWorkspaceMenuItem(props.workspace.id, SettingMenuKeys.Workspace.Billing) } +const route = useRoute() + +const errorProviderInfo = ref< + | { + providerName: string + clientId: string + issuerUrl: string + } + | undefined +>(undefined) + +const router = useRouter() +const { triggerNotification } = useGlobalToast() + +onMounted(() => { + const providerName = route.query?.providerName as string + const clientId = route.query?.clientId as string + const issuerUrl = route.query?.issuerUrl as string + const ssoError = route.query?.ssoError as string + const ssoValidationSuccess = route.query?.ssoValidationSuccess + + // Handle error notifications + if (ssoValidationSuccess === 'true') { + triggerNotification({ + type: ToastNotificationType.Success, + title: 'SSO Configuration Successful', + description: 'Your SSO settings have been successfully configured.' + }) + } else if (ssoValidationSuccess === 'false' || ssoError) { + triggerNotification({ + type: ToastNotificationType.Danger, + title: 'SSO Configuration Error', + description: ssoError + ? decodeURIComponent(ssoError) + : 'SSO settings validation failed' + }) + } + + // Handle provider info if present + if (providerName && clientId && issuerUrl) { + errorProviderInfo.value = { + providerName, + clientId, + issuerUrl + } + isFormVisible.value = true + } + + // Clean up URL params + router.replace({ + query: { + ...route.query, + ssoError: undefined, + providerName: undefined, + clientId: undefined, + issuerUrl: undefined, + ssoValidationSuccess: undefined + } + }) +}) diff --git a/packages/frontend-2/components/workspace/ProjectList.vue b/packages/frontend-2/components/workspace/ProjectList.vue index 595d179c6f..1a2ea75005 100644 --- a/packages/frontend-2/components/workspace/ProjectList.vue +++ b/packages/frontend-2/components/workspace/ProjectList.vue @@ -98,6 +98,7 @@ v-model:open="showSettingsDialog" :target-menu-item="settingsDialogTarget" :target-workspace-id="workspace.id" + :sso-provider-info="ssoProviderInfo" /> { validateCheckoutSession(queryResult.data.workspaceBySlug.id) } }) + +const ssoProviderInfo = ref<{ + providerName: string + clientId: string + issuerUrl: string +} | null>(null) + +onMounted(() => { + const ssoValidationSuccess = route.query?.ssoValidationSuccess + + if (ssoValidationSuccess) { + // Open security settings dialog + onShowSettingsDialog(SettingMenuKeys.Workspace.Security) + } +}) diff --git a/packages/frontend-2/middleware/requiresWorkspacesEnabled.ts b/packages/frontend-2/middleware/requiresWorkspacesEnabled.ts index 7185cd77f3..5d7098ca7e 100644 --- a/packages/frontend-2/middleware/requiresWorkspacesEnabled.ts +++ b/packages/frontend-2/middleware/requiresWorkspacesEnabled.ts @@ -1,40 +1,9 @@ -export default defineNuxtRouteMiddleware((to) => { +export default defineNuxtRouteMiddleware(() => { const isWorkspacesEnabled = useIsWorkspacesEnabled() // If workspaces are enabled, continue as normal if (isWorkspacesEnabled.value) return - // If there's an SSO error, redirect to the main workspace page with provider details - const hasSsoError = to.query.ssoError || to.query.ssoValidationSuccess === 'false' - - if (hasSsoError) { - // Collect provider details from URL - const providerDetails = { - providerName: to.query.providerName, - clientId: to.query.clientId, - issuerUrl: to.query.issuerUrl - } - - // Only include non-null values - const queryParams = Object.fromEntries( - Object.entries(providerDetails).filter(([_, value]) => value) - ) - - // Add the error message - if (to.query.ssoError) { - queryParams.error = to.query.ssoError as string - } - - // Add a flag to open the settings dialog - queryParams.openSettingsDialog = 'true' - - // Redirect to the main workspace page - return navigateTo({ - path: `/workspaces/${to.params.slug}`, - query: queryParams - }) - } - // Otherwise, block navigation return abortNavigation( createError({ diff --git a/packages/frontend-2/pages/workspaces/[slug]/index.vue b/packages/frontend-2/pages/workspaces/[slug]/index.vue index bdf6935256..2260cd8f70 100644 --- a/packages/frontend-2/pages/workspaces/[slug]/index.vue +++ b/packages/frontend-2/pages/workspaces/[slug]/index.vue @@ -1,26 +1,5 @@