mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-05 20:21:19 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fd66cef0f | |||
| b7c0669c38 | |||
| 835a30cffe | |||
| 18b90da6ab | |||
| efe22c889c |
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM node:24-alpine
|
FROM node:25-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,12 @@
|
|||||||
*
|
*
|
||||||
* This file is not licensed under the AGPLv3.
|
* This file is not licensed under the AGPLv3.
|
||||||
*/
|
*/
|
||||||
import { certificates, db, domains, orgDomains } from "@server/db";
|
import { certificates, db, domainNamespaces, domains, orgDomains } from "@server/db";
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { type GetBatchedCertificateResponse } from "@server/routers/certificates/types";
|
import { type GetBatchedCertificateResponse } from "@server/routers/certificates/types";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { and, eq, inArray, or } from "drizzle-orm";
|
import { and, eq, inArray, isNotNull, or } from "drizzle-orm";
|
||||||
import { NextFunction, Request, Response } from "express";
|
import { NextFunction, Request, Response } from "express";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
@@ -63,14 +63,28 @@ async function query(orgId: string, domainList: string[]) {
|
|||||||
})
|
})
|
||||||
.from(certificates)
|
.from(certificates)
|
||||||
.innerJoin(domains, eq(certificates.domainId, domains.domainId))
|
.innerJoin(domains, eq(certificates.domainId, domains.domainId))
|
||||||
.innerJoin(
|
.leftJoin(
|
||||||
orgDomains,
|
orgDomains,
|
||||||
and(
|
and(
|
||||||
eq(domains.domainId, orgDomains.domainId),
|
eq(domains.domainId, orgDomains.domainId),
|
||||||
eq(orgDomains.orgId, orgId)
|
eq(orgDomains.orgId, orgId)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.where(and(inArray(certificates.domain, domainList)));
|
.leftJoin(
|
||||||
|
domainNamespaces,
|
||||||
|
eq(domains.domainId, domainNamespaces.domainId)
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
inArray(certificates.domain, domainList),
|
||||||
|
// Namespace domains are shared across all orgs, so they skip
|
||||||
|
// the org-ownership check (mirrors verifyCertificateAccess).
|
||||||
|
or(
|
||||||
|
isNotNull(orgDomains.orgId),
|
||||||
|
isNotNull(domainNamespaces.domainNamespaceId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// All non resolved domain certificates might be `ns` or `wildcard`,
|
// All non resolved domain certificates might be `ns` or `wildcard`,
|
||||||
// which means exact domain certificates do not exist
|
// which means exact domain certificates do not exist
|
||||||
@@ -110,19 +124,27 @@ async function query(orgId: string, domainList: string[]) {
|
|||||||
})
|
})
|
||||||
.from(certificates)
|
.from(certificates)
|
||||||
.innerJoin(domains, eq(certificates.domainId, domains.domainId))
|
.innerJoin(domains, eq(certificates.domainId, domains.domainId))
|
||||||
.innerJoin(
|
.leftJoin(
|
||||||
orgDomains,
|
orgDomains,
|
||||||
and(
|
and(
|
||||||
eq(domains.domainId, orgDomains.domainId),
|
eq(domains.domainId, orgDomains.domainId),
|
||||||
eq(orgDomains.orgId, orgId)
|
eq(orgDomains.orgId, orgId)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.leftJoin(
|
||||||
|
domainNamespaces,
|
||||||
|
eq(domains.domainId, domainNamespaces.domainId)
|
||||||
|
)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(certificates.wildcard, true),
|
eq(certificates.wildcard, true),
|
||||||
or(
|
or(
|
||||||
inArray(certificates.domain, [...domainLevelDownSet]),
|
inArray(certificates.domain, [...domainLevelDownSet]),
|
||||||
inArray(certificates.domain, [...wildcardDomainSet])
|
inArray(certificates.domain, [...wildcardDomainSet])
|
||||||
|
),
|
||||||
|
or(
|
||||||
|
isNotNull(orgDomains.orgId),
|
||||||
|
isNotNull(domainNamespaces.domainNamespaceId)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export function useCertificate({
|
|||||||
let certError: string | null = null;
|
let certError: string | null = null;
|
||||||
if (restartCert.isError) {
|
if (restartCert.isError) {
|
||||||
certError = "Failed to restart";
|
certError = "Failed to restart";
|
||||||
} else if (isError || initialCertValue === null) {
|
} else if (isError || (!isLoading && data === null)) {
|
||||||
// Null value means failed to get the certificate
|
// Null value means failed to get the certificate
|
||||||
certError = "Failed";
|
certError = "Failed";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user