Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot] 152d2fb1d6 Bump brace-expansion
Bumps  and [brace-expansion](https://github.com/juliangruber/brace-expansion). These dependencies needed to be updated together.

Updates `brace-expansion` from 5.0.6 to 5.0.9
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v5.0.6...v5.0.9)

Updates `brace-expansion` from 1.1.14 to 1.1.18
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v5.0.6...v5.0.9)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 5.0.9
  dependency-type: indirect
- dependency-name: brace-expansion
  dependency-version: 1.1.18
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-04 05:33:39 +00:00
5 changed files with 18 additions and 88 deletions
+7 -7
View File
@@ -9504,15 +9504,15 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "5.0.6", "version": "5.0.9",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==", "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"balanced-match": "^4.0.2" "balanced-match": "^4.0.2"
}, },
"engines": { "engines": {
"node": "18 || 20 || >=22" "node": "20 || >=22"
} }
}, },
"node_modules/braces": { "node_modules/braces": {
@@ -11645,9 +11645,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/eslint-config-next/node_modules/brace-expansion": { "node_modules/eslint-config-next/node_modules/brace-expansion": {
"version": "1.1.14", "version": "1.1.18",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
"integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
+2 -2
View File
@@ -266,13 +266,13 @@ export const configSchema = z
.positive() .positive()
.gt(0) .gt(0)
.optional() .optional()
.default(30), .default(10),
burst: z burst: z
.number() .number()
.positive() .positive()
.gt(0) .gt(0)
.optional() .optional()
.default(50) .default(16)
}) })
.optional() .optional()
.prefault({}) .prefault({})
@@ -10,12 +10,12 @@
* *
* This file is not licensed under the AGPLv3. * This file is not licensed under the AGPLv3.
*/ */
import { certificates, db, domainNamespaces, domains, orgDomains } from "@server/db"; import { certificates, db, 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, isNotNull, or } from "drizzle-orm"; import { and, eq, inArray, 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,28 +63,14 @@ 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))
.leftJoin( .innerJoin(
orgDomains, orgDomains,
and( and(
eq(domains.domainId, orgDomains.domainId), eq(domains.domainId, orgDomains.domainId),
eq(orgDomains.orgId, orgId) eq(orgDomains.orgId, orgId)
) )
) )
.leftJoin( .where(and(inArray(certificates.domain, domainList)));
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
@@ -124,27 +110,19 @@ 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))
.leftJoin( .innerJoin(
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)
) )
) )
); );
+3 -51
View File
@@ -127,9 +127,6 @@ export async function verifyResourceSession(
// Extract HTTP Basic Auth credentials if present // Extract HTTP Basic Auth credentials if present
const clientHeaderAuth = extractBasicAuth(headers); const clientHeaderAuth = extractBasicAuth(headers);
const clientUserAgent = headers?.["user-agent"] || headers?.["User-Agent"];
const clientIsBrowser = isBrowserUserAgent(clientUserAgent);
const clientIp = requestIp const clientIp = requestIp
? stripPortFromHost(requestIp, badgerVersion) ? stripPortFromHost(requestIp, badgerVersion)
: undefined; : undefined;
@@ -316,14 +313,9 @@ export async function verifyResourceSession(
return allowed(res, undefined, dontStripSession); return allowed(res, undefined, dontStripSession);
} }
// Only offer a browser redirect to clients that can actually follow one and log in const redirectPath = `/auth/resource/${encodeURIComponent(
// (an interactive browser). Non-browser clients (curl, scripts, bots, etc.) just get resource.resourceGuid
// an unauthorized response from Badger instead of a login redirect URL. )}?redirect=${encodeURIComponent(originalRequestURL)}`;
const redirectPath = clientIsBrowser
? `/auth/resource/${encodeURIComponent(
resource.resourceGuid
)}?redirect=${encodeURIComponent(originalRequestURL)}`
: undefined;
// check for access token in headers // check for access token in headers
if ( if (
@@ -1484,46 +1476,6 @@ async function getCountryCodeFromIp(ip: string): Promise<string | undefined> {
return cachedCountryCode; return cachedCountryCode;
} }
// Permissive by default: only reject known non-browser clients or a missing
// User-Agent (real browsers always send one). This avoids blocking real
// browsers whose UA string doesn't match a hardcoded allow-list.
const NON_BROWSER_USER_AGENT_PATTERNS = [
/curl/,
/wget/,
/python-requests/,
/python-urllib/,
/go-http-client/,
/okhttp/,
/axios/,
/node-fetch/,
/postmanruntime/,
/insomnia/,
/libwww-perl/,
/java\//,
/ruby/,
/php/,
/bot/,
/spider/,
/crawler/,
/headlesschrome/,
/phantomjs/,
/httpclient/,
/prometheus/,
/go-resty/,
/apache-httpclient/,
/scrapy/
];
function isBrowserUserAgent(userAgent: string | undefined): boolean {
if (!userAgent) {
return false;
}
const ua = userAgent.toLowerCase();
return !NON_BROWSER_USER_AGENT_PATTERNS.some((pattern) => pattern.test(ua));
}
function extractBasicAuth( function extractBasicAuth(
headers: Record<string, string> | undefined headers: Record<string, string> | undefined
): string | undefined { ): string | undefined {
+1 -1
View File
@@ -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 || (!isLoading && data === null)) { } else if (isError || initialCertValue === null) {
// Null value means failed to get the certificate // Null value means failed to get the certificate
certError = "Failed"; certError = "Failed";
} }