Skip to content

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

fix: fallback to global idps for login (#19987)

ecmadaoaafa7efed7e4
diff --git a/backend/api/v1/idp_service.go b/backend/api/v1/idp_service.go
index aa76d7f0ac..52a7a66e4a 100644
--- a/backend/api/v1/idp_service.go
+++ b/backend/api/v1/idp_service.go
@@ -57,26 +57,12 @@ func (s *IdentityProviderService) ListIdentityProviders(ctx context.Context, req
// Workspace resolution order: request.parent -> JWT context -> default workspace (self-hosted).
var identityProviders []*store.IdentityProviderMessage
- var workspaceID string
if req.Msg.Parent != "" {
- id, err := common.GetWorkspaceID(req.Msg.Parent)
+ workspaceID, err := common.GetWorkspaceID(req.Msg.Parent)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
- workspaceID = id
- }
- if workspaceID == "" {
- workspaceID = common.GetWorkspaceIDFromContext(ctx)
- }
- if workspaceID == "" && !s.profile.SaaS {
- defaultWorkspaceID, err := s.store.GetWorkspaceID(ctx)
- if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to find workspace id"))
- }
- workspaceID = defaultWorkspaceID
- }
- if workspaceID != "" {
wsIDPs, err := s.store.ListIdentityProviders(ctx, &store.FindIdentityProviderMessage{Workspace: &workspaceID})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vue
index 4dfef66c7d..b97c46c657 100644
--- a/frontend/src/views/auth/Signin.vue
+++ b/frontend/src/views/auth/Signin.vue
@@ -286,15 +286,21 @@ watchEffect(() => {
onMounted(async () => {
// If a workspace is specified in the query, fetch workspace-scoped actuator and IDPs.
const workspaceID = route.query["workspace"] as string | undefined;
- const workspaceName = workspaceID ? `workspaces/${workspaceID}` : undefined;
+ const workspaceNameFromQuery = workspaceID
+ ? `workspaces/${workspaceID}`
+ : undefined;
+ const workspaceName =
+ actuatorStore.workspaceResourceName || workspaceNameFromQuery;
+
try {
- const promises: Promise<unknown>[] = [
+ const [idpList, _] = await Promise.all([
identityProviderStore.fetchIdentityProviderList(workspaceName),
- ];
- if (workspaceName) {
- promises.push(actuatorStore.fetchServerInfo(workspaceName));
+ actuatorStore.fetchServerInfo(workspaceName),
+ ]);
+ if (idpList.length === 0 && workspaceName) {
+ // fallback to global IDPs
+ await identityProviderStore.fetchIdentityProviderList();
}
- await Promise.all(promises);
} catch (error) {
pushNotification({
module: "bytebase",