From c575bb76e754a3df3c71bba83c4772af6c9371dc Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 5 May 2026 11:11:43 -0700 Subject: [PATCH 1/4] Fix only using acme.json in dir Ref #2978 --- server/private/lib/acmeCertSync.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/server/private/lib/acmeCertSync.ts b/server/private/lib/acmeCertSync.ts index adf87eed8..03051b11d 100644 --- a/server/private/lib/acmeCertSync.ts +++ b/server/private/lib/acmeCertSync.ts @@ -500,7 +500,30 @@ function findAcmeJsonFiles(dirPath: string): string[] { const fullPath = path.join(dirPath, entry.name); if (entry.isDirectory()) { results.push(...findAcmeJsonFiles(fullPath)); - } else if (entry.isFile() && entry.name === "acme.json") { + } else if (entry.isFile()) { + // check if it is a json file + if (entry.name.endsWith(".json")) { + let raw: string; + try { + raw = fs.readFileSync(fullPath, "utf8"); + } catch (err) { + logger.warn( + `acmeCertSync: could not read file "${fullPath}": ${err}` + ); + continue; + } + + let parsed: any; + try { + parsed = JSON.parse(raw); + } catch (err) { + logger.warn( + `acmeCertSync: could not parse "${fullPath}" as JSON: ${err}` + ); + continue; + } + } + results.push(fullPath); } } From 3b232bcc58f28dfbc122ff17042fd3aa53de206f Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Tue, 5 May 2026 11:31:58 -0700 Subject: [PATCH 2/4] set orgId to undefined --- src/components/SmartLoginOrgSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SmartLoginOrgSelector.tsx b/src/components/SmartLoginOrgSelector.tsx index 656cb1ca6..79a43782e 100644 --- a/src/components/SmartLoginOrgSelector.tsx +++ b/src/components/SmartLoginOrgSelector.tsx @@ -147,7 +147,7 @@ export default function SmartLoginOrgSelector({ const response = await generateOidcUrlProxy( idpId, safeRedirect, - orgId, + undefined, forceLogin ); From 18f6e0f75dc3eea4730ec5e3e62f718706cdae09 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Tue, 5 May 2026 11:52:31 -0700 Subject: [PATCH 3/4] add subscribed check back --- server/routers/idp/validateOidcCallback.ts | 27 ++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/server/routers/idp/validateOidcCallback.ts b/server/routers/idp/validateOidcCallback.ts index fc8e9b3da..a1ac3607c 100644 --- a/server/routers/idp/validateOidcCallback.ts +++ b/server/routers/idp/validateOidcCallback.ts @@ -333,23 +333,16 @@ export async function validateOidcCallback( .innerJoin(orgs, eq(orgs.orgId, idpOrg.orgId)); allOrgs = idpOrgs.map((o) => o.orgs); - // for (const org of allOrgs) { - // const subscribed = await isSubscribed( - // org.orgId, - // tierMatrix.autoProvisioning - // ); - // if (!subscribed) { - // // filter out the org - // allOrgs = allOrgs.filter((o) => o.orgId !== org.orgId); - - // // return next( - // // createHttpError( - // // HttpCode.FORBIDDEN, - // // "This organization's current plan does not support this feature." - // // ) - // // ); - // } - // } + for (const org of allOrgs) { + const subscribed = await isSubscribed( + org.orgId, + tierMatrix.autoProvisioning + ); + if (!subscribed) { + // filter out the org + allOrgs = allOrgs.filter((o) => o.orgId !== org.orgId); + } + } } else { allOrgs = await db.select().from(orgs); } From e06dda27cb7607fbd7e4783216d0590a4691eddf Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Tue, 5 May 2026 12:10:55 -0700 Subject: [PATCH 4/4] dont wait rebuild --- server/routers/idp/validateOidcCallback.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/routers/idp/validateOidcCallback.ts b/server/routers/idp/validateOidcCallback.ts index a1ac3607c..71a681e51 100644 --- a/server/routers/idp/validateOidcCallback.ts +++ b/server/routers/idp/validateOidcCallback.ts @@ -483,7 +483,14 @@ export async function validateOidcCallback( } } - await calculateUserClientsForOrgs(existingUser.userId); + calculateUserClientsForOrgs(existingUser.userId).catch( + (err) => { + logger.error( + "Error calculating user clients after removing all orgs for user with no valid IdP mappings", + { error: err } + ); + } + ); return next( createHttpError(