Skip to content

Commit 04445f0

Browse files
hotlongCopilot
andcommitted
fix(service-cloud): mirror auth-proxy /config + /bootstrap-status fix
Service-cloud has a parallel copy of auth-proxy-plugin used by the cloud preset. Apply the same /config and /bootstrap-status short- circuits there so the platform-SSO button renders on per-project deployments routed through the cloud control plane too. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 980a8ae commit 04445f0

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

packages/services/service-cloud/src/auth-proxy-plugin.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,44 @@ export class AuthProxyPlugin implements Plugin {
116116
try { authSvc = (projectKernel as any).getService?.('auth'); } catch { /* ignore */ }
117117
}
118118

119+
// Custom non-better-auth endpoints. better-auth has no
120+
// /config or /bootstrap-status route, so without these
121+
// short-circuits the request would fall through to the
122+
// better-auth handler and 404. The Account SPA needs
123+
// /config to render the "Continue with ObjectStack"
124+
// platform SSO button via SocialSignInButtons.
125+
const subPath = url.pathname.startsWith(AUTH_PREFIX + '/')
126+
? url.pathname.substring(AUTH_PREFIX.length + 1)
127+
: '';
128+
if (c.req.method === 'GET' && (subPath === 'config' || subPath === 'bootstrap-status')) {
129+
if (subPath === 'config') {
130+
try {
131+
const config = typeof authSvc?.getPublicConfig === 'function'
132+
? authSvc.getPublicConfig()
133+
: null;
134+
if (config) {
135+
return c.json({ success: true, data: config });
136+
}
137+
return c.json({ success: false, error: { code: 'auth_config_unavailable', message: 'AuthManager has no getPublicConfig()' } }, 503);
138+
} catch (e: any) {
139+
return c.json({ success: false, error: { code: 'auth_config_error', message: String(e?.message ?? e) } }, 500);
140+
}
141+
}
142+
// bootstrap-status
143+
try {
144+
const dataEngine = typeof authSvc?.getDataEngine === 'function'
145+
? authSvc.getDataEngine()
146+
: null;
147+
if (!dataEngine || typeof dataEngine.count !== 'function') {
148+
return c.json({ hasOwner: true });
149+
}
150+
const count = await dataEngine.count('sys_user', {});
151+
return c.json({ hasOwner: (count ?? 0) > 0 });
152+
} catch {
153+
return c.json({ hasOwner: true });
154+
}
155+
}
156+
119157
const fn = await resolveAuthHandler(authSvc);
120158
if (!fn) {
121159
return c.json({ error: 'auth_service_unavailable', projectId }, 503);

0 commit comments

Comments
 (0)