From 9804c0db289308003c95d4913bb2017cee66e93d Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Wed, 27 May 2026 17:02:13 +0200 Subject: [PATCH 01/37] Ready for testing --- messages/bg-BG.json | 6 +- messages/cs-CZ.json | 6 +- messages/de-DE.json | 6 +- messages/en-US.json | 6 +- messages/es-ES.json | 6 +- messages/fr-FR.json | 6 +- messages/it-IT.json | 6 +- messages/ko-KR.json | 6 +- messages/nb-NO.json | 6 +- messages/nl-NL.json | 6 +- messages/pl-PL.json | 6 +- messages/pt-PT.json | 6 +- messages/ru-RU.json | 6 +- messages/tr-TR.json | 6 +- messages/zh-CN.json | 6 +- messages/zh-TW.json | 6 +- package-lock.json | 37 ++-------- server/db/pg/schema/schema.ts | 3 +- server/db/sqlite/schema/schema.ts | 3 +- server/lib/traefik/getTraefikConfig.ts | 51 +++++++++---- .../private/lib/traefik/getTraefikConfig.ts | 55 +++++++++----- server/routers/resource/getResource.ts | 9 ++- server/routers/resource/updateResource.ts | 71 +++++++++++-------- server/setup/migrationsPg.ts | 4 +- server/setup/migrationsSqlite.ts | 4 +- server/setup/scriptsPg/1.18.5.ts | 30 ++++++++ server/setup/scriptsSqlite/1.18.5.ts | 34 +++++++++ .../resources/proxy/[niceId]/proxy/page.tsx | 48 ++++++++++--- src/components/HealthCheckCredenza.tsx | 4 +- src/components/HealthCheckFormFields.tsx | 4 +- 30 files changed, 308 insertions(+), 145 deletions(-) create mode 100644 server/setup/scriptsPg/1.18.5.ts create mode 100644 server/setup/scriptsSqlite/1.18.5.ts diff --git a/messages/bg-BG.json b/messages/bg-BG.json index 108229942..60f7225a9 100644 --- a/messages/bg-BG.json +++ b/messages/bg-BG.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Опити за повторно", "expectedResponseCodes": "Очаквани кодове за отговор", "expectedResponseCodesDescription": "HTTP статус код, указващ здравословно състояние. Ако бъде оставено празно, между 200-300 се счита за здравословно.", - "customHeaders": "Персонализирани заглавия", - "customHeadersDescription": "Add custom headers to be sent when proxying requests. One per line in the format Header-Name: value", + "customRequestHeaders": "Персонализирани заглавия", + "customRequestHeadersDescription": "Add custom headers to be sent when proxying requests. One per line in the format Header-Name: value", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Заглавията трябва да бъдат във формат: Име на заглавието: стойност.", "saveHealthCheck": "Запазване на проверка на здравето", "healthCheckSaved": "Проверка на здравето е запазена", diff --git a/messages/cs-CZ.json b/messages/cs-CZ.json index 7c118ff29..be171bf09 100644 --- a/messages/cs-CZ.json +++ b/messages/cs-CZ.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Opakovat pokusy", "expectedResponseCodes": "Očekávané kódy odezvy", "expectedResponseCodesDescription": "HTTP kód stavu, který označuje zdravý stav. Ponecháte-li prázdné, 200-300 je považováno za zdravé.", - "customHeaders": "Vlastní záhlaví", - "customHeadersDescription": "Záhlaví oddělená nová řádka: hodnota", + "customRequestHeaders": "Vlastní záhlaví", + "customRequestHeadersDescription": "Záhlaví oddělená nová řádka: hodnota", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Headers must be in the format: Header-Name: value.", "saveHealthCheck": "Uložit kontrolu stavu", "healthCheckSaved": "Kontrola stavu uložena", diff --git a/messages/de-DE.json b/messages/de-DE.json index 11d76dab5..d61bf24b2 100644 --- a/messages/de-DE.json +++ b/messages/de-DE.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Wiederholungsversuche", "expectedResponseCodes": "Erwartete Antwortcodes", "expectedResponseCodesDescription": "HTTP-Statuscode, der einen gesunden Zustand anzeigt. Wenn leer gelassen, wird 200-300 als gesund angesehen.", - "customHeaders": "Eigene Kopfzeilen", - "customHeadersDescription": "Header neue Zeile getrennt: Header-Name: Wert", + "customRequestHeaders": "Eigene Kopfzeilen", + "customRequestHeadersDescription": "Header neue Zeile getrennt: Header-Name: Wert", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Header müssen im Format Header-Name: Wert sein.", "saveHealthCheck": "Gesundheits-Check speichern", "healthCheckSaved": "Gesundheits-Check gespeichert", diff --git a/messages/en-US.json b/messages/en-US.json index 027d9fc38..829aa0692 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -1994,8 +1994,10 @@ "retryAttempts": "Retry Attempts", "expectedResponseCodes": "Expected Response Codes", "expectedResponseCodesDescription": "HTTP status code that indicates healthy status. If left blank, 200-300 is considered healthy.", - "customHeaders": "Custom Request Headers", - "customHeadersDescription": "Request headers sent to the downstream targets. Headers new line separated: Header-Name: value", + "customRequestHeaders": "Custom Request Headers", + "customRequestHeadersDescription": "Request headers sent to the downstream targets. One per line: Header-Name: value", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Headers must be in the format: Header-Name: value", "saveHealthCheck": "Save Health Check", "healthCheckSaved": "Health Check Saved", diff --git a/messages/es-ES.json b/messages/es-ES.json index 9e5b6fc82..2b1e55381 100644 --- a/messages/es-ES.json +++ b/messages/es-ES.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Intentos de Reintento", "expectedResponseCodes": "Códigos de respuesta esperados", "expectedResponseCodesDescription": "Código de estado HTTP que indica un estado saludable. Si se deja en blanco, se considera saludable de 200 a 300.", - "customHeaders": "Cabeceras personalizadas", - "customHeadersDescription": "Nueva línea de cabeceras separada: Nombre de cabecera: valor", + "customRequestHeaders": "Cabeceras personalizadas", + "customRequestHeadersDescription": "Nueva línea de cabeceras separada: Nombre de cabecera: valor", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Los encabezados deben estar en el formato: Nombre de cabecera: valor.", "saveHealthCheck": "Guardar Chequeo de Salud", "healthCheckSaved": "Chequeo de Salud Guardado", diff --git a/messages/fr-FR.json b/messages/fr-FR.json index da3350e46..d9a83e655 100644 --- a/messages/fr-FR.json +++ b/messages/fr-FR.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Tentatives de réessai", "expectedResponseCodes": "Codes de réponse attendus", "expectedResponseCodesDescription": "Code de statut HTTP indiquant un état de santé satisfaisant. Si non renseigné, 200-300 est considéré comme satisfaisant.", - "customHeaders": "En-têtes personnalisés", - "customHeadersDescription": "En-têtes séparés par une nouvelle ligne: En-nom: valeur", + "customRequestHeaders": "En-têtes personnalisés", + "customRequestHeadersDescription": "En-têtes séparés par une nouvelle ligne: En-nom: valeur", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Les entêtes doivent être au format : Header-Name: valeur.", "saveHealthCheck": "Sauvegarder la vérification de l'état de santé", "healthCheckSaved": "Vérification de l'état de santé enregistrée", diff --git a/messages/it-IT.json b/messages/it-IT.json index 3ec9c0011..eac3ecde9 100644 --- a/messages/it-IT.json +++ b/messages/it-IT.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Tentativi di Riprova", "expectedResponseCodes": "Codici di Risposta Attesi", "expectedResponseCodesDescription": "Codice di stato HTTP che indica lo stato di salute. Se lasciato vuoto, considerato sano è compreso tra 200-300.", - "customHeaders": "Intestazioni Personalizzate", - "customHeadersDescription": "Intestazioni nuova riga separate: Intestazione-Nome: valore", + "customRequestHeaders": "Intestazioni Personalizzate", + "customRequestHeadersDescription": "Intestazioni nuova riga separate: Intestazione-Nome: valore", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Le intestazioni devono essere nel formato: Intestazione-Nome: valore.", "saveHealthCheck": "Salva Controllo Salute", "healthCheckSaved": "Controllo Salute Salvato", diff --git a/messages/ko-KR.json b/messages/ko-KR.json index d1bd16382..76facec3e 100644 --- a/messages/ko-KR.json +++ b/messages/ko-KR.json @@ -1964,8 +1964,10 @@ "retryAttempts": "재시도 횟수", "expectedResponseCodes": "예상 응답 코드", "expectedResponseCodesDescription": "정상 상태를 나타내는 HTTP 상태 코드입니다. 비워 두면 200-300이 정상으로 간주됩니다.", - "customHeaders": "사용자 정의 헤더", - "customHeadersDescription": "헤더는 새 줄로 구분됨: Header-Name: value", + "customRequestHeaders": "사용자 정의 헤더", + "customRequestHeadersDescription": "헤더는 새 줄로 구분됨: Header-Name: value", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "헤더는 형식이어야 합니다: 헤더명: 값.", "saveHealthCheck": "상태 확인 저장", "healthCheckSaved": "상태 확인이 저장되었습니다.", diff --git a/messages/nb-NO.json b/messages/nb-NO.json index d76013d16..2aa54d52a 100644 --- a/messages/nb-NO.json +++ b/messages/nb-NO.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Forsøk på nytt", "expectedResponseCodes": "Forventede svarkoder", "expectedResponseCodesDescription": "HTTP-statuskode som indikerer sunn status. Hvis den blir stående tom, regnes 200-300 som sunn.", - "customHeaders": "Egendefinerte topptekster", - "customHeadersDescription": "Overskrifter som er adskilt med linje: Overskriftsnavn: verdi", + "customRequestHeaders": "Egendefinerte topptekster", + "customRequestHeadersDescription": "Overskrifter som er adskilt med linje: Overskriftsnavn: verdi", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Topptekst må være i formatet: header-navn: verdi.", "saveHealthCheck": "Lagre Helsekontroll", "healthCheckSaved": "Helsekontroll Lagret", diff --git a/messages/nl-NL.json b/messages/nl-NL.json index f989db342..29215eb93 100644 --- a/messages/nl-NL.json +++ b/messages/nl-NL.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Herhaal Pogingen", "expectedResponseCodes": "Verwachte Reactiecodes", "expectedResponseCodesDescription": "HTTP-statuscode die gezonde status aangeeft. Indien leeg wordt 200-300 als gezond beschouwd.", - "customHeaders": "Aangepaste headers", - "customHeadersDescription": "Kopregeleinde: Header-Naam: waarde", + "customRequestHeaders": "Aangepaste headers", + "customRequestHeadersDescription": "Kopregeleinde: Header-Naam: waarde", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Headers moeten in het formaat zijn: Header-Naam: waarde.", "saveHealthCheck": "Opslaan Gezondheidscontrole", "healthCheckSaved": "Gezondheidscontrole Opgeslagen", diff --git a/messages/pl-PL.json b/messages/pl-PL.json index 4d801023b..205b34ded 100644 --- a/messages/pl-PL.json +++ b/messages/pl-PL.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Próby Ponowienia", "expectedResponseCodes": "Oczekiwane Kody Odpowiedzi", "expectedResponseCodesDescription": "Kod statusu HTTP, który wskazuje zdrowy status. Jeśli pozostanie pusty, uznaje się 200-300 za zdrowy.", - "customHeaders": "Niestandardowe nagłówki", - "customHeadersDescription": "Nagłówki oddzielone: Nazwa nagłówka: wartość", + "customRequestHeaders": "Niestandardowe nagłówki", + "customRequestHeadersDescription": "Nagłówki oddzielone: Nazwa nagłówka: wartość", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Nagłówki muszą być w formacie: Nazwa nagłówka: wartość.", "saveHealthCheck": "Zapisz Kontrolę Zdrowia", "healthCheckSaved": "Kontrola Zdrowia Zapisana", diff --git a/messages/pt-PT.json b/messages/pt-PT.json index 0604c1caf..b3086aa1c 100644 --- a/messages/pt-PT.json +++ b/messages/pt-PT.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Tentativas de Repetição", "expectedResponseCodes": "Códigos de Resposta Esperados", "expectedResponseCodesDescription": "Código de status HTTP que indica estado saudável. Se deixado em branco, 200-300 é considerado saudável.", - "customHeaders": "Cabeçalhos Personalizados", - "customHeadersDescription": "Separados por cabeçalhos da nova linha: Nome do Cabeçalho: valor", + "customRequestHeaders": "Cabeçalhos Personalizados", + "customRequestHeadersDescription": "Separados por cabeçalhos da nova linha: Nome do Cabeçalho: valor", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Cabeçalhos devem estar no formato: Nome do Cabeçalho: valor.", "saveHealthCheck": "Salvar Verificação de Saúde", "healthCheckSaved": "Verificação de Saúde Salva", diff --git a/messages/ru-RU.json b/messages/ru-RU.json index 0f3e48962..556d1d35c 100644 --- a/messages/ru-RU.json +++ b/messages/ru-RU.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Количество попыток повторного запроса", "expectedResponseCodes": "Ожидаемые коды ответов", "expectedResponseCodesDescription": "HTTP-код состояния, указывающий на здоровое состояние. Если оставить пустым, 200-300 считается здоровым.", - "customHeaders": "Пользовательские заголовки", - "customHeadersDescription": "Заголовки новой строки, разделённые: название заголовка: значение", + "customRequestHeaders": "Пользовательские заголовки", + "customRequestHeadersDescription": "Заголовки новой строки, разделённые: название заголовка: значение", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Заголовки должны быть в формате: Название заголовка: значение.", "saveHealthCheck": "Сохранить проверку здоровья", "healthCheckSaved": "Проверка здоровья сохранена", diff --git a/messages/tr-TR.json b/messages/tr-TR.json index e1d965e8e..3b5a324e2 100644 --- a/messages/tr-TR.json +++ b/messages/tr-TR.json @@ -1964,8 +1964,10 @@ "retryAttempts": "Tekrar Deneme Girişimleri", "expectedResponseCodes": "Beklenen Yanıt Kodları", "expectedResponseCodesDescription": "Sağlıklı durumu gösteren HTTP durum kodu. Boş bırakılırsa, 200-300 arası sağlıklı kabul edilir.", - "customHeaders": "Özel Başlıklar", - "customHeadersDescription": "Başlıklar yeni satırla ayrılmış: Başlık-Adı: değer", + "customRequestHeaders": "Özel Başlıklar", + "customRequestHeadersDescription": "Başlıklar yeni satırla ayrılmış: Başlık-Adı: değer", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Başlıklar şu formatta olmalıdır: Başlık-Adı: değer.", "saveHealthCheck": "Sağlık Kontrolünü Kaydet", "healthCheckSaved": "Sağlık Kontrolü Kaydedildi", diff --git a/messages/zh-CN.json b/messages/zh-CN.json index a23647dba..dd01d78f8 100644 --- a/messages/zh-CN.json +++ b/messages/zh-CN.json @@ -1964,8 +1964,10 @@ "retryAttempts": "重试次数", "expectedResponseCodes": "期望响应代码", "expectedResponseCodesDescription": "HTTP 状态码表示健康状态。如留空,200-300 被视为健康。", - "customHeaders": "自定义标题", - "customHeadersDescription": "头部新行分隔:头部名称:值", + "customRequestHeaders": "自定义标题", + "customRequestHeadersDescription": "头部新行分隔:头部名称:值", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "头部必须是格式:头部名称:值。", "saveHealthCheck": "保存健康检查", "healthCheckSaved": "健康检查已保存", diff --git a/messages/zh-TW.json b/messages/zh-TW.json index 532962593..e6c4a95f2 100644 --- a/messages/zh-TW.json +++ b/messages/zh-TW.json @@ -1555,8 +1555,10 @@ "retryAttempts": "重試次數", "expectedResponseCodes": "期望響應代碼", "expectedResponseCodesDescription": "HTTP 狀態碼表示健康狀態。如留空,200-300 被視為健康。", - "customHeaders": "自訂 Headers", - "customHeadersDescription": "Header 斷行分隔:Header 名稱:值", + "customRequestHeaders": "自訂 Headers", + "customRequestHeadersDescription": "Header 斷行分隔:Header 名稱:值", + "customResponseHeaders": "Custom Response Headers", + "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", "headersValidationError": "Header 必須是格式:Header 名稱:值。", "saveHealthCheck": "保存健康檢查", "healthCheckSaved": "健康檢查已保存", diff --git a/package-lock.json b/package-lock.json index 8c241554a..d06ae5554 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1058,7 +1058,6 @@ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -3034,7 +3033,6 @@ "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": "^14.21.3 || >=16" }, @@ -6981,7 +6979,6 @@ "resolved": "https://registry.npmjs.org/@react-email/text/-/text-0.1.6.tgz", "integrity": "sha512-TYqkioRS45wTR5il3dYk/SbUjjEdhSwh9BtRNB99qNH1pXAwA45H7rAuxehiu8iJQJH0IyIr+6n62gBz9ezmsw==", "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -8442,7 +8439,6 @@ "version": "5.90.21", "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.21.tgz", "integrity": "sha512-0Lu6y5t+tvlTJMTO7oh5NSpJfpg/5D41LlThfepTixPYkJ0sE2Jj0m0f6yYqujBwIXlId87e234+MxG3D3g7kg==", - "peer": true, "dependencies": { "@tanstack/query-core": "5.90.20" }, @@ -8558,7 +8554,6 @@ "integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "@types/node": "*" } @@ -8906,7 +8901,6 @@ "integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^5.0.0", @@ -9002,7 +8996,6 @@ "integrity": "sha512-oX8xrhvpiyRCQkG1MFchB09f+cXftgIXb3a7UUa4Y3wpmZPw5tyZGTLWhlESOLq1Rq6oDlc8npVU2/9xiCuXMA==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.18.0" } @@ -9030,7 +9023,6 @@ "integrity": "sha512-gT+oueVQkqnj6ajGJXblFR4iavIXWsGAFCk3dP4Kki5+a9R4NMt0JARdk6s8cUKcfUoqP5dAtDSLU8xYUTFV+Q==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "@types/node": "*", "pg-protocol": "*", @@ -9056,7 +9048,6 @@ "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz", "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", "devOptional": true, - "peer": true, "dependencies": { "csstype": "^3.2.2" } @@ -9067,7 +9058,6 @@ "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", "devOptional": true, "license": "MIT", - "peer": true, "peerDependencies": { "@types/react": "^19.2.0" } @@ -9154,7 +9144,8 @@ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/@types/ws": { "version": "8.18.1", @@ -9228,7 +9219,6 @@ "integrity": "sha512-klQbnPAAiGYFyI02+znpBRLyjL4/BrBd0nyWkdC0s/6xFLkXYQ8OoRrSkqacS1ddVxf/LDyODIKbQ5TgKAf/Fg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.56.1", "@typescript-eslint/types": "8.56.1", @@ -9702,7 +9692,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -10152,7 +10141,6 @@ "integrity": "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/types": "^7.26.0" } @@ -10224,7 +10212,6 @@ "integrity": "sha512-Ba0KR+Fzxh2jDRhdg6TSH0SJGzb8C0aBY4hR8w8madIdIzzC6Y1+kx5qR6eS1Z+Gy20h6ZU28aeyg0z1VIrShQ==", "hasInstallScript": true, "license": "MIT", - "peer": true, "dependencies": { "bindings": "^1.5.0", "prebuild-install": "^7.1.1" @@ -10353,7 +10340,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -11260,7 +11246,6 @@ "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", "license": "ISC", - "peer": true, "engines": { "node": ">=12" } @@ -11701,6 +11686,7 @@ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.2.tgz", "integrity": "sha512-6obghkliLdmKa56xdbLOpUZ43pAR6xFy1uOrxBaIDjT+yaRuuybLjGS9eVBoSR/UPU5fq3OXClEHLJNGvbxKpQ==", "license": "(MPL-2.0 OR Apache-2.0)", + "peer": true, "engines": { "node": ">=20" }, @@ -12335,7 +12321,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "bin": { "esbuild": "bin/esbuild" }, @@ -12421,7 +12406,6 @@ "integrity": "sha512-COV33RzXZkqhG9P2rZCFl9ZmJ7WL+gQSCRzE7RhkbclbQPtLAWReL7ysA0Sh4c8Im2U9ynybdR56PV0XcKvqaQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -12558,7 +12542,6 @@ "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.9", @@ -12952,7 +12935,6 @@ "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", "license": "MIT", - "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", @@ -15370,6 +15352,7 @@ "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.55.1.tgz", "integrity": "sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==", "license": "MIT", + "peer": true, "dependencies": { "dompurify": "3.2.7", "marked": "14.0.0" @@ -15380,6 +15363,7 @@ "resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz", "integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==", "license": "MIT", + "peer": true, "bin": { "marked": "bin/marked.js" }, @@ -15468,7 +15452,6 @@ "resolved": "https://registry.npmjs.org/next/-/next-15.5.15.tgz", "integrity": "sha512-VSqCrJwtLVGwAVE0Sb/yikrQfkwkZW9p+lL/J4+xe+G3ZA+QnWPqgcfH1tDUEuk9y+pthzzVFp4L/U8JerMfMQ==", "license": "MIT", - "peer": true, "dependencies": { "@next/env": "15.5.15", "@swc/helpers": "0.5.15", @@ -16428,7 +16411,6 @@ "resolved": "https://registry.npmjs.org/pg/-/pg-8.20.0.tgz", "integrity": "sha512-ldhMxz2r8fl/6QkXnBD3CR9/xg694oT6DZQ2s6c/RI28OjtSOpxnPrUCGOBJ46RCUxcWdx3p6kw/xnDHjKvaRA==", "license": "MIT", - "peer": true, "dependencies": { "pg-connection-string": "^2.12.0", "pg-pool": "^3.13.0", @@ -16936,7 +16918,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz", "integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -16968,7 +16949,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz", "integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==", "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -17261,7 +17241,6 @@ "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.71.2.tgz", "integrity": "sha512-1CHvcDYzuRUNOflt4MOq3ZM46AronNJtQ1S7tnX6YN4y72qhgiUItpacZUAQ0TyWYci3yz1X+rXaSxiuEm86PA==", "license": "MIT", - "peer": true, "engines": { "node": ">=18.0.0" }, @@ -18723,8 +18702,7 @@ "version": "4.2.2", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.2.tgz", "integrity": "sha512-KWBIxs1Xb6NoLdMVqhbhgwZf2PGBpPEiwOqgI4pFIYbNTfBXiKYyWoTsXgBQ9WFg/OlhnvHaY+AEpW7wSmFo2Q==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/tapable": { "version": "2.3.2", @@ -19199,7 +19177,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "devOptional": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -19627,7 +19604,6 @@ "resolved": "https://registry.npmjs.org/winston/-/winston-3.19.0.tgz", "integrity": "sha512-LZNJgPzfKR+/J3cHkxcpHKpKKvGfDZVPS4hfJCc4cCG0CgYzvlD6yE/S3CIL/Yt91ak327YCpiF/0MyeZHEHKA==", "license": "MIT", - "peer": true, "dependencies": { "@colors/colors": "^1.6.0", "@dabh/diagnostics": "^2.0.8", @@ -19834,7 +19810,6 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/server/db/pg/schema/schema.ts b/server/db/pg/schema/schema.ts index 58e78735c..e8784a999 100644 --- a/server/db/pg/schema/schema.ts +++ b/server/db/pg/schema/schema.ts @@ -144,7 +144,8 @@ export const resources = pgTable("resources", { skipToIdpId: integer("skipToIdpId").references(() => idp.idpId, { onDelete: "set null" }), - headers: text("headers"), // comma-separated list of headers to add to the request + requestHeaders: text("requestHeaders"), + responseHeaders: text("responseHeaders"), proxyProtocol: boolean("proxyProtocol").notNull().default(false), proxyProtocolVersion: integer("proxyProtocolVersion").default(1), diff --git a/server/db/sqlite/schema/schema.ts b/server/db/sqlite/schema/schema.ts index e3e83d222..54ac67969 100644 --- a/server/db/sqlite/schema/schema.ts +++ b/server/db/sqlite/schema/schema.ts @@ -161,7 +161,8 @@ export const resources = sqliteTable("resources", { skipToIdpId: integer("skipToIdpId").references(() => idp.idpId, { onDelete: "set null" }), - headers: text("headers"), // comma-separated list of headers to add to the request + requestHeaders: text("requestHeaders"), + responseHeaders: text("responseHeaders"), proxyProtocol: integer("proxyProtocol", { mode: "boolean" }) .notNull() .default(false), diff --git a/server/lib/traefik/getTraefikConfig.ts b/server/lib/traefik/getTraefikConfig.ts index 7379cad7f..ee5c25ea9 100644 --- a/server/lib/traefik/getTraefikConfig.ts +++ b/server/lib/traefik/getTraefikConfig.ts @@ -65,7 +65,8 @@ export async function getTraefikConfig( tlsServerName: resources.tlsServerName, setHostHeader: resources.setHostHeader, enableProxy: resources.enableProxy, - headers: resources.headers, + requestHeaders: resources.requestHeaders, + responseHeaders: resources.responseHeaders, proxyProtocol: resources.proxyProtocol, proxyProtocolVersion: resources.proxyProtocolVersion, @@ -177,7 +178,8 @@ export async function getTraefikConfig( setHostHeader: row.setHostHeader, enableProxy: row.enableProxy, targets: [], - headers: row.headers, + requestHeaders: row.requestHeaders, + responseHeaders: row.responseHeaders, proxyProtocol: row.proxyProtocol, proxyProtocolVersion: row.proxyProtocolVersion ?? 1, path: row.path, // the targets will all have the same path @@ -364,38 +366,59 @@ export async function getTraefikConfig( } // Handle custom headers middleware - if (resource.headers || resource.setHostHeader) { - const headersObj: { [key: string]: string } = {}; + if (resource.requestHeaders || resource.responseHeaders || resource.setHostHeader) { + const requestHeadersObj: { [key: string]: string } = {}; + const responseHeadersObj: { [key: string]: string } = {}; - if (resource.headers) { - let headersArr: { name: string; value: string }[] = []; + if (resource.requestHeaders) { + let requestHeadersArr: { name: string; value: string }[] = []; try { - headersArr = JSON.parse(resource.headers) as { + requestHeadersArr = JSON.parse(resource.requestHeaders) as { name: string; value: string; }[]; } catch (e) { logger.warn( - `Failed to parse headers for resource ${resource.resourceId}: ${e}` + `Failed to parse requestHeaders for resource ${resource.resourceId}: ${e}` ); } - - headersArr.forEach((header) => { - headersObj[header.name] = header.value; + requestHeadersArr.forEach((header) => { + requestHeadersObj[header.name] = header.value; }); } if (resource.setHostHeader) { - headersObj["Host"] = resource.setHostHeader; + requestHeadersObj["Host"] = resource.setHostHeader; } - if (Object.keys(headersObj).length > 0) { + if (resource.responseHeaders) { + let responseHeadersArr: { name: string; value: string }[] = []; + try { + responseHeadersArr = JSON.parse(resource.responseHeaders) as { + name: string; + value: string; + }[]; + } catch (e) { + logger.warn( + `Failed to parse responseHeaders for resource ${resource.resourceId}: ${e}` + ); + } + responseHeadersArr.forEach((header) => { + responseHeadersObj[header.name] = header.value; + }); + } + + const hasRequestHeaders = Object.keys(requestHeadersObj).length > 0; + const hasResponseHeaders = Object.keys(responseHeadersObj).length > 0; + + if (hasRequestHeaders || hasResponseHeaders) { if (!config_output.http.middlewares) { config_output.http.middlewares = {}; } config_output.http.middlewares[headersMiddlewareName] = { headers: { - customRequestHeaders: headersObj + ...(hasRequestHeaders && { customRequestHeaders: requestHeadersObj }), + ...(hasResponseHeaders && { customResponseHeaders: responseHeadersObj }) } }; diff --git a/server/private/lib/traefik/getTraefikConfig.ts b/server/private/lib/traefik/getTraefikConfig.ts index 481192fb5..e35544dc9 100644 --- a/server/private/lib/traefik/getTraefikConfig.ts +++ b/server/private/lib/traefik/getTraefikConfig.ts @@ -105,7 +105,8 @@ export async function getTraefikConfig( tlsServerName: resources.tlsServerName, setHostHeader: resources.setHostHeader, enableProxy: resources.enableProxy, - headers: resources.headers, + requestHeaders: resources.requestHeaders, + responseHeaders: resources.responseHeaders, proxyProtocol: resources.proxyProtocol, proxyProtocolVersion: resources.proxyProtocolVersion, wildcard: resources.wildcard, @@ -237,7 +238,8 @@ export async function getTraefikConfig( setHostHeader: row.setHostHeader, enableProxy: row.enableProxy, targets: [], - headers: row.headers, + requestHeaders: row.requestHeaders, + responseHeaders: row.responseHeaders, proxyProtocol: row.proxyProtocol, proxyProtocolVersion: row.proxyProtocolVersion ?? 1, path: row.path, // the targets will all have the same path @@ -648,40 +650,59 @@ export async function getTraefikConfig( } } - if (resource.headers || resource.setHostHeader) { - // if there are headers, parse them into an object - const headersObj: { [key: string]: string } = {}; - if (resource.headers) { - let headersArr: { name: string; value: string }[] = []; + if (resource.requestHeaders || resource.responseHeaders || resource.setHostHeader) { + const requestHeadersObj: { [key: string]: string } = {}; + const responseHeadersObj: { [key: string]: string } = {}; + + if (resource.requestHeaders) { + let requestHeadersArr: { name: string; value: string }[] = []; try { - headersArr = JSON.parse(resource.headers) as { + requestHeadersArr = JSON.parse(resource.requestHeaders) as { name: string; value: string; }[]; } catch (e) { logger.warn( - `Failed to parse headers for resource ${resource.resourceId}: ${e}` + `Failed to parse requestHeaders for resource ${resource.resourceId}: ${e}` ); } - - headersArr.forEach((header) => { - headersObj[header.name] = header.value; + requestHeadersArr.forEach((header) => { + requestHeadersObj[header.name] = header.value; }); } if (resource.setHostHeader) { - headersObj["Host"] = resource.setHostHeader; + requestHeadersObj["Host"] = resource.setHostHeader; } - // check if the object is not empty - if (Object.keys(headersObj).length > 0) { - // Add the headers middleware + if (resource.responseHeaders) { + let responseHeadersArr: { name: string; value: string }[] = []; + try { + responseHeadersArr = JSON.parse(resource.responseHeaders) as { + name: string; + value: string; + }[]; + } catch (e) { + logger.warn( + `Failed to parse responseHeaders for resource ${resource.resourceId}: ${e}` + ); + } + responseHeadersArr.forEach((header) => { + responseHeadersObj[header.name] = header.value; + }); + } + + const hasRequestHeaders = Object.keys(requestHeadersObj).length > 0; + const hasResponseHeaders = Object.keys(responseHeadersObj).length > 0; + + if (hasRequestHeaders || hasResponseHeaders) { if (!config_output.http.middlewares) { config_output.http.middlewares = {}; } config_output.http.middlewares[headersMiddlewareName] = { headers: { - customRequestHeaders: headersObj + ...(hasRequestHeaders && { customRequestHeaders: requestHeadersObj }), + ...(hasResponseHeaders && { customResponseHeaders: responseHeadersObj }) } }; diff --git a/server/routers/resource/getResource.ts b/server/routers/resource/getResource.ts index 7a52c0a85..bbd58320c 100644 --- a/server/routers/resource/getResource.ts +++ b/server/routers/resource/getResource.ts @@ -105,9 +105,12 @@ export async function getResource( return response(res, { data: { ...resource, - headers: resource.headers - ? JSON.parse(resource.headers) - : resource.headers + requestHeaders: resource.requestHeaders + ? JSON.parse(resource.requestHeaders) + : resource.requestHeaders, + responseHeaders: resource.responseHeaders + ? JSON.parse(resource.responseHeaders) + : resource.responseHeaders }, success: true, error: false, diff --git a/server/routers/resource/updateResource.ts b/server/routers/resource/updateResource.ts index 0a7052dce..fc8416282 100644 --- a/server/routers/resource/updateResource.ts +++ b/server/routers/resource/updateResource.ts @@ -58,7 +58,11 @@ const updateHttpResourceBodySchema = z tlsServerName: z.string().nullable().optional(), setHostHeader: z.string().nullable().optional(), skipToIdpId: z.int().positive().nullable().optional(), - headers: z + requestHeaders: z + .array(z.strictObject({ name: z.string(), value: z.string() })) + .nullable() + .optional(), + responseHeaders: z .array(z.strictObject({ name: z.string(), value: z.string() })) .nullable() .optional(), @@ -111,12 +115,12 @@ const updateHttpResourceBodySchema = z ) .refine( (data) => { - if (data.headers) { - // HTTP header names must be valid token characters (RFC 7230) - const validHeaderName = /^[a-zA-Z0-9!#$%&'*+\-.^_`|~]+$/; - return data.headers.every((h) => validHeaderName.test(h.name)); - } - return true; + const validHeaderName = /^[a-zA-Z0-9!#$%&'*+\-.^_`|~]+$/; + const allHeaders = [ + ...(data.requestHeaders ?? []), + ...(data.responseHeaders ?? []) + ]; + return allHeaders.every((h) => validHeaderName.test(h.name)); }, { error: "Header names may only contain valid HTTP token characters (letters, digits, and !#$%&'*+-.^_`|~)." @@ -124,14 +128,12 @@ const updateHttpResourceBodySchema = z ) .refine( (data) => { - if (data.headers) { - // HTTP header values must be visible ASCII or horizontal whitespace, no control chars (RFC 7230) - const validHeaderValue = /^[\t\x20-\x7E]*$/; - return data.headers.every((h) => - validHeaderValue.test(h.value) - ); - } - return true; + const validHeaderValue = /^[\t\x20-\x7E]*$/; + const allHeaders = [ + ...(data.requestHeaders ?? []), + ...(data.responseHeaders ?? []) + ]; + return allHeaders.every((h) => validHeaderValue.test(h.value)); }, { error: "Header values may only contain printable ASCII characters and horizontal whitespace." @@ -139,16 +141,16 @@ const updateHttpResourceBodySchema = z ) .refine( (data) => { - if (data.headers) { - // Reject Traefik template syntax {{word}} in names or values - const templatePattern = /\{\{[^}]+\}\}/; - return data.headers.every( - (h) => - !templatePattern.test(h.name) && - !templatePattern.test(h.value) - ); - } - return true; + const templatePattern = /\{\{[^}]+\}\}/; + const allHeaders = [ + ...(data.requestHeaders ?? []), + ...(data.responseHeaders ?? []) + ]; + return allHeaders.every( + (h) => + !templatePattern.test(h.name) && + !templatePattern.test(h.value) + ); }, { error: "Header names and values must not contain template expressions such as {{value}}." @@ -467,11 +469,18 @@ async function updateHttpResource( } } - let headers = undefined; - if (updateData.headers) { - headers = JSON.stringify(updateData.headers); - } else if (updateData.headers === null) { - headers = null; + let requestHeaders = undefined; + if (updateData.requestHeaders) { + requestHeaders = JSON.stringify(updateData.requestHeaders); + } else if (updateData.requestHeaders === null) { + requestHeaders = null; + } + + let responseHeaders = undefined; + if (updateData.responseHeaders) { + responseHeaders = JSON.stringify(updateData.responseHeaders); + } else if (updateData.responseHeaders === null) { + responseHeaders = null; } const isLicensed = await isLicensedOrSubscribed( @@ -488,7 +497,7 @@ async function updateHttpResource( const updatedResource = await db .update(resources) - .set({ ...updateData, headers }) + .set({ ...updateData, requestHeaders, responseHeaders }) .where(eq(resources.resourceId, resource.resourceId)) .returning(); diff --git a/server/setup/migrationsPg.ts b/server/setup/migrationsPg.ts index 0b8af06bc..1a7d530c4 100644 --- a/server/setup/migrationsPg.ts +++ b/server/setup/migrationsPg.ts @@ -25,6 +25,7 @@ import m16 from "./scriptsPg/1.17.0"; import m17 from "./scriptsPg/1.18.0"; import m18 from "./scriptsPg/1.18.3"; import m19 from "./scriptsPg/1.18.4"; +import m20 from "./scriptsPg/1.18.5"; // THIS CANNOT IMPORT ANYTHING FROM THE SERVER // EXCEPT FOR THE DATABASE AND THE SCHEMA @@ -49,7 +50,8 @@ const migrations = [ { version: "1.17.0", run: m16 }, { version: "1.18.0", run: m17 }, { version: "1.18.3", run: m18 }, - { version: "1.18.4", run: m19 } + { version: "1.18.4", run: m19 }, + { version: "1.18.5", run: m20 } // Add new migrations here as they are created ] as { version: string; diff --git a/server/setup/migrationsSqlite.ts b/server/setup/migrationsSqlite.ts index 837b039f7..75f414c75 100644 --- a/server/setup/migrationsSqlite.ts +++ b/server/setup/migrationsSqlite.ts @@ -43,6 +43,7 @@ import m37 from "./scriptsSqlite/1.17.0"; import m38 from "./scriptsSqlite/1.18.0"; import m39 from "./scriptsSqlite/1.18.3"; import m40 from "./scriptsSqlite/1.18.4"; +import m41 from "./scriptsSqlite/1.18.5"; // THIS CANNOT IMPORT ANYTHING FROM THE SERVER // EXCEPT FOR THE DATABASE AND THE SCHEMA @@ -83,7 +84,8 @@ const migrations = [ { version: "1.17.0", run: m37 }, { version: "1.18.0", run: m38 }, { version: "1.18.3", run: m39 }, - { version: "1.18.4", run: m40 } + { version: "1.18.4", run: m40 }, + { version: "1.18.5", run: m41 } // Add new migrations here as they are created ] as const; diff --git a/server/setup/scriptsPg/1.18.5.ts b/server/setup/scriptsPg/1.18.5.ts new file mode 100644 index 000000000..5bceb41cf --- /dev/null +++ b/server/setup/scriptsPg/1.18.5.ts @@ -0,0 +1,30 @@ +import { db } from "@server/db/pg/driver"; +import { sql } from "drizzle-orm"; + +const version = "1.18.5"; + +export default async function migration() { + console.log(`Running setup script ${version}...`); + + try { + await db.execute(sql`BEGIN`); + + await db.execute(sql` + ALTER TABLE "resources" RENAME COLUMN "headers" TO "requestHeaders"; + `); + + await db.execute(sql` + ALTER TABLE "resources" ADD COLUMN "responseHeaders" text; + `); + + await db.execute(sql`COMMIT`); + console.log("Migrated database"); + } catch (e) { + await db.execute(sql`ROLLBACK`); + console.log("Unable to migrate database"); + console.log(e); + throw e; + } + + console.log(`${version} migration complete`); +} diff --git a/server/setup/scriptsSqlite/1.18.5.ts b/server/setup/scriptsSqlite/1.18.5.ts new file mode 100644 index 000000000..2edd523f0 --- /dev/null +++ b/server/setup/scriptsSqlite/1.18.5.ts @@ -0,0 +1,34 @@ +import { APP_PATH } from "@server/lib/consts"; +import Database from "better-sqlite3"; +import path from "path"; + +const version = "1.18.5"; + +export default async function migration() { + console.log(`Running setup script ${version}...`); + + const location = path.join(APP_PATH, "db", "db.sqlite"); + const db = new Database(location); + + try { + db.pragma("foreign_keys = OFF"); + + db.transaction(() => { + db.prepare( + `ALTER TABLE 'resources' RENAME COLUMN 'headers' TO 'requestHeaders';` + ).run(); + db.prepare( + `ALTER TABLE 'resources' ADD 'responseHeaders' text;` + ).run(); + })(); + + db.pragma("foreign_keys = ON"); + + console.log("Migrated database"); + } catch (e) { + console.log("Failed to migrate db:", e); + throw e; + } + + console.log(`${version} migration complete`); +} diff --git a/src/app/[orgId]/settings/resources/proxy/[niceId]/proxy/page.tsx b/src/app/[orgId]/settings/resources/proxy/[niceId]/proxy/page.tsx index 823c0f957..fd491354b 100644 --- a/src/app/[orgId]/settings/resources/proxy/[niceId]/proxy/page.tsx +++ b/src/app/[orgId]/settings/resources/proxy/[niceId]/proxy/page.tsx @@ -1097,7 +1097,10 @@ function ProxyResourceHttpForm({ message: t("proxyErrorInvalidHeader") } ), - headers: z + requestHeaders: z + .array(z.object({ name: z.string(), value: z.string() })) + .nullable(), + responseHeaders: z .array(z.object({ name: z.string(), value: z.string() })) .nullable(), proxyProtocol: z.boolean().optional(), @@ -1108,7 +1111,8 @@ function ProxyResourceHttpForm({ resolver: zodResolver(proxySettingsSchema), defaultValues: { setHostHeader: resource.setHostHeader || "", - headers: resource.headers, + requestHeaders: resource.requestHeaders, + responseHeaders: resource.responseHeaders, proxyProtocol: resource.proxyProtocol || false, proxyProtocolVersion: resource.proxyProtocolVersion || 1 } @@ -1148,7 +1152,8 @@ function ProxyResourceHttpForm({ ssl: tlsData.ssl, tlsServerName: tlsData.tlsServerName || null, setHostHeader: proxyData.setHostHeader || null, - headers: proxyData.headers || null + requestHeaders: proxyData.requestHeaders || null, + responseHeaders: proxyData.responseHeaders || null }; // Single API call to update all settings @@ -1161,7 +1166,8 @@ function ProxyResourceHttpForm({ ssl: tlsData.ssl, tlsServerName: tlsData.tlsServerName || null, setHostHeader: proxyData.setHostHeader || null, - headers: proxyData.headers || null + requestHeaders: proxyData.requestHeaders || null, + responseHeaders: proxyData.responseHeaders || null }); toast({ @@ -1307,11 +1313,11 @@ function ProxyResourceHttpForm({ /> ( - {t("customHeaders")} + {t("customRequestHeaders")} - {t("customHeadersDescription")} + {t("customRequestHeadersDescription")} + + + + )} + /> + ( + + + {t("customResponseHeaders")} + + + { + field.onChange(value); + }} + rows={4} + /> + + + {t("customResponseHeadersDescription")} @@ -1369,7 +1399,7 @@ function ProxyResourceProtocolForm({ message: t("proxyErrorInvalidHeader") } ), - headers: z + requestHeaders: z .array(z.object({ name: z.string(), value: z.string() })) .nullable(), proxyProtocol: z.boolean().optional(), @@ -1380,7 +1410,7 @@ function ProxyResourceProtocolForm({ resolver: zodResolver(proxySettingsSchema), defaultValues: { setHostHeader: resource.setHostHeader || "", - headers: resource.headers, + requestHeaders: resource.requestHeaders, proxyProtocol: resource.proxyProtocol || false, proxyProtocolVersion: resource.proxyProtocolVersion || 1 } diff --git a/src/components/HealthCheckCredenza.tsx b/src/components/HealthCheckCredenza.tsx index 0360a15e7..2bd7a27b1 100644 --- a/src/components/HealthCheckCredenza.tsx +++ b/src/components/HealthCheckCredenza.tsx @@ -1317,7 +1317,7 @@ export function HealthCheckCredenza(props: HealthCheckCredenzaProps) { {t( - "customHeaders" + "customRequestHeaders" )} @@ -1341,7 +1341,7 @@ export function HealthCheckCredenza(props: HealthCheckCredenzaProps) { {t( - "customHeadersDescription" + "customRequestHeadersDescription" )} diff --git a/src/components/HealthCheckFormFields.tsx b/src/components/HealthCheckFormFields.tsx index 6f5d528db..5b43e8a59 100644 --- a/src/components/HealthCheckFormFields.tsx +++ b/src/components/HealthCheckFormFields.tsx @@ -733,7 +733,7 @@ export function HealthCheckFormFields({ render={({ field }) => ( - {t("customHeaders")} + {t("customRequestHeaders")} {t( - "customHeadersDescription" + "customRequestHeadersDescription" )} From c8357e8653d825c266e41d6a6094018713943daa Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Wed, 27 May 2026 18:03:58 +0200 Subject: [PATCH 02/37] tested and translated! --- messages/bg-BG.json | 8 ++++---- messages/cs-CZ.json | 8 ++++---- messages/de-DE.json | 8 ++++---- messages/es-ES.json | 8 ++++---- messages/fr-FR.json | 8 ++++---- messages/it-IT.json | 8 ++++---- messages/ko-KR.json | 8 ++++---- messages/nb-NO.json | 8 ++++---- messages/nl-NL.json | 8 ++++---- messages/pl-PL.json | 8 ++++---- messages/pt-PT.json | 8 ++++---- messages/ru-RU.json | 8 ++++---- messages/tr-TR.json | 8 ++++---- messages/zh-CN.json | 8 ++++---- messages/zh-TW.json | 8 ++++---- 15 files changed, 60 insertions(+), 60 deletions(-) diff --git a/messages/bg-BG.json b/messages/bg-BG.json index 60f7225a9..9b6dd6986 100644 --- a/messages/bg-BG.json +++ b/messages/bg-BG.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Опити за повторно", "expectedResponseCodes": "Очаквани кодове за отговор", "expectedResponseCodesDescription": "HTTP статус код, указващ здравословно състояние. Ако бъде оставено празно, между 200-300 се счита за здравословно.", - "customRequestHeaders": "Персонализирани заглавия", - "customRequestHeadersDescription": "Add custom headers to be sent when proxying requests. One per line in the format Header-Name: value", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Персонализирани заглавия на заявката", + "customRequestHeadersDescription": "Заглавия на заявката, изпратени до целевите сървъри. По едно на ред: Заглавие-Име: стойност", + "customResponseHeaders": "Персонализирани заглавия на отговора", + "customResponseHeadersDescription": "Заглавия на отговора, върнати на клиента. По едно на ред: Заглавие-Име: стойност", "headersValidationError": "Заглавията трябва да бъдат във формат: Име на заглавието: стойност.", "saveHealthCheck": "Запазване на проверка на здравето", "healthCheckSaved": "Проверка на здравето е запазена", diff --git a/messages/cs-CZ.json b/messages/cs-CZ.json index be171bf09..0effc0c83 100644 --- a/messages/cs-CZ.json +++ b/messages/cs-CZ.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Opakovat pokusy", "expectedResponseCodes": "Očekávané kódy odezvy", "expectedResponseCodesDescription": "HTTP kód stavu, který označuje zdravý stav. Ponecháte-li prázdné, 200-300 je považováno za zdravé.", - "customRequestHeaders": "Vlastní záhlaví", - "customRequestHeadersDescription": "Záhlaví oddělená nová řádka: hodnota", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Vlastní záhlaví požadavku", + "customRequestHeadersDescription": "Záhlaví požadavku odeslaná do cílů. Jedno na řádek: Název-záhlaví: hodnota", + "customResponseHeaders": "Vlastní záhlaví odpovědi", + "customResponseHeadersDescription": "Záhlaví odpovědi vrácená klientovi. Jedno na řádek: Název-záhlaví: hodnota", "headersValidationError": "Headers must be in the format: Header-Name: value.", "saveHealthCheck": "Uložit kontrolu stavu", "healthCheckSaved": "Kontrola stavu uložena", diff --git a/messages/de-DE.json b/messages/de-DE.json index d61bf24b2..c009d2fd9 100644 --- a/messages/de-DE.json +++ b/messages/de-DE.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Wiederholungsversuche", "expectedResponseCodes": "Erwartete Antwortcodes", "expectedResponseCodesDescription": "HTTP-Statuscode, der einen gesunden Zustand anzeigt. Wenn leer gelassen, wird 200-300 als gesund angesehen.", - "customRequestHeaders": "Eigene Kopfzeilen", - "customRequestHeadersDescription": "Header neue Zeile getrennt: Header-Name: Wert", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Eigene Anfrage-Header", + "customRequestHeadersDescription": "Anfrage-Header, die an die Ziele gesendet werden. Eine pro Zeile: Header-Name: Wert", + "customResponseHeaders": "Eigene Antwort-Header", + "customResponseHeadersDescription": "Antwort-Header, die an den Client zurückgesendet werden. Eine pro Zeile: Header-Name: Wert", "headersValidationError": "Header müssen im Format Header-Name: Wert sein.", "saveHealthCheck": "Gesundheits-Check speichern", "healthCheckSaved": "Gesundheits-Check gespeichert", diff --git a/messages/es-ES.json b/messages/es-ES.json index 2b1e55381..08ba73040 100644 --- a/messages/es-ES.json +++ b/messages/es-ES.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Intentos de Reintento", "expectedResponseCodes": "Códigos de respuesta esperados", "expectedResponseCodesDescription": "Código de estado HTTP que indica un estado saludable. Si se deja en blanco, se considera saludable de 200 a 300.", - "customRequestHeaders": "Cabeceras personalizadas", - "customRequestHeadersDescription": "Nueva línea de cabeceras separada: Nombre de cabecera: valor", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Cabeceras de solicitud personalizadas", + "customRequestHeadersDescription": "Cabeceras de solicitud enviadas a los destinos. Una por línea: Nombre-Cabecera: valor", + "customResponseHeaders": "Cabeceras de respuesta personalizadas", + "customResponseHeadersDescription": "Cabeceras de respuesta devueltas al cliente. Una por línea: Nombre-Cabecera: valor", "headersValidationError": "Los encabezados deben estar en el formato: Nombre de cabecera: valor.", "saveHealthCheck": "Guardar Chequeo de Salud", "healthCheckSaved": "Chequeo de Salud Guardado", diff --git a/messages/fr-FR.json b/messages/fr-FR.json index d9a83e655..194e798ab 100644 --- a/messages/fr-FR.json +++ b/messages/fr-FR.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Tentatives de réessai", "expectedResponseCodes": "Codes de réponse attendus", "expectedResponseCodesDescription": "Code de statut HTTP indiquant un état de santé satisfaisant. Si non renseigné, 200-300 est considéré comme satisfaisant.", - "customRequestHeaders": "En-têtes personnalisés", - "customRequestHeadersDescription": "En-têtes séparés par une nouvelle ligne: En-nom: valeur", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "En-têtes de requête personnalisés", + "customRequestHeadersDescription": "En-têtes de requête envoyés aux cibles. Un par ligne : Nom-En-tête : valeur", + "customResponseHeaders": "En-têtes de réponse personnalisés", + "customResponseHeadersDescription": "En-têtes de réponse renvoyés au client. Un par ligne : Nom-En-tête : valeur", "headersValidationError": "Les entêtes doivent être au format : Header-Name: valeur.", "saveHealthCheck": "Sauvegarder la vérification de l'état de santé", "healthCheckSaved": "Vérification de l'état de santé enregistrée", diff --git a/messages/it-IT.json b/messages/it-IT.json index eac3ecde9..7e8cd68d7 100644 --- a/messages/it-IT.json +++ b/messages/it-IT.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Tentativi di Riprova", "expectedResponseCodes": "Codici di Risposta Attesi", "expectedResponseCodesDescription": "Codice di stato HTTP che indica lo stato di salute. Se lasciato vuoto, considerato sano è compreso tra 200-300.", - "customRequestHeaders": "Intestazioni Personalizzate", - "customRequestHeadersDescription": "Intestazioni nuova riga separate: Intestazione-Nome: valore", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Intestazioni di richiesta personalizzate", + "customRequestHeadersDescription": "Intestazioni di richiesta inviate ai target. Una per riga: Nome-Intestazione: valore", + "customResponseHeaders": "Intestazioni di risposta personalizzate", + "customResponseHeadersDescription": "Intestazioni di risposta restituite al client. Una per riga: Nome-Intestazione: valore", "headersValidationError": "Le intestazioni devono essere nel formato: Intestazione-Nome: valore.", "saveHealthCheck": "Salva Controllo Salute", "healthCheckSaved": "Controllo Salute Salvato", diff --git a/messages/ko-KR.json b/messages/ko-KR.json index 76facec3e..1f45379a6 100644 --- a/messages/ko-KR.json +++ b/messages/ko-KR.json @@ -1964,10 +1964,10 @@ "retryAttempts": "재시도 횟수", "expectedResponseCodes": "예상 응답 코드", "expectedResponseCodesDescription": "정상 상태를 나타내는 HTTP 상태 코드입니다. 비워 두면 200-300이 정상으로 간주됩니다.", - "customRequestHeaders": "사용자 정의 헤더", - "customRequestHeadersDescription": "헤더는 새 줄로 구분됨: Header-Name: value", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "사용자 정의 요청 헤더", + "customRequestHeadersDescription": "다운스트림 대상으로 전송되는 요청 헤더. 한 줄에 하나씩: 헤더-이름: 값", + "customResponseHeaders": "사용자 정의 응답 헤더", + "customResponseHeadersDescription": "클라이언트로 반환되는 응답 헤더. 한 줄에 하나씩: 헤더-이름: 값", "headersValidationError": "헤더는 형식이어야 합니다: 헤더명: 값.", "saveHealthCheck": "상태 확인 저장", "healthCheckSaved": "상태 확인이 저장되었습니다.", diff --git a/messages/nb-NO.json b/messages/nb-NO.json index 2aa54d52a..0fd21f858 100644 --- a/messages/nb-NO.json +++ b/messages/nb-NO.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Forsøk på nytt", "expectedResponseCodes": "Forventede svarkoder", "expectedResponseCodesDescription": "HTTP-statuskode som indikerer sunn status. Hvis den blir stående tom, regnes 200-300 som sunn.", - "customRequestHeaders": "Egendefinerte topptekster", - "customRequestHeadersDescription": "Overskrifter som er adskilt med linje: Overskriftsnavn: verdi", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Egendefinerte forespørselshoder", + "customRequestHeadersDescription": "Forespørselshoder sendt til målene. Én per linje: Header-Navn: verdi", + "customResponseHeaders": "Egendefinerte svarhoder", + "customResponseHeadersDescription": "Svarhoder sendt tilbake til klienten. Én per linje: Header-Navn: verdi", "headersValidationError": "Topptekst må være i formatet: header-navn: verdi.", "saveHealthCheck": "Lagre Helsekontroll", "healthCheckSaved": "Helsekontroll Lagret", diff --git a/messages/nl-NL.json b/messages/nl-NL.json index 29215eb93..fc1e96aba 100644 --- a/messages/nl-NL.json +++ b/messages/nl-NL.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Herhaal Pogingen", "expectedResponseCodes": "Verwachte Reactiecodes", "expectedResponseCodesDescription": "HTTP-statuscode die gezonde status aangeeft. Indien leeg wordt 200-300 als gezond beschouwd.", - "customRequestHeaders": "Aangepaste headers", - "customRequestHeadersDescription": "Kopregeleinde: Header-Naam: waarde", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Aangepaste verzoekheaders", + "customRequestHeadersDescription": "Verzoekheaders die worden doorgestuurd naar het doel. Per regel één: Header-Naam: waarde", + "customResponseHeaders": "Aangepaste antwoordheaders", + "customResponseHeadersDescription": "Antwoordheaders die worden teruggestuurd naar de client. Per regel één: Header-Naam: waarde", "headersValidationError": "Headers moeten in het formaat zijn: Header-Naam: waarde.", "saveHealthCheck": "Opslaan Gezondheidscontrole", "healthCheckSaved": "Gezondheidscontrole Opgeslagen", diff --git a/messages/pl-PL.json b/messages/pl-PL.json index 205b34ded..ebb8f0c28 100644 --- a/messages/pl-PL.json +++ b/messages/pl-PL.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Próby Ponowienia", "expectedResponseCodes": "Oczekiwane Kody Odpowiedzi", "expectedResponseCodesDescription": "Kod statusu HTTP, który wskazuje zdrowy status. Jeśli pozostanie pusty, uznaje się 200-300 za zdrowy.", - "customRequestHeaders": "Niestandardowe nagłówki", - "customRequestHeadersDescription": "Nagłówki oddzielone: Nazwa nagłówka: wartość", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Niestandardowe nagłówki żądania", + "customRequestHeadersDescription": "Nagłówki żądania wysyłane do celów. Jeden w wierszu: Nazwa-Nagłówka: wartość", + "customResponseHeaders": "Niestandardowe nagłówki odpowiedzi", + "customResponseHeadersDescription": "Nagłówki odpowiedzi zwracane do klienta. Jeden w wierszu: Nazwa-Nagłówka: wartość", "headersValidationError": "Nagłówki muszą być w formacie: Nazwa nagłówka: wartość.", "saveHealthCheck": "Zapisz Kontrolę Zdrowia", "healthCheckSaved": "Kontrola Zdrowia Zapisana", diff --git a/messages/pt-PT.json b/messages/pt-PT.json index b3086aa1c..697280c64 100644 --- a/messages/pt-PT.json +++ b/messages/pt-PT.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Tentativas de Repetição", "expectedResponseCodes": "Códigos de Resposta Esperados", "expectedResponseCodesDescription": "Código de status HTTP que indica estado saudável. Se deixado em branco, 200-300 é considerado saudável.", - "customRequestHeaders": "Cabeçalhos Personalizados", - "customRequestHeadersDescription": "Separados por cabeçalhos da nova linha: Nome do Cabeçalho: valor", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Cabeçalhos de Pedido Personalizados", + "customRequestHeadersDescription": "Cabeçalhos de pedido enviados para os destinos. Um por linha: Nome-Cabeçalho: valor", + "customResponseHeaders": "Cabeçalhos de Resposta Personalizados", + "customResponseHeadersDescription": "Cabeçalhos de resposta enviados de volta ao cliente. Um por linha: Nome-Cabeçalho: valor", "headersValidationError": "Cabeçalhos devem estar no formato: Nome do Cabeçalho: valor.", "saveHealthCheck": "Salvar Verificação de Saúde", "healthCheckSaved": "Verificação de Saúde Salva", diff --git a/messages/ru-RU.json b/messages/ru-RU.json index 556d1d35c..068762903 100644 --- a/messages/ru-RU.json +++ b/messages/ru-RU.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Количество попыток повторного запроса", "expectedResponseCodes": "Ожидаемые коды ответов", "expectedResponseCodesDescription": "HTTP-код состояния, указывающий на здоровое состояние. Если оставить пустым, 200-300 считается здоровым.", - "customRequestHeaders": "Пользовательские заголовки", - "customRequestHeadersDescription": "Заголовки новой строки, разделённые: название заголовка: значение", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Пользовательские заголовки запроса", + "customRequestHeadersDescription": "Заголовки запроса, отправляемые целевым серверам. По одному в строке: Имя-Заголовка: значение", + "customResponseHeaders": "Пользовательские заголовки ответа", + "customResponseHeadersDescription": "Заголовки ответа, возвращаемые клиенту. По одному в строке: Имя-Заголовка: значение", "headersValidationError": "Заголовки должны быть в формате: Название заголовка: значение.", "saveHealthCheck": "Сохранить проверку здоровья", "healthCheckSaved": "Проверка здоровья сохранена", diff --git a/messages/tr-TR.json b/messages/tr-TR.json index 3b5a324e2..00cc9f4b8 100644 --- a/messages/tr-TR.json +++ b/messages/tr-TR.json @@ -1964,10 +1964,10 @@ "retryAttempts": "Tekrar Deneme Girişimleri", "expectedResponseCodes": "Beklenen Yanıt Kodları", "expectedResponseCodesDescription": "Sağlıklı durumu gösteren HTTP durum kodu. Boş bırakılırsa, 200-300 arası sağlıklı kabul edilir.", - "customRequestHeaders": "Özel Başlıklar", - "customRequestHeadersDescription": "Başlıklar yeni satırla ayrılmış: Başlık-Adı: değer", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "Özel İstek Başlıkları", + "customRequestHeadersDescription": "Hedeflere gönderilen istek başlıkları. Satır başına bir tane: Başlık-Adı: değer", + "customResponseHeaders": "Özel Yanıt Başlıkları", + "customResponseHeadersDescription": "İstemciye geri gönderilen yanıt başlıkları. Satır başına bir tane: Başlık-Adı: değer", "headersValidationError": "Başlıklar şu formatta olmalıdır: Başlık-Adı: değer.", "saveHealthCheck": "Sağlık Kontrolünü Kaydet", "healthCheckSaved": "Sağlık Kontrolü Kaydedildi", diff --git a/messages/zh-CN.json b/messages/zh-CN.json index dd01d78f8..95b881ac3 100644 --- a/messages/zh-CN.json +++ b/messages/zh-CN.json @@ -1964,10 +1964,10 @@ "retryAttempts": "重试次数", "expectedResponseCodes": "期望响应代码", "expectedResponseCodesDescription": "HTTP 状态码表示健康状态。如留空,200-300 被视为健康。", - "customRequestHeaders": "自定义标题", - "customRequestHeadersDescription": "头部新行分隔:头部名称:值", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "自定义请求标头", + "customRequestHeadersDescription": "转发到目标的请求标头。每行一个:标头名称:值", + "customResponseHeaders": "自定义响应标头", + "customResponseHeadersDescription": "返回给客户端的响应标头。每行一个:标头名称:值", "headersValidationError": "头部必须是格式:头部名称:值。", "saveHealthCheck": "保存健康检查", "healthCheckSaved": "健康检查已保存", diff --git a/messages/zh-TW.json b/messages/zh-TW.json index e6c4a95f2..47d803b5d 100644 --- a/messages/zh-TW.json +++ b/messages/zh-TW.json @@ -1555,10 +1555,10 @@ "retryAttempts": "重試次數", "expectedResponseCodes": "期望響應代碼", "expectedResponseCodesDescription": "HTTP 狀態碼表示健康狀態。如留空,200-300 被視為健康。", - "customRequestHeaders": "自訂 Headers", - "customRequestHeadersDescription": "Header 斷行分隔:Header 名稱:值", - "customResponseHeaders": "Custom Response Headers", - "customResponseHeadersDescription": "Response headers sent back to the client. One per line: Header-Name: value", + "customRequestHeaders": "自訂請求 Headers", + "customRequestHeadersDescription": "轉發至目標的請求標頭。每行一個:Header-名稱:值", + "customResponseHeaders": "自訂回應 Headers", + "customResponseHeadersDescription": "回傳給客戶端的回應標頭。每行一個:Header-名稱:值", "headersValidationError": "Header 必須是格式:Header 名稱:值。", "saveHealthCheck": "保存健康檢查", "healthCheckSaved": "健康檢查已保存", From 6c7d345f033ca670f4d80806dfce573c4d5856dd Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Wed, 27 May 2026 18:05:43 +0200 Subject: [PATCH 03/37] Reverted package-lock.json --- package-lock.json | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index d06ae5554..8c241554a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1058,6 +1058,7 @@ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -3033,6 +3034,7 @@ "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": "^14.21.3 || >=16" }, @@ -6979,6 +6981,7 @@ "resolved": "https://registry.npmjs.org/@react-email/text/-/text-0.1.6.tgz", "integrity": "sha512-TYqkioRS45wTR5il3dYk/SbUjjEdhSwh9BtRNB99qNH1pXAwA45H7rAuxehiu8iJQJH0IyIr+6n62gBz9ezmsw==", "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -8439,6 +8442,7 @@ "version": "5.90.21", "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.21.tgz", "integrity": "sha512-0Lu6y5t+tvlTJMTO7oh5NSpJfpg/5D41LlThfepTixPYkJ0sE2Jj0m0f6yYqujBwIXlId87e234+MxG3D3g7kg==", + "peer": true, "dependencies": { "@tanstack/query-core": "5.90.20" }, @@ -8554,6 +8558,7 @@ "integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "@types/node": "*" } @@ -8901,6 +8906,7 @@ "integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^5.0.0", @@ -8996,6 +9002,7 @@ "integrity": "sha512-oX8xrhvpiyRCQkG1MFchB09f+cXftgIXb3a7UUa4Y3wpmZPw5tyZGTLWhlESOLq1Rq6oDlc8npVU2/9xiCuXMA==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~7.18.0" } @@ -9023,6 +9030,7 @@ "integrity": "sha512-gT+oueVQkqnj6ajGJXblFR4iavIXWsGAFCk3dP4Kki5+a9R4NMt0JARdk6s8cUKcfUoqP5dAtDSLU8xYUTFV+Q==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "@types/node": "*", "pg-protocol": "*", @@ -9048,6 +9056,7 @@ "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz", "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", "devOptional": true, + "peer": true, "dependencies": { "csstype": "^3.2.2" } @@ -9058,6 +9067,7 @@ "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", "devOptional": true, "license": "MIT", + "peer": true, "peerDependencies": { "@types/react": "^19.2.0" } @@ -9144,8 +9154,7 @@ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", "license": "MIT", - "optional": true, - "peer": true + "optional": true }, "node_modules/@types/ws": { "version": "8.18.1", @@ -9219,6 +9228,7 @@ "integrity": "sha512-klQbnPAAiGYFyI02+znpBRLyjL4/BrBd0nyWkdC0s/6xFLkXYQ8OoRrSkqacS1ddVxf/LDyODIKbQ5TgKAf/Fg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.56.1", "@typescript-eslint/types": "8.56.1", @@ -9692,6 +9702,7 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -10141,6 +10152,7 @@ "integrity": "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/types": "^7.26.0" } @@ -10212,6 +10224,7 @@ "integrity": "sha512-Ba0KR+Fzxh2jDRhdg6TSH0SJGzb8C0aBY4hR8w8madIdIzzC6Y1+kx5qR6eS1Z+Gy20h6ZU28aeyg0z1VIrShQ==", "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "bindings": "^1.5.0", "prebuild-install": "^7.1.1" @@ -10340,6 +10353,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -11246,6 +11260,7 @@ "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", "license": "ISC", + "peer": true, "engines": { "node": ">=12" } @@ -11686,7 +11701,6 @@ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.2.tgz", "integrity": "sha512-6obghkliLdmKa56xdbLOpUZ43pAR6xFy1uOrxBaIDjT+yaRuuybLjGS9eVBoSR/UPU5fq3OXClEHLJNGvbxKpQ==", "license": "(MPL-2.0 OR Apache-2.0)", - "peer": true, "engines": { "node": ">=20" }, @@ -12321,6 +12335,7 @@ "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "bin": { "esbuild": "bin/esbuild" }, @@ -12406,6 +12421,7 @@ "integrity": "sha512-COV33RzXZkqhG9P2rZCFl9ZmJ7WL+gQSCRzE7RhkbclbQPtLAWReL7ysA0Sh4c8Im2U9ynybdR56PV0XcKvqaQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -12542,6 +12558,7 @@ "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.9", @@ -12935,6 +12952,7 @@ "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", "license": "MIT", + "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", @@ -15352,7 +15370,6 @@ "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.55.1.tgz", "integrity": "sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==", "license": "MIT", - "peer": true, "dependencies": { "dompurify": "3.2.7", "marked": "14.0.0" @@ -15363,7 +15380,6 @@ "resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz", "integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==", "license": "MIT", - "peer": true, "bin": { "marked": "bin/marked.js" }, @@ -15452,6 +15468,7 @@ "resolved": "https://registry.npmjs.org/next/-/next-15.5.15.tgz", "integrity": "sha512-VSqCrJwtLVGwAVE0Sb/yikrQfkwkZW9p+lL/J4+xe+G3ZA+QnWPqgcfH1tDUEuk9y+pthzzVFp4L/U8JerMfMQ==", "license": "MIT", + "peer": true, "dependencies": { "@next/env": "15.5.15", "@swc/helpers": "0.5.15", @@ -16411,6 +16428,7 @@ "resolved": "https://registry.npmjs.org/pg/-/pg-8.20.0.tgz", "integrity": "sha512-ldhMxz2r8fl/6QkXnBD3CR9/xg694oT6DZQ2s6c/RI28OjtSOpxnPrUCGOBJ46RCUxcWdx3p6kw/xnDHjKvaRA==", "license": "MIT", + "peer": true, "dependencies": { "pg-connection-string": "^2.12.0", "pg-pool": "^3.13.0", @@ -16918,6 +16936,7 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz", "integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==", "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -16949,6 +16968,7 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz", "integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==", "license": "MIT", + "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -17241,6 +17261,7 @@ "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.71.2.tgz", "integrity": "sha512-1CHvcDYzuRUNOflt4MOq3ZM46AronNJtQ1S7tnX6YN4y72qhgiUItpacZUAQ0TyWYci3yz1X+rXaSxiuEm86PA==", "license": "MIT", + "peer": true, "engines": { "node": ">=18.0.0" }, @@ -18702,7 +18723,8 @@ "version": "4.2.2", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.2.tgz", "integrity": "sha512-KWBIxs1Xb6NoLdMVqhbhgwZf2PGBpPEiwOqgI4pFIYbNTfBXiKYyWoTsXgBQ9WFg/OlhnvHaY+AEpW7wSmFo2Q==", - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/tapable": { "version": "2.3.2", @@ -19177,6 +19199,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -19604,6 +19627,7 @@ "resolved": "https://registry.npmjs.org/winston/-/winston-3.19.0.tgz", "integrity": "sha512-LZNJgPzfKR+/J3cHkxcpHKpKKvGfDZVPS4hfJCc4cCG0CgYzvlD6yE/S3CIL/Yt91ak327YCpiF/0MyeZHEHKA==", "license": "MIT", + "peer": true, "dependencies": { "@colors/colors": "^1.6.0", "@dabh/diagnostics": "^2.0.8", @@ -19810,6 +19834,7 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } From 9d6062619c2dd1e2dc438a4377e40b91378b00fc Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Wed, 27 May 2026 18:21:52 +0200 Subject: [PATCH 04/37] Forgot about blueprints --- server/lib/blueprints/proxyResources.ts | 18 ++++++++++++++---- server/lib/blueprints/types.ts | 4 +++- server/routers/resource/getResource.ts | 5 +++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/server/lib/blueprints/proxyResources.ts b/server/lib/blueprints/proxyResources.ts index 178991962..6fac02122 100644 --- a/server/lib/blueprints/proxyResources.ts +++ b/server/lib/blueprints/proxyResources.ts @@ -210,8 +210,16 @@ export async function updateProxyResources( ? true : resourceData.ssl; let headers = ""; - if (resourceData.headers) { - headers = JSON.stringify(resourceData.headers); + const requestHeadersData = [ + ...(resourceData.headers ?? []), + ...(resourceData.requestHeaders ?? []) + ]; + if (requestHeadersData.length > 0) { + headers = JSON.stringify(requestHeadersData); + } + let responseHeaders = ""; + if (resourceData.responseHeaders) { + responseHeaders = JSON.stringify(resourceData.responseHeaders); } if (existingResource) { @@ -265,7 +273,8 @@ export async function updateProxyResources( ] ? resourceData.auth["whitelist-users"].length > 0 : false, - headers: headers || null, + requestHeaders: headers || null, + responseHeaders: responseHeaders || null, applyRules: resourceData.rules && resourceData.rules.length > 0, maintenanceModeEnabled: @@ -724,7 +733,8 @@ export async function updateProxyResources( setHostHeader: resourceData["host-header"] || null, tlsServerName: resourceData["tls-server-name"] || null, ssl: resourceSsl, - headers: headers || null, + requestHeaders: headers || null, + responseHeaders: responseHeaders || null, applyRules: resourceData.rules && resourceData.rules.length > 0, maintenanceModeEnabled: resourceData.maintenance?.enabled, diff --git a/server/lib/blueprints/types.ts b/server/lib/blueprints/types.ts index 13f4caa8f..2bff77d10 100644 --- a/server/lib/blueprints/types.ts +++ b/server/lib/blueprints/types.ts @@ -175,7 +175,9 @@ export const ResourceSchema = z auth: AuthSchema.optional(), "host-header": z.string().optional(), "tls-server-name": z.string().optional(), - headers: z.array(HeaderSchema).optional(), + headers: z.array(HeaderSchema).optional(), // deprecated alias for requestHeaders + requestHeaders: z.array(HeaderSchema).optional(), + responseHeaders: z.array(HeaderSchema).optional(), rules: z.array(RuleSchema).optional(), maintenance: MaintenanceSchema.optional() }) diff --git a/server/routers/resource/getResource.ts b/server/routers/resource/getResource.ts index bbd58320c..d63012f18 100644 --- a/server/routers/resource/getResource.ts +++ b/server/routers/resource/getResource.ts @@ -43,9 +43,10 @@ async function query(resourceId?: number, niceId?: string, orgId?: string) { export type GetResourceResponse = Omit< NonNullable>>, - "headers" + "requestHeaders" | "responseHeaders" > & { - headers: { name: string; value: string }[] | null; + requestHeaders: { name: string; value: string }[] | null; + responseHeaders: { name: string; value: string }[] | null; }; registry.registerPath({ From 382f5d52184dcb7b712d15427b8cd87a4b625eef Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Wed, 27 May 2026 18:36:33 +0200 Subject: [PATCH 05/37] Fixed copilot issue. --- server/lib/blueprints/proxyResources.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/server/lib/blueprints/proxyResources.ts b/server/lib/blueprints/proxyResources.ts index 6fac02122..f0194c650 100644 --- a/server/lib/blueprints/proxyResources.ts +++ b/server/lib/blueprints/proxyResources.ts @@ -209,18 +209,17 @@ export async function updateProxyResources( resourceData.ssl == undefined || resourceData.ssl == null ? true : resourceData.ssl; - let headers = ""; const requestHeadersData = [ ...(resourceData.headers ?? []), ...(resourceData.requestHeaders ?? []) ]; - if (requestHeadersData.length > 0) { - headers = JSON.stringify(requestHeadersData); - } - let responseHeaders = ""; - if (resourceData.responseHeaders) { - responseHeaders = JSON.stringify(resourceData.responseHeaders); - } + const requestHeadersJson = + requestHeadersData.length > 0 + ? JSON.stringify(requestHeadersData) + : null; + const responseHeadersJson = resourceData.responseHeaders + ? JSON.stringify(resourceData.responseHeaders) + : null; if (existingResource) { let domain; @@ -273,8 +272,8 @@ export async function updateProxyResources( ] ? resourceData.auth["whitelist-users"].length > 0 : false, - requestHeaders: headers || null, - responseHeaders: responseHeaders || null, + requestHeaders: requestHeadersJson, + responseHeaders: responseHeadersJson, applyRules: resourceData.rules && resourceData.rules.length > 0, maintenanceModeEnabled: @@ -733,8 +732,8 @@ export async function updateProxyResources( setHostHeader: resourceData["host-header"] || null, tlsServerName: resourceData["tls-server-name"] || null, ssl: resourceSsl, - requestHeaders: headers || null, - responseHeaders: responseHeaders || null, + requestHeaders: requestHeadersJson, + responseHeaders: responseHeadersJson, applyRules: resourceData.rules && resourceData.rules.length > 0, maintenanceModeEnabled: resourceData.maintenance?.enabled, From 8dee505eb25ec517f4515df4d5f2da7d590bfbf4 Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Wed, 27 May 2026 18:38:56 +0200 Subject: [PATCH 06/37] Fixed copilot issue. --- server/setup/scriptsSqlite/1.18.5.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/setup/scriptsSqlite/1.18.5.ts b/server/setup/scriptsSqlite/1.18.5.ts index 2edd523f0..d72d801a8 100644 --- a/server/setup/scriptsSqlite/1.18.5.ts +++ b/server/setup/scriptsSqlite/1.18.5.ts @@ -15,19 +15,20 @@ export default async function migration() { db.transaction(() => { db.prepare( - `ALTER TABLE 'resources' RENAME COLUMN 'headers' TO 'requestHeaders';` + `ALTER TABLE "resources" RENAME COLUMN "headers" TO "requestHeaders";` ).run(); db.prepare( - `ALTER TABLE 'resources' ADD 'responseHeaders' text;` + `ALTER TABLE "resources" ADD "responseHeaders" text;` ).run(); })(); - db.pragma("foreign_keys = ON"); - console.log("Migrated database"); } catch (e) { console.log("Failed to migrate db:", e); throw e; + } finally { + db.pragma("foreign_keys = ON"); + db.close(); } console.log(`${version} migration complete`); From 6952d3bee7cde9409d5a51fd68960bc17cca5a5d Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Wed, 27 May 2026 18:42:00 +0200 Subject: [PATCH 07/37] Fixed copilot issue. --- server/routers/resource/updateResource.ts | 28 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/server/routers/resource/updateResource.ts b/server/routers/resource/updateResource.ts index fc8416282..97513dcb1 100644 --- a/server/routers/resource/updateResource.ts +++ b/server/routers/resource/updateResource.ts @@ -24,7 +24,10 @@ import { import { registry } from "@server/openApi"; import { OpenAPITags } from "@server/openApi"; import { createCertificate } from "#dynamic/routers/certificates/createCertificate"; -import { validateAndConstructDomain, checkWildcardDomainConflict } from "@server/lib/domainUtils"; +import { + validateAndConstructDomain, + checkWildcardDomainConflict +} from "@server/lib/domainUtils"; import { build } from "@server/build"; import { isLicensedOrSubscribed } from "#dynamic/lib/isLicencedOrSubscribed"; import { tierMatrix } from "@server/lib/billing/tierMatrix"; @@ -58,6 +61,10 @@ const updateHttpResourceBodySchema = z tlsServerName: z.string().nullable().optional(), setHostHeader: z.string().nullable().optional(), skipToIdpId: z.int().positive().nullable().optional(), + headers: z + .array(z.strictObject({ name: z.string(), value: z.string() })) + .nullable() + .optional(), // deprecated alias for requestHeaders requestHeaders: z .array(z.strictObject({ name: z.string(), value: z.string() })) .nullable() @@ -117,6 +124,7 @@ const updateHttpResourceBodySchema = z (data) => { const validHeaderName = /^[a-zA-Z0-9!#$%&'*+\-.^_`|~]+$/; const allHeaders = [ + ...(data.headers ?? []), ...(data.requestHeaders ?? []), ...(data.responseHeaders ?? []) ]; @@ -130,6 +138,7 @@ const updateHttpResourceBodySchema = z (data) => { const validHeaderValue = /^[\t\x20-\x7E]*$/; const allHeaders = [ + ...(data.headers ?? []), ...(data.requestHeaders ?? []), ...(data.responseHeaders ?? []) ]; @@ -143,6 +152,7 @@ const updateHttpResourceBodySchema = z (data) => { const templatePattern = /\{\{[^}]+\}\}/; const allHeaders = [ + ...(data.headers ?? []), ...(data.requestHeaders ?? []), ...(data.responseHeaders ?? []) ]; @@ -470,10 +480,18 @@ async function updateHttpResource( } let requestHeaders = undefined; - if (updateData.requestHeaders) { - requestHeaders = JSON.stringify(updateData.requestHeaders); - } else if (updateData.requestHeaders === null) { - requestHeaders = null; + const mergedRequestHeaders = [ + ...(updateData.headers ?? []), + ...(updateData.requestHeaders ?? []) + ]; + if ( + updateData.headers !== undefined || + updateData.requestHeaders !== undefined + ) { + requestHeaders = + mergedRequestHeaders.length > 0 + ? JSON.stringify(mergedRequestHeaders) + : null; } let responseHeaders = undefined; From 713e24503db0562f81eada4e0062466d061a440e Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Wed, 27 May 2026 20:33:10 +0200 Subject: [PATCH 08/37] Removed migrations --- server/setup/migrationsPg.ts | 4 +--- server/setup/migrationsSqlite.ts | 4 +--- server/setup/scriptsPg/1.18.5.ts | 30 ------------------------ server/setup/scriptsSqlite/1.18.5.ts | 35 ---------------------------- 4 files changed, 2 insertions(+), 71 deletions(-) delete mode 100644 server/setup/scriptsPg/1.18.5.ts delete mode 100644 server/setup/scriptsSqlite/1.18.5.ts diff --git a/server/setup/migrationsPg.ts b/server/setup/migrationsPg.ts index 1a7d530c4..0b8af06bc 100644 --- a/server/setup/migrationsPg.ts +++ b/server/setup/migrationsPg.ts @@ -25,7 +25,6 @@ import m16 from "./scriptsPg/1.17.0"; import m17 from "./scriptsPg/1.18.0"; import m18 from "./scriptsPg/1.18.3"; import m19 from "./scriptsPg/1.18.4"; -import m20 from "./scriptsPg/1.18.5"; // THIS CANNOT IMPORT ANYTHING FROM THE SERVER // EXCEPT FOR THE DATABASE AND THE SCHEMA @@ -50,8 +49,7 @@ const migrations = [ { version: "1.17.0", run: m16 }, { version: "1.18.0", run: m17 }, { version: "1.18.3", run: m18 }, - { version: "1.18.4", run: m19 }, - { version: "1.18.5", run: m20 } + { version: "1.18.4", run: m19 } // Add new migrations here as they are created ] as { version: string; diff --git a/server/setup/migrationsSqlite.ts b/server/setup/migrationsSqlite.ts index 75f414c75..837b039f7 100644 --- a/server/setup/migrationsSqlite.ts +++ b/server/setup/migrationsSqlite.ts @@ -43,7 +43,6 @@ import m37 from "./scriptsSqlite/1.17.0"; import m38 from "./scriptsSqlite/1.18.0"; import m39 from "./scriptsSqlite/1.18.3"; import m40 from "./scriptsSqlite/1.18.4"; -import m41 from "./scriptsSqlite/1.18.5"; // THIS CANNOT IMPORT ANYTHING FROM THE SERVER // EXCEPT FOR THE DATABASE AND THE SCHEMA @@ -84,8 +83,7 @@ const migrations = [ { version: "1.17.0", run: m37 }, { version: "1.18.0", run: m38 }, { version: "1.18.3", run: m39 }, - { version: "1.18.4", run: m40 }, - { version: "1.18.5", run: m41 } + { version: "1.18.4", run: m40 } // Add new migrations here as they are created ] as const; diff --git a/server/setup/scriptsPg/1.18.5.ts b/server/setup/scriptsPg/1.18.5.ts deleted file mode 100644 index 5bceb41cf..000000000 --- a/server/setup/scriptsPg/1.18.5.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { db } from "@server/db/pg/driver"; -import { sql } from "drizzle-orm"; - -const version = "1.18.5"; - -export default async function migration() { - console.log(`Running setup script ${version}...`); - - try { - await db.execute(sql`BEGIN`); - - await db.execute(sql` - ALTER TABLE "resources" RENAME COLUMN "headers" TO "requestHeaders"; - `); - - await db.execute(sql` - ALTER TABLE "resources" ADD COLUMN "responseHeaders" text; - `); - - await db.execute(sql`COMMIT`); - console.log("Migrated database"); - } catch (e) { - await db.execute(sql`ROLLBACK`); - console.log("Unable to migrate database"); - console.log(e); - throw e; - } - - console.log(`${version} migration complete`); -} diff --git a/server/setup/scriptsSqlite/1.18.5.ts b/server/setup/scriptsSqlite/1.18.5.ts deleted file mode 100644 index d72d801a8..000000000 --- a/server/setup/scriptsSqlite/1.18.5.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { APP_PATH } from "@server/lib/consts"; -import Database from "better-sqlite3"; -import path from "path"; - -const version = "1.18.5"; - -export default async function migration() { - console.log(`Running setup script ${version}...`); - - const location = path.join(APP_PATH, "db", "db.sqlite"); - const db = new Database(location); - - try { - db.pragma("foreign_keys = OFF"); - - db.transaction(() => { - db.prepare( - `ALTER TABLE "resources" RENAME COLUMN "headers" TO "requestHeaders";` - ).run(); - db.prepare( - `ALTER TABLE "resources" ADD "responseHeaders" text;` - ).run(); - })(); - - console.log("Migrated database"); - } catch (e) { - console.log("Failed to migrate db:", e); - throw e; - } finally { - db.pragma("foreign_keys = ON"); - db.close(); - } - - console.log(`${version} migration complete`); -} From a8c1ddb4481d39c37700d7b5f968fe80b506cab4 Mon Sep 17 00:00:00 2001 From: Julian van der Horst Date: Tue, 7 Jul 2026 11:57:43 +0200 Subject: [PATCH 09/37] Merge should be complete --- server/lib/blueprints/proxyResources.ts | 0 server/lib/blueprints/publicResources.ts | 25 +++++++++++++------ server/routers/resource/updateResource.ts | 6 ++++- .../resources/proxy/[niceId]/proxy/page.tsx | 0 4 files changed, 23 insertions(+), 8 deletions(-) delete mode 100644 server/lib/blueprints/proxyResources.ts delete mode 100644 src/app/[orgId]/settings/resources/proxy/[niceId]/proxy/page.tsx diff --git a/server/lib/blueprints/proxyResources.ts b/server/lib/blueprints/proxyResources.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/server/lib/blueprints/publicResources.ts b/server/lib/blueprints/publicResources.ts index 92d6239fa..03e3a724a 100644 --- a/server/lib/blueprints/publicResources.ts +++ b/server/lib/blueprints/publicResources.ts @@ -237,10 +237,18 @@ export async function updatePublicResources( resourceData.ssl == undefined || resourceData.ssl == null ? true : resourceData.ssl; - let headers = ""; - if (resourceData.headers) { - headers = JSON.stringify(resourceData.headers); - } + // `headers` is a deprecated alias for `requestHeaders` + const mergedRequestHeaders = [ + ...(resourceData.headers ?? []), + ...(resourceData.requestHeaders ?? []) + ]; + const requestHeaders = + mergedRequestHeaders.length > 0 + ? JSON.stringify(mergedRequestHeaders) + : null; + const responseHeaders = resourceData.responseHeaders?.length + ? JSON.stringify(resourceData.responseHeaders) + : null; if (["ssh", "rdp", "vnc"].includes(resourceData.mode || "")) { const isLicensed = await isLicensedOrSubscribed( @@ -380,7 +388,8 @@ export async function updatePublicResources( ? resourceData.auth["whitelist-users"].length > 0 : false, - headers: headers || null, + requestHeaders, + responseHeaders, applyRules: resourceData.rules && resourceData.rules.length > 0, @@ -566,7 +575,8 @@ export async function updatePublicResources( setHostHeader: resourceData["host-header"] || null, tlsServerName: resourceData["tls-server-name"] || null, - headers: headers || null, + requestHeaders, + responseHeaders, maintenanceModeEnabled: resourceData.maintenance?.enabled, maintenanceModeType: resourceData.maintenance?.type, @@ -1152,7 +1162,8 @@ export async function updatePublicResources( setHostHeader: resourceData["host-header"] || null, tlsServerName: resourceData["tls-server-name"] || null, ssl: resourceSsl, - headers: headers || null, + requestHeaders, + responseHeaders, applyRules: resourceData.rules && resourceData.rules.length > 0, pamMode: resourceData["auth-daemon"]?.pam || "passthrough", diff --git a/server/routers/resource/updateResource.ts b/server/routers/resource/updateResource.ts index 532ba2b25..fd2e8c37e 100644 --- a/server/routers/resource/updateResource.ts +++ b/server/routers/resource/updateResource.ts @@ -663,6 +663,10 @@ async function updateHttpResource( responseHeaders = null; } + updateData.headers = undefined; + updateData.requestHeaders = undefined; + updateData.responseHeaders = undefined; + if (!isLicensed) { updateData.maintenanceModeEnabled = undefined; updateData.maintenanceModeType = undefined; @@ -715,7 +719,7 @@ async function updateHttpResource( const updatedResource = await db .update(resources) - .set({ ...resourceOnlyData, headers }) + .set({ ...resourceOnlyData, requestHeaders, responseHeaders }) .where(eq(resources.resourceId, resource.resourceId)) .returning(); diff --git a/src/app/[orgId]/settings/resources/proxy/[niceId]/proxy/page.tsx b/src/app/[orgId]/settings/resources/proxy/[niceId]/proxy/page.tsx deleted file mode 100644 index e69de29bb..000000000 From 3564674bedabf9b6b96c10bb89790cc8ee77cc63 Mon Sep 17 00:00:00 2001 From: Tim <82370418+Tim5965@users.noreply.github.com> Date: Wed, 29 Jul 2026 15:29:31 +0200 Subject: [PATCH 10/37] Update nl-NL.json Also did them on crowdin, but think there is some difference between the files --- messages/nl-NL.json | 84 ++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/messages/nl-NL.json b/messages/nl-NL.json index f914a3c80..a7dd85a91 100644 --- a/messages/nl-NL.json +++ b/messages/nl-NL.json @@ -13,7 +13,7 @@ "orgDisplayName": "Dit is de weergavenaam van de organisatie.", "orgId": "Organisatie ID", "setupIdentifierMessage": "Dit is de unieke identificatie voor de organisatie.", - "setupErrorIdentifier": "Organisatie-ID is al in gebruik. Kies een andere.", + "setupErrorIdentifier": "Organisatie ID is al in gebruik, verzin iets anders.", "componentsErrorNoMemberCreate": "U bent momenteel geen lid van een organisatie. Maak een organisatie aan om aan de slag te gaan.", "componentsErrorNoMember": "U bent momenteel geen lid van een organisatie.", "welcome": "Welkom bij Pangolin!", @@ -78,7 +78,7 @@ "siteManageSites": "Sites beheren", "siteDescription": "Maak en beheer sites om verbinding met privénetwerken in te schakelen", "sitesBannerTitle": "Verbind elk netwerk", - "sitesBannerDescription": "Een site is een verbinding met een extern netwerk waarmee Pangolin toegang biedt tot bronnen, zowel openbaar als privé, aan gebruikers overal. Installeer de sitedatacenterconnector (Newt) overal waar je een binaire of container kunt uitvoeren om de verbinding tot stand te brengen.", + "sitesBannerDescription": "Een site is een verbinding met een extern netwerk waarmee Pangolin toegang biedt voor gebruikers voor bronnen, zowel openbaar als privé. Installeer de sitedatacenterconnector (Newt) overal waar je een binaire of container kunt uitvoeren om de verbinding tot stand te brengen.", "sitesBannerButtonText": "Site installeren", "approvalsBannerTitle": "Toegang tot het apparaat goedkeuren of weigeren", "approvalsBannerDescription": "Bekijk en keur toestelverzoeken goed of weiger toegang van gebruikers. Wanneer apparaatgoedkeuringen vereist zijn, moeten gebruikers de goedkeuring van beheerders krijgen voordat hun apparaten verbinding kunnen maken met de bronnen van uw organisatie.", @@ -219,12 +219,12 @@ "shareErrorSelectResource": "Selecteer een bron", "proxyResourceTitle": "Openbare bronnen beheren", "proxyResourceDescription": "Creëer en beheer bronnen die openbaar toegankelijk zijn via een webbrowser", - "publicResourcesBannerTitle": "Web-gebaseerde Openbare Toegang", - "publicResourcesBannerDescription": "Openbare bronnen zijn HTTPS-proxies die toegankelijk zijn voor iedereen op het internet via een webbrowser. In tegenstelling tot privébronnen hoeven ze geen client-software te hebben en kunnen ze identiteit- en context bewuste toegangsmiddelen bevatten.", + "publicResourcesBannerTitle": "Webgebaseerde openbare bronnen", + "publicResourcesBannerDescription": "Openbare bronnen zijn HTTPS proxy's die te bereiken zijn voor iedereen op het internet via een webbrowser. Het is mogelijk om deze te beveiligen door identiteitscontrole of een toegangsbeleid. In tegenstelling tot privébronnen hoeven ze geen clientsoftware te installeren.", "clientResourceTitle": "Privébronnen beheren", "clientResourceDescription": "Creëer en beheer bronnen die alleen toegankelijk zijn via een verbonden client", - "privateResourcesBannerTitle": "Zero-Trust Private Access", - "privateResourcesBannerDescription": "Privé bronnen maken gebruik van zero-trust-beveiliging, wat ervoor zorgt dat gebruikers en machines alleen toegang kunnen krijgen tot middelen die jij specifiek toestaat. Verbind gebruikersapparaten of machineclients om deze middelen te benaderen via een veilig virtueel priv��netwerk.", + "privateResourcesBannerTitle": "Privébronnen via Zero Trust", + "privateResourcesBannerDescription": "Privébronnen maken gebruik van zero trust beveiliging, wat ervoor zorgt dat gebruikers en machines alleen toegang kunnen krijgen tot resources die je specifiek toestaat. Verbind gebruikersapparaten of machines om deze middelen te benaderen via een veilig, virtueel privénetwerk.", "resourcesSearch": "Zoek bronnen...", "resourceAdd": "Bron toevoegen", "resourceErrorDelte": "Fout bij verwijderen document", @@ -253,7 +253,7 @@ "resourcePolicyUsersRolesDescription": "Bepaal welke gebruikers en rollen geassocieerde bronnen kunnen bezoeken", "rulesResourcePolicyDescription": "Stel regels in om toegang te regelen tot bronnen die zijn gekoppeld aan dit beleid", "authentication": "Authenticatie", - "protected": "Beschermd", + "protected": "Beveiligd", "notProtected": "Niet beveiligd", "resourceMessageRemove": "Eenmaal verwijderd, zal het bestand niet langer toegankelijk zijn. Alle doelen die gekoppeld zijn aan het hulpbron, zullen ook verwijderd worden.", "resourceQuestionRemove": "Weet u zeker dat u het document van de organisatie wilt verwijderen?", @@ -324,7 +324,7 @@ "labelEdit": "Label bewerken", "editLabelDialogTitle": "Label bijwerken", "editLabelDialogDescription": "Bewerk een nieuw label dat aan deze organisatie kan worden gekoppeld", - "labelDeleteConfirm": "Bevestigen Verwijderen Label", + "labelDeleteConfirm": "Label verwijderen", "labelErrorDelete": "Kan label niet verwijderen", "labelMessageRemove": "Deze handeling is definitief. Alle sites, bronnen en klanten met dit label zullen worden onttakeld.", "labelQuestionRemove": "Weet u zeker dat u het label uit de organisatie wilt verwijderen?", @@ -409,40 +409,40 @@ "years": "Jaar", "day": "{count, plural, one {# dag} other {# dagen}}", "apiKeysTitle": "API Key Informatie", - "apiKeysConfirmCopy2": "Bevestig dat u de API-sleutel hebt gekopieerd.", - "apiKeysErrorCreate": "Fout bij maken API-sleutel", + "apiKeysConfirmCopy2": "Bevestig dat u de API sleutel hebt gekopieerd.", + "apiKeysErrorCreate": "Fout bij maken API sleutel", "apiKeysErrorSetPermission": "Fout instellen permissies", - "apiKeysCreate": "API-sleutel genereren", - "apiKeysCreateDescription": "Een nieuwe API-sleutel voor de organisatie genereren", + "apiKeysCreate": "API sleutel genereren", + "apiKeysCreateDescription": "Een nieuwe API sleutel voor de organisatie genereren", "apiKeysGeneralSettings": "Machtigingen", - "apiKeysGeneralSettingsDescription": "Bepaal wat deze API-sleutel kan doen", - "apiKeysList": "Nieuwe API-sleutel", - "apiKeysSave": "De API-sleutel opslaan", + "apiKeysGeneralSettingsDescription": "Bepaal wat deze API sleutel kan doen", + "apiKeysList": "Nieuwe API sleutel", + "apiKeysSave": "De API sleutel opslaan", "apiKeysSaveDescription": "Je kunt dit slechts één keer zien. Kopieer het naar een veilige plek.", - "apiKeysInfo": "De API-sleutel is:", - "apiKeysConfirmCopy": "Ik heb de API-sleutel gekopieerd", + "apiKeysInfo": "De API sleutel is:", + "apiKeysConfirmCopy": "Ik heb de API sleutel gekopieerd", "generate": "Genereren", "done": "Voltooid", - "apiKeysSeeAll": "Alle API-sleutels bekijken", + "apiKeysSeeAll": "Alle API sleutels bekijken", "apiKeysPermissionsErrorLoadingActions": "Fout bij het laden van API key acties", "apiKeysPermissionsErrorUpdate": "Fout instellen permissies", "apiKeysPermissionsUpdated": "Permissies bijgewerkt", "apiKeysPermissionsUpdatedDescription": "De bevoegdheden zijn bijgewerkt.", "apiKeysPermissionsGeneralSettings": "Machtigingen", - "apiKeysPermissionsGeneralSettingsDescription": "Bepaal wat deze API-sleutel kan doen", + "apiKeysPermissionsGeneralSettingsDescription": "Bepaal wat deze API sleutel kan doen", "apiKeysPermissionsSave": "Rechten opslaan", "apiKeysPermissionsTitle": "Machtigingen", "apiKeys": "API sleutels", - "searchApiKeys": "API-sleutels zoeken...", - "apiKeysAdd": "API-sleutel genereren", - "apiKeysErrorDelete": "Fout bij verwijderen API-sleutel", - "apiKeysErrorDeleteMessage": "Fout bij verwijderen API-sleutel", - "apiKeysQuestionRemove": "Weet u zeker dat u de API-sleutel van de organisatie wilt verwijderen?", - "apiKeysMessageRemove": "Eenmaal verwijderd, kan de API-sleutel niet meer worden gebruikt.", - "apiKeysDeleteConfirm": "Bevestig Verwijderen API-sleutel", - "apiKeysDelete": "API-sleutel verwijderen", - "apiKeysManage": "API-sleutels beheren", - "apiKeysDescription": "API-sleutels worden gebruikt om te verifiëren met de integratie-API", + "searchApiKeys": "API sleutels zoeken...", + "apiKeysAdd": "API sleutel genereren", + "apiKeysErrorDelete": "Fout bij verwijderen API sleutel", + "apiKeysErrorDeleteMessage": "Fout bij verwijderen API- leutel", + "apiKeysQuestionRemove": "Weet u zeker dat u de API sleutel van de organisatie wilt verwijderen?", + "apiKeysMessageRemove": "Eenmaal verwijderd, kan de APIsleutel niet meer worden gebruikt.", + "apiKeysDeleteConfirm": "Bevestig verwijderen API sleutel", + "apiKeysDelete": "API sleutel verwijderen", + "apiKeysManage": "API sleutels beheren", + "apiKeysDescription": "API sleutels worden gebruikt om te verifiëren met de integratie-API", "provisioningKeysTitle": "Vertrekkende sleutel", "provisioningKeysManage": "Beheren van Provisioning Sleutels", "provisioningKeysDescription": "Provisionerende sleutels worden gebruikt om geautomatiseerde sitebepaling voor uw organisatie te verifiëren.", @@ -906,7 +906,7 @@ "resourcesUsersRolesAccess": "Gebruiker en rol-gebaseerde toegangsbeheer", "resourcesErrorUpdate": "Bron wisselen mislukt", "resourcesErrorUpdateDescription": "Er is een fout opgetreden tijdens het bijwerken van het document", - "access": "Toegangsrechten", + "access": "Link", "accessControl": "Toegangs controle", "shareLink": "{resource} Deelbare Link", "resourceSelect": "Selecteer resource", @@ -1480,11 +1480,11 @@ "actionCheckOrgId": "ID controleren", "actionCreateOrg": "Nieuwe organisatie aanmaken", "actionDeleteOrg": "Verwijder organisatie", - "actionListApiKeys": "API-sleutels weergeven", + "actionListApiKeys": "API sleutels weergeven", "actionListApiKeyActions": "Lijst van API Key Acties", "actionSetApiKeyActions": "Stel API Key Toegestane Acties", - "actionCreateApiKey": "API-sleutel aanmaken", - "actionDeleteApiKey": "API-sleutel verwijderen", + "actionCreateApiKey": "API sleutel aanmaken", + "actionDeleteApiKey": "API sleutel verwijderen", "actionCreateIdp": "IDP aanmaken", "actionUpdateIdp": "IDP bijwerken", "actionDeleteIdp": "Verwijder IDP", @@ -1550,7 +1550,7 @@ "commandPaletteCreateProxyResource": "Maak Openbare Bron", "commandPaletteCreatePrivateResource": "Maak Privébron", "commandPaletteCreateUser": "Gebruiker aanmaken", - "commandPaletteCreateApiKey": "API-sleutel aanmaken", + "commandPaletteCreateApiKey": "API sleutel aanmaken", "commandPaletteCreateMachineClient": "Machineclient aanmaken", "commandPaletteCreateAlertRule": "Alarmregel aanmaken", "commandPaletteCreateIdentityProvider": "Identiteitsprovider aanmaken", @@ -1598,10 +1598,10 @@ "authErrorNoUpdate": "Geen authenticatie informatie om bij te werken", "orgErrorNoUpdate": "Geen org om bij te werken", "orgErrorNoProvided": "Geen org opgegeven", - "apiKeysErrorNoUpdate": "Geen API-sleutel om bij te werken", + "apiKeysErrorNoUpdate": "Geen API sleutel om bij te werken", "sidebarOverview": "Overzicht.", "sidebarHome": "Startpagina", - "sidebarSites": "Werkruimtes", + "sidebarSites": "Sites", "sidebarApprovals": "Goedkeuringsverzoeken", "sidebarResources": "Bronnen", "sidebarProxyResources": "Openbaar", @@ -1671,8 +1671,8 @@ "commandBilling": "Facturering", "commandEnterpriseLicenses": "Licentie", "commandSettings": "Instellingen", - "commandLauncher": "Startprogramma", - "commandResourceLauncher": "Bron Startprogramma", + "commandLauncher": "Startpagina", + "commandResourceLauncher": "Bron startpagina", "commandSearchResults": "Zoekresultaten", "alertingTitle": "Waarschuwingen", "alertingDescription": "Definieer bronnen, triggers en acties voor meldingen", @@ -1830,7 +1830,7 @@ "standaloneHcFilterSiteIdFallback": "Site {id}", "standaloneHcFilterResourceIdFallback": "Bron {id}", "blueprints": "Blauwdrukken", - "blueprintsLog": "Log Blueprints", + "blueprintsLog": "Log blauwafdrukken", "blueprintsDescription": "Bekijk eerdere blauwdruktoepassingen en hun resultaten of pas een nieuwe blauwdruk toe", "blueprintAdd": "Blauwdruk toevoegen", "blueprintGoBack": "Bekijk alle Blauwdrukken", @@ -3311,7 +3311,7 @@ "internalResourceAuthDaemonPort": "Daemon poort (optioneel)", "orgAuthWhatsThis": "Waar kan ik mijn organisatie-ID vinden?", "learnMore": "Meer informatie", - "backToHome": "Ga terug naar startpagina", + "backToHome": "Ga terug naar de startpagina", "needToSignInToOrg": "Moet u de identiteit provider van uw organisatie gebruiken?", "maintenanceMode": "Onderhoudspagina", "maintenanceModeDescription": "Toon een onderhoudspagina aan bezoekers", @@ -3524,7 +3524,7 @@ "httpDestAuthNoneDescription": "Stuurt verzoeken zonder toestemmingskop.", "httpDestAuthBearerTitle": "Betere Token", "httpDestAuthBearerDescription": "Voegt een Authorization: Bearer '' header toe aan elk verzoek.", - "httpDestAuthBearerPlaceholder": "Uw API-sleutel of -token", + "httpDestAuthBearerPlaceholder": "Uw API sleutel of token", "httpDestAuthBasicTitle": "Basis authenticatie", "httpDestAuthBasicDescription": "Voegt een Authorization: Basic '' header toe. Verstrek inloggegevens als gebruikersnaam:wachtwoord.", "httpDestAuthBasicPlaceholder": "Gebruikersnaam:wachtwoord", @@ -3678,7 +3678,7 @@ "memberPortalResourceDisabled": "Bron Uitgeschakeld", "memberPortalShowingResources": "Toont {start}-{end} van {total} bronnen", "resourceLauncherTitle": "Bron Launcher", - "resourceSidebarLauncherTitle": "Startprogramma", + "resourceSidebarLauncherTitle": "Startpagina", "resourceLauncherDescription": "Bekijk alle beschikbare bronnen en start ze vanuit één centraal punt", "resourceLauncherSearchPlaceholder": "Zoek naar bronnen...", "resourceLauncherDefaultView": "Standaard", From c11fc86b63b8710a31bd222cbe45e6dfc4d45387 Mon Sep 17 00:00:00 2001 From: Shubham Singh Date: Thu, 30 Jul 2026 15:34:00 +0530 Subject: [PATCH 11/37] Fix integration site resource lookup --- .../siteResource/getSiteResource.test.ts | 58 +++++++++++++++++++ .../routers/siteResource/getSiteResource.ts | 24 ++++---- 2 files changed, 69 insertions(+), 13 deletions(-) create mode 100644 server/routers/siteResource/getSiteResource.test.ts diff --git a/server/routers/siteResource/getSiteResource.test.ts b/server/routers/siteResource/getSiteResource.test.ts new file mode 100644 index 000000000..4e63742da --- /dev/null +++ b/server/routers/siteResource/getSiteResource.test.ts @@ -0,0 +1,58 @@ +import { assertEquals } from "@test/assert"; +import { getSiteResourceParamsSchema } from "./getSiteResource"; + +function testSiteResourceIdOnlyParams() { + const result = getSiteResourceParamsSchema.safeParse({ + siteResourceId: "42" + }); + + assertEquals( + result.success, + true, + "siteResourceId-only integration routes should pass validation" + ); + + if (result.success) { + assertEquals( + result.data.siteResourceId, + 42, + "siteResourceId should be parsed as a number" + ); + assertEquals( + result.data.orgId, + undefined, + "orgId should remain optional" + ); + } +} + +function testOrgScopedParamsRemainSupported() { + const result = getSiteResourceParamsSchema.safeParse({ + siteResourceId: "42", + orgId: "org-id" + }); + + assertEquals( + result.success, + true, + "org-scoped routes should continue to pass validation" + ); +} + +function testInvalidSiteResourceId() { + const result = getSiteResourceParamsSchema.safeParse({ + siteResourceId: "not-a-number" + }); + + assertEquals( + result.success, + false, + "non-numeric siteResourceIds should fail validation" + ); +} + +testSiteResourceIdOnlyParams(); +testOrgScopedParamsRemainSupported(); +testInvalidSiteResourceId(); + +console.log("All getSiteResource parameter validation tests passed."); diff --git a/server/routers/siteResource/getSiteResource.ts b/server/routers/siteResource/getSiteResource.ts index 47a89d1b1..efdac5452 100644 --- a/server/routers/siteResource/getSiteResource.ts +++ b/server/routers/siteResource/getSiteResource.ts @@ -10,7 +10,7 @@ import { fromError } from "zod-validation-error"; import logger from "@server/logger"; import { OpenAPITags, registry } from "@server/openApi"; -const getSiteResourceParamsSchema = z.strictObject({ +export const getSiteResourceParamsSchema = z.strictObject({ siteResourceId: z .string() .optional() @@ -18,19 +18,21 @@ const getSiteResourceParamsSchema = z.strictObject({ .pipe(z.int().positive().optional()) .optional(), niceId: z.string().optional(), - orgId: z.string() + orgId: z.string().optional() }); async function query(siteResourceId?: number, niceId?: string, orgId?: string) { - if (siteResourceId && orgId) { + if (siteResourceId) { const [siteResource] = await db .select() .from(siteResources) .where( - and( - eq(siteResources.siteResourceId, siteResourceId), - eq(siteResources.orgId, orgId) - ) + orgId + ? and( + eq(siteResources.siteResourceId, siteResourceId), + eq(siteResources.orgId, orgId) + ) + : eq(siteResources.siteResourceId, siteResourceId) ) .limit(1); return siteResource; @@ -60,9 +62,7 @@ registry.registerPath({ tags: [OpenAPITags.PrivateResourceLegacy], request: { params: z.object({ - siteResourceId: z.number(), - siteId: z.number(), - orgId: z.string() + siteResourceId: z.number() }) }, responses: { @@ -90,9 +90,7 @@ registry.registerPath({ tags: [OpenAPITags.PrivateResource], request: { params: z.object({ - siteResourceId: z.number(), - siteId: z.number(), - orgId: z.string() + siteResourceId: z.number() }) }, responses: { From 8ec9fb3cb9a1938fef22bc96fe5ba8bcfd3b4120 Mon Sep 17 00:00:00 2001 From: yaqoob Date: Sat, 15 Aug 2026 03:49:08 +0530 Subject: [PATCH 12/37] Normalize CLI command import paths in pangctl entrypoint --- cli/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/index.ts b/cli/index.ts index cfa65625c..688416ab6 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -2,8 +2,8 @@ import yargs from "yargs"; import { hideBin } from "yargs/helpers"; -import { setAdminCredentials } from "@cli/commands/setAdminCredentials"; -import { resetUserSecurityKeys } from "@cli/commands/resetUserSecurityKeys"; +import { setAdminCredentials } from "./commands/setAdminCredentials"; +import { resetUserSecurityKeys } from "./commands/resetUserSecurityKeys"; import { clearExitNodes } from "./commands/clearExitNodes"; import { rotateServerSecret } from "./commands/rotateServerSecret"; import { clearLicenseKeys } from "./commands/clearLicenseKeys"; From e9e8457d06ed3e9324f2ebb0ac2ba6db0635917e Mon Sep 17 00:00:00 2001 From: Shlee Date: Sun, 16 Aug 2026 21:29:44 +0930 Subject: [PATCH 13/37] Update updateResource.ts --- server/routers/resource/updateResource.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/routers/resource/updateResource.ts b/server/routers/resource/updateResource.ts index f3e0c3909..f8573df11 100644 --- a/server/routers/resource/updateResource.ts +++ b/server/routers/resource/updateResource.ts @@ -498,7 +498,8 @@ async function updateHttpResource( } // catch when the resource policy changes or gets cleared - if (resource.resourcePolicyId != updateData.resourcePolicyId) { + if (updateData.resourcePolicyId !== undefined && + resource.resourcePolicyId !== updateData.resourcePolicyId) { await clearResourceSpecificSettings( resource.resourceId, resource.orgId, From 4bf5efdab56177d209624ed78c6580bb80c32a8d Mon Sep 17 00:00:00 2001 From: Shlee Date: Sun, 16 Aug 2026 21:34:35 +0930 Subject: [PATCH 14/37] Update exportConnectionAuditLog.ts --- server/private/routers/auditLogs/exportConnectionAuditLog.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/private/routers/auditLogs/exportConnectionAuditLog.ts b/server/private/routers/auditLogs/exportConnectionAuditLog.ts index a20d4052a..810ae1630 100644 --- a/server/private/routers/auditLogs/exportConnectionAuditLog.ts +++ b/server/private/routers/auditLogs/exportConnectionAuditLog.ts @@ -97,7 +97,7 @@ export async function exportConnectionAuditLogs( const baseQuery = queryConnection(data); - const log = await baseQuery.limit(data.limit).offset(data.offset); + const log = await baseQuery.limit(MAX_EXPORT_LIMIT); const csvData = generateCSV(log); From 5cd98e2790b25415517eaef4e4aea09f64a493b6 Mon Sep 17 00:00:00 2001 From: Shlee Date: Sun, 16 Aug 2026 21:37:00 +0930 Subject: [PATCH 15/37] Update updateSite.ts --- server/routers/site/updateSite.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routers/site/updateSite.ts b/server/routers/site/updateSite.ts index 42ab8b246..bea6eabbb 100644 --- a/server/routers/site/updateSite.ts +++ b/server/routers/site/updateSite.ts @@ -113,7 +113,7 @@ export async function updateSite( .where( and( eq(sites.niceId, updateData.niceId), - eq(sites.orgId, sites.orgId), + eq(sites.orgId, existingSite.orgId), ne(sites.siteId, siteId) ) ) From 2a6bd21029c9f4ab77bc7028b3b237f5ea5d0c9c Mon Sep 17 00:00:00 2001 From: Shlee Date: Sun, 16 Aug 2026 22:10:07 +0930 Subject: [PATCH 16/37] Update verifyApiKeyAccess.ts --- server/middlewares/verifyApiKeyAccess.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/server/middlewares/verifyApiKeyAccess.ts b/server/middlewares/verifyApiKeyAccess.ts index ea1bdac18..47dac03f0 100644 --- a/server/middlewares/verifyApiKeyAccess.ts +++ b/server/middlewares/verifyApiKeyAccess.ts @@ -70,13 +70,8 @@ export async function verifyApiKeyAccess( ); } - if (!apiKeyOrg.orgId) { - return next( - createHttpError( - HttpCode.INTERNAL_SERVER_ERROR, - `API key with ID ${apiKeyId} does not have an organization ID` - ) - ); + if (!apiKey.apiKeyOrg?.orgId) { + return next(createHttpError(HttpCode.INTERNAL_SERVER_ERROR, `API key with ID ${apiKeyId} does not have an organization ID`)); } if (!req.userOrg) { @@ -86,7 +81,7 @@ export async function verifyApiKeyAccess( .where( and( eq(userOrgs.userId, userId), - eq(userOrgs.orgId, apiKeyOrg.orgId) + eq(userOrgs.orgId, apiKey.apiKeyOrg.orgId) ) ) .limit(1); From 64aa7292e6190f6c954a43a96a14a0b61428bd05 Mon Sep 17 00:00:00 2001 From: Shlee Date: Sun, 16 Aug 2026 22:10:57 +0930 Subject: [PATCH 17/37] Update peers.ts --- server/routers/newt/peers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routers/newt/peers.ts b/server/routers/newt/peers.ts index 6c38671f3..bd11f03d0 100644 --- a/server/routers/newt/peers.ts +++ b/server/routers/newt/peers.ts @@ -31,7 +31,7 @@ export async function addPeer( .where(eq(newts.siteId, siteId)) .limit(1); if (!newt) { - throw new Error(`Site found for site ${siteId}`); + throw new Error(`Newt not found for site ${siteId}`); } newtId = newt.newtId; } From 46538eb606574137f135a98e57bce83efef057fe Mon Sep 17 00:00:00 2001 From: m1handr <71174649+m1handr@users.noreply.github.com> Date: Wed, 19 Aug 2026 20:29:27 +0300 Subject: [PATCH 18/37] fix(site): include org subnet prefix when auto-allocating site address (#3523) --- server/routers/site/createSite.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routers/site/createSite.ts b/server/routers/site/createSite.ts index 574751e93..84f651338 100644 --- a/server/routers/site/createSite.ts +++ b/server/routers/site/createSite.ts @@ -263,7 +263,7 @@ export async function createSite( const { value: newClientAddress, release } = await getNextAvailableClientSubnet(orgId); releaseSubnetLock = release; - updatedAddress = newClientAddress.split("/")[0]; + updatedAddress = `${newClientAddress.split("/")[0]}/${org.subnet ? org.subnet.split("/")[1] : "32"}`; } let newSite: Site | undefined; From 64ae230d236df67282e507e41e61ef99932068ee Mon Sep 17 00:00:00 2001 From: breken Date: Sun, 13 Sep 2026 19:00:59 -0700 Subject: [PATCH 19/37] fix(rules): decode percent-encoded PATH rule patterns before matching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isPathAllowed decodes the incoming request path (and Badger already sends Go's decoded req.URL.Path), but compared it against the rule pattern as raw text. isValidUrlGlobPattern rejects raw spaces and non-ASCII and only accepts them percent-encoded, so a PATH rule such as `/my%20docs/*` or `/caf%C3%A9` was stored as `my%20docs` / `caf%C3%A9` and compared against `my docs` / `café`, and could therefore never match any request. Run the pattern through the same decodeAndResolvePath normalisation as the request path so both sides are compared in decoded form. Claude-Session: https://claude.ai/code/session_0134ujLF81GyXsCByibLcYsz --- server/lib/pathMatch.ts | 7 ++++- server/routers/badger/verifySession.test.ts | 33 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/server/lib/pathMatch.ts b/server/lib/pathMatch.ts index 8ef579607..2c3444b24 100644 --- a/server/lib/pathMatch.ts +++ b/server/lib/pathMatch.ts @@ -20,6 +20,11 @@ function getSegmentRegex(patternPart: string): RegExp { // resolves `.` / `..` segments, so a request like `/public%2F..%2Fadmin/` // or `/public/../admin/` is matched as `/admin/`, not as a literal segment // or a wildcard-swallowed sequence under `/public/*`. +// +// Applied to both the request path and the rule pattern: the pattern +// validator only accepts spaces / non-ASCII in percent-encoded form, so a +// rule like `/my%20docs/*` must be compared against the decoded segment +// `my docs`, not the literal text `my%20docs`. function decodeAndResolvePath(p: string): string[] { const rawParts = p.split("/").filter(Boolean); @@ -48,7 +53,7 @@ function decodeAndResolvePath(p: string): string[] { } export function isPathAllowed(pattern: string, path: string): boolean { - const patternParts = pattern.split("/").filter(Boolean); + const patternParts = decodeAndResolvePath(pattern); const pathParts = decodeAndResolvePath(path); function matchSegments( diff --git a/server/routers/badger/verifySession.test.ts b/server/routers/badger/verifySession.test.ts index c91805f8e..6254de025 100644 --- a/server/routers/badger/verifySession.test.ts +++ b/server/routers/badger/verifySession.test.ts @@ -386,6 +386,38 @@ function runSpecialCharacterTests() { console.log("All special character tests passed!"); } +function runEncodedPatternTests() { + console.log("\nRunning percent-encoded pattern tests..."); + + // isValidUrlGlobPattern accepts percent-encoded sequences and rejects + // raw spaces / non-ASCII, so `%20` and `%C3%A9` are the only way to write + // a PATH rule for such a path. Badger sends the request path already + // decoded (Go's req.URL.Path), and isPathAllowed decodes it again, so the + // rule pattern must be decoded the same way or it can never match. + assertEquals( + isPathAllowed("/my%20docs/*", "/my docs/report.pdf"), + true, + "Percent-encoded space in pattern should match decoded request path" + ); + assertEquals( + isPathAllowed("/my%20docs/*", "/my%20docs/report.pdf"), + true, + "Percent-encoded space in pattern should match raw-encoded request path" + ); + assertEquals( + isPathAllowed("/caf%C3%A9", "/café"), + true, + "Percent-encoded UTF-8 in pattern should match decoded request path" + ); + assertEquals( + isPathAllowed("/my%20docs/*", "/my-docs/report.pdf"), + false, + "Decoded pattern must still reject a different path" + ); + + console.log("All percent-encoded pattern tests passed!"); +} + function runRegionTests() { console.log("\nRunning isIpInRegion tests..."); @@ -446,6 +478,7 @@ function runRegionTests() { try { runTests(); runSpecialCharacterTests(); + runEncodedPatternTests(); runRegionTests(); console.log("\n✅ All tests passed!"); } catch (error) { From a7d4745f93a0c0326f4554b5d902a25fb261dca4 Mon Sep 17 00:00:00 2001 From: Jan Kahmen <36455663+kah-ja@users.noreply.github.com> Date: Tue, 15 Sep 2026 09:57:22 +0000 Subject: [PATCH 20/37] Only accept http(s) targets for the resource auth redirect The resource auth page copies the redirect query parameter into redirectUrl when its host matches the resource host (src/app/auth/resource/[resourceGuid]/page.tsx:121-150). URL parses a host out of every scheme that uses "//", so a target such as javascript://resource-host/... passes that comparison. The value is handed to ResourceAuthPortal as the redirect prop and assigned to window.location.href after a successful login (src/components/ResourceAuthPortal.tsx:213,247,281). Parse the target once and require http: or https: before the host comparisons. The three branches that assigned the same value are folded into one condition; the accepted set of http(s) targets is unchanged. --- src/app/auth/resource/[resourceGuid]/page.tsx | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/app/auth/resource/[resourceGuid]/page.tsx b/src/app/auth/resource/[resourceGuid]/page.tsx index 318d63517..53217dcfd 100644 --- a/src/app/auth/resource/[resourceGuid]/page.tsx +++ b/src/app/auth/resource/[resourceGuid]/page.tsx @@ -122,11 +122,20 @@ export default async function ResourceAuthPage(props: { if (searchParams.redirect) { try { + const redirectTarget = new URL(searchParams.redirect); const serverResourceHost = new URL(authInfo.url).host; - const redirectHost = new URL(searchParams.redirect).host; - const redirectPort = new URL(searchParams.redirect).port; + const redirectHost = redirectTarget.host; + const redirectPort = redirectTarget.port; const serverResourceHostWithPort = `${serverResourceHost}:${redirectPort}`; + // URL parses a host out of any scheme that uses "//", so a target + // like javascript://resource-host/... matches the comparisons + // below. The target is later assigned to window.location, so only + // http(s) is accepted here. + const isHttpTarget = + redirectTarget.protocol === "http:" || + redirectTarget.protocol === "https:"; + const wildcardMatchesRedirect = ( wildcardDomain: string, host: string @@ -136,14 +145,16 @@ export default async function ResourceAuthPage(props: { return host.endsWith(suffix) && host.length > suffix.length; }; - if (serverResourceHost === redirectHost) { - redirectUrl = searchParams.redirect; - } else if (serverResourceHostWithPort === redirectHost) { - redirectUrl = searchParams.redirect; - } else if ( - authInfo.wildcard && - authInfo.fullDomain && - wildcardMatchesRedirect(authInfo.fullDomain, redirectHost) + if ( + isHttpTarget && + (serverResourceHost === redirectHost || + serverResourceHostWithPort === redirectHost || + (authInfo.wildcard && + authInfo.fullDomain && + wildcardMatchesRedirect( + authInfo.fullDomain, + redirectHost + ))) ) { redirectUrl = searchParams.redirect; } From 803fbb2ea20d8ddf1739649e03d8ea4d9a836aab Mon Sep 17 00:00:00 2001 From: Tyagiquamar Date: Thu, 17 Sep 2026 22:45:42 +0530 Subject: [PATCH 21/37] fix(sqlite): take a single database backup per upgrade instead of one per migration --- server/setup/migrationsSqlite.backup.test.ts | 151 +++++++++++++++++++ server/setup/migrationsSqlite.ts | 13 +- 2 files changed, 159 insertions(+), 5 deletions(-) create mode 100644 server/setup/migrationsSqlite.backup.test.ts diff --git a/server/setup/migrationsSqlite.backup.test.ts b/server/setup/migrationsSqlite.backup.test.ts new file mode 100644 index 000000000..e450155ff --- /dev/null +++ b/server/setup/migrationsSqlite.backup.test.ts @@ -0,0 +1,151 @@ +import { execFileSync } from "child_process"; +import fs from "fs"; +import os from "os"; +import path from "path"; +import { fileURLToPath } from "url"; +import Database from "better-sqlite3"; +import { assertEquals } from "@test/assert"; + +const here = path.dirname(fileURLToPath(import.meta.url)); +const repoRoot = path.resolve(here, "..", ".."); +const migrationsScript = path.join(here, "migrationsSqlite.ts"); + +const SEED_STATEMENTS = [ + `CREATE TABLE versionMigrations (version TEXT PRIMARY KEY, executedAt INTEGER NOT NULL)`, + `INSERT INTO versionMigrations (version, executedAt) VALUES ('1.21.0', 1750000000000)`, + `CREATE TABLE sites (siteId INTEGER PRIMARY KEY AUTOINCREMENT, subnet TEXT)`, + `INSERT INTO sites (subnet) VALUES ('10.0.0.0/24')`, + `CREATE TABLE roles (roleId INTEGER PRIMARY KEY AUTOINCREMENT, orgId TEXT, isAdmin INTEGER DEFAULT 0, sshSudoMode TEXT DEFAULT 'none')`, + `INSERT INTO roles (orgId, isAdmin, sshSudoMode) VALUES ('org1', 0, 'none')`, + `CREATE TABLE licenseKey (licenseKeyId INTEGER PRIMARY KEY AUTOINCREMENT)`, + `CREATE TABLE targets (targetId INTEGER PRIMARY KEY AUTOINCREMENT, resourceId INTEGER, siteId INTEGER NOT NULL, ip TEXT NOT NULL, method TEXT, port INTEGER NOT NULL, internalPort INTEGER, enabled INTEGER DEFAULT 1, path TEXT, pathMatchType TEXT, rewritePath TEXT, rewritePathType TEXT, priority INTEGER DEFAULT 100, mode TEXT DEFAULT 'http', authToken TEXT)`, + `CREATE TABLE subscriptions (subscriptionId INTEGER PRIMARY KEY AUTOINCREMENT)`, + `CREATE TABLE clients (clientId INTEGER PRIMARY KEY AUTOINCREMENT)`, + `CREATE TABLE orgs (orgId TEXT PRIMARY KEY)`, + `INSERT INTO orgs (orgId) VALUES ('org1')`, + `CREATE TABLE siteResources (siteResourceId INTEGER PRIMARY KEY AUTOINCREMENT)`, + `CREATE TABLE eventStreamingDestinations (destinationId INTEGER PRIMARY KEY AUTOINCREMENT)`, + `CREATE TABLE roleActions (roleId INTEGER, actionId TEXT, orgId TEXT)`, + `CREATE TABLE newt (newtId INTEGER PRIMARY KEY AUTOINCREMENT)` +]; + +function seedDatabase(dbPath: string) { + const db = new Database(dbPath); + try { + for (const statement of SEED_STATEMENTS) { + db.exec(statement); + } + } finally { + db.close(); + } +} + +function siteColumns(dbPath: string): string[] { + const db = new Database(dbPath, { readonly: true }); + try { + return ( + db.prepare(`PRAGMA table_info(sites)`).all() as Array<{ + name: unknown; + }> + ).map((row) => String(row.name)); + } finally { + db.close(); + } +} + +function runMigrations(workdir: string): { + exitCode: number; + output: string; +} { + const tsconfig = ["tsconfig.json", "tsconfig.oss.json"] + .map((file) => path.join(repoRoot, file)) + .find((file) => fs.existsSync(file)); + if (!tsconfig) { + throw new Error("No tsconfig found for @server path aliases"); + } + const tsxCli = path.join( + repoRoot, + "node_modules", + "tsx", + "dist", + "cli.mjs" + ); + if (!fs.existsSync(tsxCli)) { + throw new Error("tsx is not installed; run npm ci first"); + } + try { + const output = execFileSync( + process.execPath, + [tsxCli, "--tsconfig", tsconfig, migrationsScript], + { cwd: workdir, timeout: 120000, encoding: "utf8" } + ); + return { exitCode: 0, output }; + } catch (error) { + const output = + error instanceof Error + ? (error as Error & { stdout?: unknown }).stdout + : ""; + return { exitCode: 1, output: String(output ?? "") }; + } +} + +function testSingleBackupPerUpgrade() { + console.log("Running single backup per upgrade test..."); + for (const generated of ["server/build.ts", "server/db/index.ts"]) { + if (!fs.existsSync(path.join(repoRoot, generated))) { + throw new Error( + `Missing ${generated}; run npm run set:oss && npm run set:sqlite first` + ); + } + } + const workdir = fs.mkdtempSync( + path.join(os.tmpdir(), "pangolin-backup-test-") + ); + try { + fs.mkdirSync(path.join(workdir, "config", "db"), { recursive: true }); + fs.copyFileSync( + path.join(repoRoot, "config", "config.example.yml"), + path.join(workdir, "config", "config.yml") + ); + fs.symlinkSync( + path.join(repoRoot, "server"), + path.join(workdir, "server"), + process.platform === "win32" ? "junction" : "dir" + ); + seedDatabase(path.join(workdir, "config", "db", "db.sqlite")); + const result = runMigrations(workdir); + assertEquals(result.exitCode, 0, "Seeded migrations must run cleanly"); + if (!result.output.includes("All migrations completed successfully")) { + throw new Error( + "Seeded migrations did not complete; the backup assertions below would be vacuous" + ); + } + const backupsDir = path.join(workdir, "config", "db", "backups"); + const backups = fs.existsSync(backupsDir) + ? fs + .readdirSync(backupsDir) + .filter((file) => file.endsWith(".sqlite")) + : []; + assertEquals( + backups.length, + 1, + "One upgrade must produce exactly one database backup even with several pending migrations" + ); + const columns = siteColumns(path.join(backupsDir, backups[0])); + if (!columns.includes("subnet")) { + throw new Error( + `The single backup must be the pre-upgrade snapshot (sites.subnet), got sites(${columns.join(",")})` + ); + } + } finally { + fs.rmSync(workdir, { recursive: true, force: true }); + } +} + +try { + testSingleBackupPerUpgrade(); + console.log("All tests passed successfully!"); +} catch (error) { + console.error("Test failed:", error); + process.exit(1); +} diff --git a/server/setup/migrationsSqlite.ts b/server/setup/migrationsSqlite.ts index 6645d617f..07b38e52b 100644 --- a/server/setup/migrationsSqlite.ts +++ b/server/setup/migrationsSqlite.ts @@ -191,15 +191,18 @@ async function executeScripts() { ); // Run migrations in order + // Take a single backup before any migration runs, so one upgrade + // produces one restore point instead of one backup per migration. + if ( + migrationsToRun.length > 0 && + !process.env.DISABLE_BACKUP_ON_MIGRATION + ) { + backupDb(); + } for (const migration of migrationsToRun) { console.log(`Running migration ${migration.version}`); try { - if (!process.env.DISABLE_BACKUP_ON_MIGRATION) { - // Backup the database before running the migration - backupDb(); - } - await migration.run(); // Update version in database From b74ded3a9c823fc9aa33264be595a6ea7e7f37af Mon Sep 17 00:00:00 2001 From: Tyagiquamar Date: Fri, 18 Sep 2026 21:31:00 +0530 Subject: [PATCH 22/37] fix(sqlite): tag per-migration database backups with version and prevent collisions --- server/lib/backupFileName.test.ts | 47 +++- server/lib/backupFileName.ts | 23 ++ server/setup/migrationsSqlite.backup.test.ts | 243 +++++++++++++++++-- server/setup/migrationsSqlite.ts | 30 +-- server/setup/scriptsSqlite/1.0.0-beta9.ts | 20 -- 5 files changed, 298 insertions(+), 65 deletions(-) diff --git a/server/lib/backupFileName.test.ts b/server/lib/backupFileName.test.ts index 01fc4796a..fd8a047eb 100644 --- a/server/lib/backupFileName.test.ts +++ b/server/lib/backupFileName.test.ts @@ -1,4 +1,4 @@ -import { formatBackupTimestamp } from "./backupFileName"; +import { formatBackupFileName, formatBackupTimestamp } from "./backupFileName"; import { assertEquals } from "@test/assert"; // Local-time constructors are used throughout, matching formatBackupTimestamp, @@ -29,7 +29,9 @@ function testMonthIsOneIndexed() { } { - const result = formatBackupTimestamp(new Date(2026, 11, 31, 23, 59, 59)); + const result = formatBackupTimestamp( + new Date(2026, 11, 31, 23, 59, 59) + ); assertEquals( result, "2026-12-31_23-59-59", @@ -73,9 +75,7 @@ function testNamesSortChronologically() { new Date(2026, 11, 31, 23, 59, 59) ]; - const sorted = taken - .map((date) => formatBackupTimestamp(date)) - .sort(); + const sorted = taken.map((date) => formatBackupTimestamp(date)).sort(); assertEquals( sorted.join(","), @@ -89,11 +89,48 @@ function testNamesSortChronologically() { ); } +function testFormatBackupFileName() { + console.log("Running backup file name formatting tests..."); + + const date = new Date(2026, 8, 12, 20, 35, 56); + + // With semver version string without leading 'v' + assertEquals( + formatBackupFileName("1.22.0", date), + "db_2026-09-12_20-35-56_v1.22.0.sqlite", + "Filename must include timestamp and prefixed version tag" + ); + + // With version string already containing 'v' + assertEquals( + formatBackupFileName("v1.22.0", date), + "db_2026-09-12_20-35-56_v1.22.0.sqlite", + "Filename must not duplicate 'v' prefix if already present" + ); + + // Without version (fallback/default) + assertEquals( + formatBackupFileName(undefined, date), + "db_2026-09-12_20-35-56.sqlite", + "Filename without version must match default timestamped format" + ); + + // Distinct versions within the exact same second do not collide + const sameSecondFile1 = formatBackupFileName("1.21.0", date); + const sameSecondFile2 = formatBackupFileName("1.22.0", date); + if (sameSecondFile1 === sameSecondFile2) { + throw new Error( + "Backup file names for different versions in the same second must not collide" + ); + } +} + // Run all tests try { testMonthIsOneIndexed(); testEveryFieldIsZeroPadded(); testNamesSortChronologically(); + testFormatBackupFileName(); console.log("All tests passed successfully!"); } catch (error) { console.error("Test failed:", error); diff --git a/server/lib/backupFileName.ts b/server/lib/backupFileName.ts index a5888450a..9d2c1bd62 100644 --- a/server/lib/backupFileName.ts +++ b/server/lib/backupFileName.ts @@ -26,3 +26,26 @@ export function formatBackupTimestamp(date: Date = new Date()): string { return `${datePart}_${timePart}`; } + +/** + * Builds the full database backup file name, including timestamp and optional version tag. + * + * When a migration version is provided, the filename includes `_v`, + * preventing collisions between multiple migrations running in the same second and making it easy + * to identify the migration state contained in the backup. + * + * @param version Optional migration version being run. + * @param date The moment the backup is being taken. Defaults to now. + * @returns A filename of the form `db_YYYY-MM-DD_HH-MM-SS_v.sqlite` or `db_YYYY-MM-DD_HH-MM-SS.sqlite`. + */ +export function formatBackupFileName( + version?: string, + date: Date = new Date() +): string { + const timestamp = formatBackupTimestamp(date); + if (version) { + const versionTag = version.startsWith("v") ? version : `v${version}`; + return `db_${timestamp}_${versionTag}.sqlite`; + } + return `db_${timestamp}.sqlite`; +} diff --git a/server/setup/migrationsSqlite.backup.test.ts b/server/setup/migrationsSqlite.backup.test.ts index e450155ff..616cf303d 100644 --- a/server/setup/migrationsSqlite.backup.test.ts +++ b/server/setup/migrationsSqlite.backup.test.ts @@ -40,11 +40,11 @@ function seedDatabase(dbPath: string) { } } -function siteColumns(dbPath: string): string[] { +function tableColumns(dbPath: string, tableName: string): string[] { const db = new Database(dbPath, { readonly: true }); try { return ( - db.prepare(`PRAGMA table_info(sites)`).all() as Array<{ + db.prepare(`PRAGMA table_info(${tableName})`).all() as Array<{ name: unknown; }> ).map((row) => String(row.name)); @@ -53,7 +53,23 @@ function siteColumns(dbPath: string): string[] { } } -function runMigrations(workdir: string): { +function executedMigrationVersions(dbPath: string): string[] { + const db = new Database(dbPath, { readonly: true }); + try { + return ( + db.prepare(`SELECT version FROM versionMigrations`).all() as Array<{ + version: unknown; + }> + ).map((row) => String(row.version)); + } finally { + db.close(); + } +} + +function runMigrations( + workdir: string, + env: Record = {} +): { exitCode: number; output: string; } { @@ -77,7 +93,12 @@ function runMigrations(workdir: string): { const output = execFileSync( process.execPath, [tsxCli, "--tsconfig", tsconfig, migrationsScript], - { cwd: workdir, timeout: 120000, encoding: "utf8" } + { + cwd: workdir, + timeout: 120000, + encoding: "utf8", + env: { ...process.env, NODE_ENV: "test", ...env } + } ); return { exitCode: 0, output }; } catch (error) { @@ -89,8 +110,7 @@ function runMigrations(workdir: string): { } } -function testSingleBackupPerUpgrade() { - console.log("Running single backup per upgrade test..."); +function createTestEnvironment(): string { for (const generated of ["server/build.ts", "server/db/index.ts"]) { if (!fs.existsSync(path.join(repoRoot, generated))) { throw new Error( @@ -101,17 +121,29 @@ function testSingleBackupPerUpgrade() { const workdir = fs.mkdtempSync( path.join(os.tmpdir(), "pangolin-backup-test-") ); + fs.mkdirSync(path.join(workdir, "config", "db"), { recursive: true }); + fs.copyFileSync( + path.join(repoRoot, "config", "config.example.yml"), + path.join(workdir, "config", "config.yml") + ); + const traefikSrc = path.join(repoRoot, "config", "traefik"); + if (fs.existsSync(traefikSrc)) { + fs.cpSync(traefikSrc, path.join(workdir, "config", "traefik"), { + recursive: true + }); + } + fs.symlinkSync( + path.join(repoRoot, "server"), + path.join(workdir, "server"), + process.platform === "win32" ? "junction" : "dir" + ); + return workdir; +} + +function testMultipleSequentialMigrations() { + console.log("Running multiple sequential migrations test..."); + const workdir = createTestEnvironment(); try { - fs.mkdirSync(path.join(workdir, "config", "db"), { recursive: true }); - fs.copyFileSync( - path.join(repoRoot, "config", "config.example.yml"), - path.join(workdir, "config", "config.yml") - ); - fs.symlinkSync( - path.join(repoRoot, "server"), - path.join(workdir, "server"), - process.platform === "win32" ? "junction" : "dir" - ); seedDatabase(path.join(workdir, "config", "db", "db.sqlite")); const result = runMigrations(workdir); assertEquals(result.exitCode, 0, "Seeded migrations must run cleanly"); @@ -120,6 +152,169 @@ function testSingleBackupPerUpgrade() { "Seeded migrations did not complete; the backup assertions below would be vacuous" ); } + + const backupsDir = path.join(workdir, "config", "db", "backups"); + const backups = fs.existsSync(backupsDir) + ? fs + .readdirSync(backupsDir) + .filter((file) => file.endsWith(".sqlite")) + : []; + + // Upgrading from 1.21.0 runs 1.22.0 and 1.23.0 -> produces 2 distinct backups + assertEquals( + backups.length, + 2, + "Each migration must have its own distinct backup snapshot" + ); + + const v122Backup = backups.find((file) => + file.includes("_v1.22.0.sqlite") + ); + const v123Backup = backups.find((file) => + file.includes("_v1.23.0.sqlite") + ); + + if (!v122Backup || !v123Backup) { + throw new Error( + `Expected backups for v1.22.0 and v1.23.0, found: ${backups.join(", ")}` + ); + } + + // Verify pre-1.22.0 snapshot state: sites has 'subnet' (not exitNodeSubnet), versions = [1.21.0] + const v122Columns = tableColumns( + path.join(backupsDir, v122Backup), + "sites" + ); + assertEquals( + v122Columns.includes("subnet") && + !v122Columns.includes("exitNodeSubnet"), + true, + "Backup before 1.22.0 must retain pre-1.22.0 schema (sites.subnet)" + ); + const v122Versions = executedMigrationVersions( + path.join(backupsDir, v122Backup) + ); + assertEquals( + v122Versions.includes("1.21.0") && !v122Versions.includes("1.22.0"), + true, + "Backup before 1.22.0 must only record version 1.21.0" + ); + + // Verify pre-1.23.0 snapshot state: sites has 'exitNodeSubnet' (1.22.0 applied), newt has no agent + const v123Columns = tableColumns( + path.join(backupsDir, v123Backup), + "sites" + ); + assertEquals( + v123Columns.includes("exitNodeSubnet"), + true, + "Backup before 1.23.0 must contain successfully applied 1.22.0 schema (sites.exitNodeSubnet)" + ); + const v123NewtCols = tableColumns( + path.join(backupsDir, v123Backup), + "newt" + ); + assertEquals( + !v123NewtCols.includes("agent"), + true, + "Backup before 1.23.0 must not contain 1.23.0 schema changes yet" + ); + const v123Versions = executedMigrationVersions( + path.join(backupsDir, v123Backup) + ); + assertEquals( + v123Versions.includes("1.21.0") && v123Versions.includes("1.22.0"), + true, + "Backup before 1.23.0 must record both 1.21.0 and 1.22.0" + ); + } finally { + fs.rmSync(workdir, { recursive: true, force: true }); + } +} + +function testFailureInLaterMigrationPreservesRestorePoints() { + console.log("Running failure in later migration test..."); + const workdir = createTestEnvironment(); + try { + const dbPath = path.join(workdir, "config", "db", "db.sqlite"); + seedDatabase(dbPath); + + // Intentionally drop table 'newt' so migration 1.23.0 fails on ALTER TABLE newt ADD COLUMN agent + const db = new Database(dbPath); + db.exec("DROP TABLE newt;"); + db.close(); + + const result = runMigrations(workdir); + assertEquals( + result.exitCode, + 1, + "Migration suite must fail when 1.23.0 errors" + ); + + const backupsDir = path.join(workdir, "config", "db", "backups"); + const backups = fs.existsSync(backupsDir) + ? fs + .readdirSync(backupsDir) + .filter((file) => file.endsWith(".sqlite")) + : []; + + // Both pre-1.22.0 and pre-1.23.0 backups must exist + assertEquals( + backups.length, + 2, + "Backups for earlier successful migration and the failed migration must both exist" + ); + + const v122Backup = backups.find((file) => + file.includes("_v1.22.0.sqlite") + ); + const v123Backup = backups.find((file) => + file.includes("_v1.23.0.sqlite") + ); + + if (!v122Backup || !v123Backup) { + throw new Error( + `Expected restore points for v1.22.0 and v1.23.0, found: ${backups.join(", ")}` + ); + } + + // Verify pre-1.23.0 backup is a valid restore point with 1.22.0 changes applied + const v123SitesCols = tableColumns( + path.join(backupsDir, v123Backup), + "sites" + ); + assertEquals( + v123SitesCols.includes("exitNodeSubnet"), + true, + "Pre-failure restore point must have 1.22.0 changes intact" + ); + const v123Versions = executedMigrationVersions( + path.join(backupsDir, v123Backup) + ); + assertEquals( + v123Versions.includes("1.22.0"), + true, + "Pre-failure restore point must record successful 1.22.0 migration" + ); + } finally { + fs.rmSync(workdir, { recursive: true, force: true }); + } +} + +function testDisableBackupOnMigration() { + console.log("Running DISABLE_BACKUP_ON_MIGRATION test..."); + const workdir = createTestEnvironment(); + try { + seedDatabase(path.join(workdir, "config", "db", "db.sqlite")); + const result = runMigrations(workdir, { + DISABLE_BACKUP_ON_MIGRATION: "1" + }); + assertEquals( + result.exitCode, + 0, + "Migrations must succeed with backups disabled" + ); + const backupsDir = path.join(workdir, "config", "db", "backups"); const backups = fs.existsSync(backupsDir) ? fs @@ -128,23 +323,19 @@ function testSingleBackupPerUpgrade() { : []; assertEquals( backups.length, - 1, - "One upgrade must produce exactly one database backup even with several pending migrations" + 0, + "No backup files should be created when DISABLE_BACKUP_ON_MIGRATION is set" ); - const columns = siteColumns(path.join(backupsDir, backups[0])); - if (!columns.includes("subnet")) { - throw new Error( - `The single backup must be the pre-upgrade snapshot (sites.subnet), got sites(${columns.join(",")})` - ); - } } finally { fs.rmSync(workdir, { recursive: true, force: true }); } } try { - testSingleBackupPerUpgrade(); - console.log("All tests passed successfully!"); + testMultipleSequentialMigrations(); + testFailureInLaterMigrationPreservesRestorePoints(); + testDisableBackupOnMigration(); + console.log("All backup migration regression tests passed successfully!"); } catch (error) { console.error("Test failed:", error); process.exit(1); diff --git a/server/setup/migrationsSqlite.ts b/server/setup/migrationsSqlite.ts index 07b38e52b..eb2846610 100644 --- a/server/setup/migrationsSqlite.ts +++ b/server/setup/migrationsSqlite.ts @@ -5,7 +5,7 @@ import path from "path"; import semver from "semver"; import { versionMigrations } from "../db/sqlite"; import { __DIRNAME, APP_PATH, APP_VERSION } from "@server/lib/consts"; -import { formatBackupTimestamp } from "@server/lib/backupFileName"; +import { formatBackupFileName } from "@server/lib/backupFileName"; import { SqliteError } from "better-sqlite3"; import fs from "fs"; import { build } from "@server/build"; @@ -107,7 +107,7 @@ async function run() { await runMigrations(); } -function backupDb() { +function backupDb(version?: string) { // make dir config/db/backups const appPath = APP_PATH; const dbDir = path.join(appPath, "db"); @@ -120,11 +120,10 @@ function backupDb() { } // copy the db.sqlite file to backups - // add the date to the filename - const date = new Date(); - const dateString = formatBackupTimestamp(date); + // add the date and migration version to the filename + const fileName = formatBackupFileName(version); const dbPath = path.join(dbDir, "db.sqlite"); - const backupPath = path.join(backupsDir, `db_${dateString}.sqlite`); + const backupPath = path.join(backupsDir, fileName); fs.copyFileSync(dbPath, backupPath); } @@ -163,6 +162,12 @@ export async function runMigrations() { } } catch (e) { console.error("Error running migrations:", e); + if ( + process.env.NODE_ENV === "test" || + process.env.ENVIRONMENT === "test" + ) { + throw e; + } await new Promise((resolve) => setTimeout(resolve, 1000 * 60 * 60 * 24 * 1) ); @@ -191,18 +196,15 @@ async function executeScripts() { ); // Run migrations in order - // Take a single backup before any migration runs, so one upgrade - // produces one restore point instead of one backup per migration. - if ( - migrationsToRun.length > 0 && - !process.env.DISABLE_BACKUP_ON_MIGRATION - ) { - backupDb(); - } for (const migration of migrationsToRun) { console.log(`Running migration ${migration.version}`); try { + if (!process.env.DISABLE_BACKUP_ON_MIGRATION) { + // Backup the database before running the migration + backupDb(migration.version); + } + await migration.run(); // Update version in database diff --git a/server/setup/scriptsSqlite/1.0.0-beta9.ts b/server/setup/scriptsSqlite/1.0.0-beta9.ts index 6766c0756..2494556ce 100644 --- a/server/setup/scriptsSqlite/1.0.0-beta9.ts +++ b/server/setup/scriptsSqlite/1.0.0-beta9.ts @@ -10,7 +10,6 @@ import { users } from "../../db/sqlite"; import { APP_PATH, configFilePath1, configFilePath2 } from "@server/lib/consts"; -import { formatBackupTimestamp } from "@server/lib/backupFileName"; import { eq, sql } from "drizzle-orm"; import fs from "fs"; import * as yaml from "js-yaml"; @@ -21,25 +20,6 @@ import { fromZodError } from "zod-validation-error"; export default async function migration() { console.log("Running setup script 1.0.0-beta.9..."); - // make dir config/db/backups - const appPath = APP_PATH; - const dbDir = path.join(appPath, "db"); - - const backupsDir = path.join(dbDir, "backups"); - - // check if the backups directory exists and create it if it doesn't - if (!fs.existsSync(backupsDir)) { - fs.mkdirSync(backupsDir, { recursive: true }); - } - - // copy the db.sqlite file to backups - // add the date to the filename - const date = new Date(); - const dateString = formatBackupTimestamp(date); - const dbPath = path.join(dbDir, "db.sqlite"); - const backupPath = path.join(backupsDir, `db_${dateString}.sqlite`); - fs.copyFileSync(dbPath, backupPath); - await db.transaction(async (trx) => { try { // Determine which config file exists From 032eeb26565be87f057b40db01198d7cab5a18f2 Mon Sep 17 00:00:00 2001 From: Alex Benthem Date: Sat, 19 Sep 2026 12:28:16 +0200 Subject: [PATCH 23/37] fix: use idp variant for resource auth login page icons The resource auth login page (auth/resource/[resourceGuid]) loads IdPs via the global /idp list in the non-saas/non-org path and passed idp.type as the icon variant. Since type is always 'oidc' for OIDC-backed providers (Google, Azure), the branded logos were never selected, showing the generic OIDC icon instead. Use idp.variant (with type as fallback), matching the fix already applied to the main login page (auth/login) and org login page (auth/org/[orgId]). Fixes #3631 --- src/app/auth/resource/[resourceGuid]/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/auth/resource/[resourceGuid]/page.tsx b/src/app/auth/resource/[resourceGuid]/page.tsx index 318d63517..4d6f101de 100644 --- a/src/app/auth/resource/[resourceGuid]/page.tsx +++ b/src/app/auth/resource/[resourceGuid]/page.tsx @@ -283,7 +283,7 @@ export default async function ResourceAuthPage(props: { loginIdps = idpsRes.data.data.idps.map((idp) => ({ idpId: idp.idpId, name: idp.name, - variant: idp.type + variant: idp.variant ?? idp.type })) as LoginFormIDP[]; } From 8e2f9ea5ef991ca12784f7f1c9e26574895360a0 Mon Sep 17 00:00:00 2001 From: Blacks-Army <104644957+Blacks-Army@users.noreply.github.com> Date: Sat, 5 Sep 2026 11:10:44 +0200 Subject: [PATCH 24/37] Add HTTP method matching to resource rules Resolves #1408. A rule with match "METHOD" carries a comma-separated list of HTTP methods in its value, e.g. "POST,PUT", and applies when the request method is in that list. This makes it possible to leave GET public while sending POST and PUT to auth, which rules could not express before because both share the same path. No new columns: the methods live in the existing rule value, so this needs no migration and every existing rule keeps working unchanged. The UI offers the ten registered methods. Blueprints and the API accept any method token, so extension methods such as the WebDAV verbs can be targeted too, and the UI preserves them when a rule set that way is edited later. --- messages/en-US.json | 7 +- server/db/pg/schema/schema.ts | 2 + server/db/sqlite/schema/schema.ts | 2 + server/lib/blueprints/publicResources.ts | 16 ++- server/lib/blueprints/resourcePolicies.ts | 28 +++-- server/lib/blueprints/types.ts | 25 +++- server/lib/validators.test.ts | 43 ++++++- server/lib/validators.ts | 43 ++++++- server/routers/badger/verifySession.ts | 20 +++- .../PolicyAccessRulesTable.tsx | 108 +++++++++++++++--- .../policy-access-rule-validation.ts | 8 +- 11 files changed, 267 insertions(+), 35 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index 664098b8b..ed0ca7dba 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -834,7 +834,7 @@ "rulesErrorDuplicatePriorityDescription": "Each rule must have a unique priority number.", "rulesErrorValidation": "Invalid rules", "rulesErrorValidationRuleDescription": "Rule {ruleNumber}: {message}", - "rulesErrorInvalidMatchTypeDescription": "Select a valid match type (path, IP, CIDR, country, region, or ASN).", + "rulesErrorInvalidMatchTypeDescription": "Select a valid match type (path, IP, CIDR, country, region, ASN, or method).", "rulesErrorValueRequired": "Enter a value for this rule.", "rulesErrorInvalidCountry": "Invalid country", "rulesErrorInvalidCountryDescription": "Select a valid country.", @@ -4400,5 +4400,8 @@ "sessionToolbarShow": "Show toolbar", "sessionToolbarHide": "Hide toolbar", "actionUpdateSiteApprovals": "Update Site Approvals", - "check": "Check" + "check": "Check", + "rulesErrorInvalidMethod": "Invalid HTTP method", + "rulesErrorInvalidMethodDescription": "Select at least one HTTP method.", + "rulesSelectMethods": "Select methods" } diff --git a/server/db/pg/schema/schema.ts b/server/db/pg/schema/schema.ts index 744e88b98..6569d48b9 100644 --- a/server/db/pg/schema/schema.ts +++ b/server/db/pg/schema/schema.ts @@ -1137,6 +1137,7 @@ export const resourceRules = pgTable("resourceRules", { | "COUNTRY_IS_NOT" | "ASN" | "REGION" + | "METHOD" >() .notNull(), // CIDR, PATH, IP value: varchar("value").notNull() @@ -1161,6 +1162,7 @@ export const resourcePolicyRules = pgTable("resourcePolicyRules", { | "COUNTRY_IS_NOT" | "ASN" | "REGION" + | "METHOD" >() .notNull(), value: varchar("value").notNull() diff --git a/server/db/sqlite/schema/schema.ts b/server/db/sqlite/schema/schema.ts index e30bc678e..6201e695d 100644 --- a/server/db/sqlite/schema/schema.ts +++ b/server/db/sqlite/schema/schema.ts @@ -1409,6 +1409,7 @@ export const resourceRules = sqliteTable("resourceRules", { | "COUNTRY_IS_NOT" | "ASN" | "REGION" + | "METHOD" >() .notNull(), // CIDR, PATH, IP value: text("value").notNull() @@ -1465,6 +1466,7 @@ export const resourcePolicyRules = sqliteTable("resourcePolicyRules", { | "COUNTRY_IS_NOT" | "ASN" | "REGION" + | "METHOD" >() .notNull(), value: text("value").notNull() diff --git a/server/lib/blueprints/publicResources.ts b/server/lib/blueprints/publicResources.ts index 4bd42ed0b..55e0013ae 100644 --- a/server/lib/blueprints/publicResources.ts +++ b/server/lib/blueprints/publicResources.ts @@ -48,7 +48,13 @@ import { defaultRoleAllowedActions } from "@server/routers/role/createRole"; import { pickPort } from "@server/routers/target/helpers"; import { and, asc, eq, isNotNull, ne } from "drizzle-orm"; import { tierMatrix } from "../billing/tierMatrix"; -import { isValidCIDR, isValidIP, isValidUrlGlobPattern } from "../validators"; +import { + isValidCIDR, + isValidHttpMethodList, + isValidIP, + isValidUrlGlobPattern, + parseHttpMethodList +} from "../validators"; import { Config, isTargetsOnlyResource, TargetData } from "./types"; import { getOrCreateLabelIds, syncResourceLabels } from "./labels"; import { findOrgUsersByIdentifier } from "./findOrgUser"; @@ -1453,6 +1459,10 @@ function getRuleValue(match: string, value: string) { if (match === "COUNTRY" || match === "COUNTRY_IS_NOT") { return value.toUpperCase(); } + // normalize the method list so it is stored as "POST,PUT" + if (match === "METHOD") { + return parseHttpMethodList(value).join(","); + } return value; } @@ -1473,6 +1483,10 @@ function validateRule(rule: any) { if (!isValidRegionId(rule.value)) { throw new Error(`Invalid region ID provided: ${rule.value}`); } + } else if (rule.match === "method") { + if (!isValidHttpMethodList(rule.value)) { + throw new Error(`Invalid HTTP method provided: ${rule.value}`); + } } } diff --git a/server/lib/blueprints/resourcePolicies.ts b/server/lib/blueprints/resourcePolicies.ts index d8c744cdb..babb1c10a 100644 --- a/server/lib/blueprints/resourcePolicies.ts +++ b/server/lib/blueprints/resourcePolicies.ts @@ -19,7 +19,13 @@ import logger from "@server/logger"; import { getUniqueResourcePolicyName } from "@server/db/names"; import { hashPassword } from "@server/auth/password"; import { idpExistsForOrg } from "@server/lib/idp/idpExistsForOrg"; -import { isValidCIDR, isValidIP, isValidUrlGlobPattern } from "../validators"; +import { + isValidCIDR, + isValidHttpMethodList, + isValidIP, + isValidUrlGlobPattern, + ResourceRuleMatchType +} from "../validators"; import { isLicensedOrSubscribed } from "#dynamic/lib/isLicencedOrSubscribed"; import { tierMatrix } from "../billing/tierMatrix"; import { findOrgUsersByIdentifier } from "./findOrgUser"; @@ -66,6 +72,13 @@ export async function updateResourcePolicies( throw new Error( `Invalid URL glob pattern provided in resource policy '${policyNiceId}': ${rule.value}` ); + } else if ( + rule.match === "method" && + !isValidHttpMethodList(rule.value) + ) { + throw new Error( + `Invalid HTTP method provided in resource policy '${policyNiceId}': ${rule.value}` + ); } } @@ -339,17 +352,8 @@ function getRuleAction(input: string): "ACCEPT" | "DROP" | "PASS" { return "PASS"; } -function getRuleMatch( - input: string -): "CIDR" | "IP" | "PATH" | "COUNTRY" | "COUNTRY_IS_NOT" | "ASN" | "REGION" { - return input.toUpperCase() as - | "CIDR" - | "IP" - | "PATH" - | "COUNTRY" - | "COUNTRY_IS_NOT" - | "ASN" - | "REGION"; +function getRuleMatch(input: string): ResourceRuleMatchType { + return input.toUpperCase() as ResourceRuleMatchType; } async function syncRolePolicies( diff --git a/server/lib/blueprints/types.ts b/server/lib/blueprints/types.ts index 238ef49c4..80c4aeb87 100644 --- a/server/lib/blueprints/types.ts +++ b/server/lib/blueprints/types.ts @@ -3,6 +3,7 @@ import { existsSync } from "node:fs"; import { portRangeStringSchema } from "@server/lib/ip"; import { MaintenanceSchema } from "#dynamic/lib/blueprints/MaintenanceSchema"; import { isValidRegionId } from "@server/db/regions"; +import { isValidHttpMethodList } from "@server/lib/validators"; import { wildcardSubdomainSchema } from "@server/lib/schemas"; import config from "@server/lib/config"; import { @@ -127,7 +128,16 @@ export const AuthSchema = z.object({ export const RuleSchema = z .object({ action: z.enum(["allow", "deny", "pass"]), - match: z.enum(["cidr", "path", "ip", "country", "country_is_not", "asn", "region"]), + match: z.enum([ + "cidr", + "path", + "ip", + "country", + "country_is_not", + "asn", + "region", + "method" + ]), value: z.coerce.string(), priority: z.int().optional(), enabled: z.boolean().optional().default(true) @@ -207,6 +217,19 @@ export const RuleSchema = z message: "Value must be a valid UN M.49 region or subregion ID when match is 'region'" } + ) + .refine( + (rule) => { + if (rule.match === "method") { + return isValidHttpMethodList(rule.value); + } + return true; + }, + { + path: ["value"], + message: + "Value must be a comma-separated list of HTTP methods when match is 'method', e.g. 'POST,PUT'" + } ); export const HeaderSchema = z.object({ diff --git a/server/lib/validators.test.ts b/server/lib/validators.test.ts index 5ce95f45c..c17181c6a 100644 --- a/server/lib/validators.test.ts +++ b/server/lib/validators.test.ts @@ -1,9 +1,10 @@ import { getResourceRuleValueValidationError, isValidDomain, - isValidUrlGlobPattern + isValidUrlGlobPattern, + parseHttpMethodList } from "./validators"; -import { assertEquals } from "@test/assert"; +import { assertEquals, assertEqualsObj } from "@test/assert"; function runTests() { console.log("Running domain validation tests..."); @@ -295,6 +296,44 @@ function runTests() { "Invalid ASN should return an error" ); + // HTTP method validation tests + assertEquals( + getResourceRuleValueValidationError("METHOD", "POST"), + null, + "Single HTTP method should be valid" + ); + assertEquals( + getResourceRuleValueValidationError("METHOD", " post , Put "), + null, + "Method list should be valid with mixed case and whitespace" + ); + assertEquals( + getResourceRuleValueValidationError("METHOD", "PROPFIND"), + null, + "Extension methods such as the WebDAV verbs should be valid" + ); + assertEquals( + getResourceRuleValueValidationError("METHOD", ""), + "Invalid HTTP method provided", + "Empty method list should return an error" + ); + assertEquals( + getResourceRuleValueValidationError("METHOD", ",,"), + "Invalid HTTP method provided", + "Method list of only separators should return an error" + ); + assertEquals( + getResourceRuleValueValidationError("METHOD", "GET POST"), + "Invalid HTTP method provided", + "Space separated methods should return an error" + ); + + assertEqualsObj( + parseHttpMethodList(" get ,post, "), + ["GET", "POST"], + "Method list should be normalized to uppercase without empty entries" + ); + console.log("All tests passed!"); } diff --git a/server/lib/validators.ts b/server/lib/validators.ts index 872ced221..d5bf5d2cc 100644 --- a/server/lib/validators.ts +++ b/server/lib/validators.ts @@ -76,9 +76,46 @@ export const RESOURCE_RULE_MATCH_TYPES = [ "COUNTRY", "COUNTRY_IS_NOT", "ASN", - "REGION" + "REGION", + "METHOD" ] as const; +// The methods offered in the UI: the eight from RFC 9110 plus PATCH (RFC 5789) +// and QUERY (RFC 10008). A METHOD rule is not limited to these, since +// isValidHttpMethodList accepts any method token, so blueprints and the API can +// also target extension methods such as the WebDAV verbs. +export const HTTP_METHODS = [ + "GET", + "HEAD", + "POST", + "PUT", + "PATCH", + "DELETE", + "OPTIONS", + "TRACE", + "CONNECT", + "QUERY" +] as const; + +// RFC 9110 token, minus the characters that would collide with the +// comma-separated list encoding. +const HTTP_METHOD_REGEX = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/; + +export function parseHttpMethodList(value: string): string[] { + return value + .split(",") + .map((method) => method.trim().toUpperCase()) + .filter((method) => method.length > 0); +} + +export function isValidHttpMethodList(value: string): boolean { + const methods = parseHttpMethodList(value); + return ( + methods.length > 0 && + methods.every((method) => HTTP_METHOD_REGEX.test(method)) + ); +} + export type ResourceRuleMatchType = (typeof RESOURCE_RULE_MATCH_TYPES)[number]; export function getResourceRuleValueValidationError( @@ -101,6 +138,10 @@ export function getResourceRuleValueValidationError( return COUNTRIES.some((country) => country.code === value) ? null : "Invalid country code provided"; + case "METHOD": + return isValidHttpMethodList(value) + ? null + : "Invalid HTTP method provided"; case "ASN": const normalizedValue = value.trim().toUpperCase(); return /^AS\d+$/.test(normalizedValue) || diff --git a/server/routers/badger/verifySession.ts b/server/routers/badger/verifySession.ts index 486feb2b7..b8ecf6b9e 100644 --- a/server/routers/badger/verifySession.ts +++ b/server/routers/badger/verifySession.ts @@ -40,6 +40,7 @@ import { import config from "@server/lib/config"; import { isIpInCidr, stripPortFromHost } from "@server/lib/ip"; import { isPathAllowed } from "@server/lib/pathMatch"; +import { parseHttpMethodList } from "@server/lib/validators"; import { response } from "@server/lib/response"; import logger from "@server/logger"; import HttpCode from "@server/types/HttpCode"; @@ -163,6 +164,7 @@ export async function verifyResourceSession( path, headers, query, + method, badgerVersion } = parsedBody.data; @@ -293,7 +295,8 @@ export async function verifyResourceSession( clientIp, path, ipCC, - ipAsn + ipAsn, + method ); if (action == "ACCEPT") { @@ -1429,7 +1432,8 @@ async function checkRules( clientIp: string | undefined, path: string | undefined, ipCC?: string, - ipAsn?: number + ipAsn?: number, + method?: string ): Promise<"ACCEPT" | "DROP" | "PASS" | undefined> { const ruleCacheKey = `rules:${resourceId}`; @@ -1504,12 +1508,24 @@ async function checkRules( (await isIpInRegion(ipCC, rule.value)) ) { return rule.action as any; + } else if ( + method && + rule.match == "METHOD" && + isMethodAllowed(rule.value, method) + ) { + return rule.action as any; } } return; } +// rule.value holds a comma-separated list of HTTP methods, e.g. "POST,PUT". +function isMethodAllowed(ruleValue: string, method: string): boolean { + const requestMethod = method.toUpperCase(); + return parseHttpMethodList(ruleValue).includes(requestMethod); +} + export { isPathAllowed }; async function isIpInGeoIP( diff --git a/src/components/resource-policy/PolicyAccessRulesTable.tsx b/src/components/resource-policy/PolicyAccessRulesTable.tsx index 2ff2e1915..dba282342 100644 --- a/src/components/resource-policy/PolicyAccessRulesTable.tsx +++ b/src/components/resource-policy/PolicyAccessRulesTable.tsx @@ -37,6 +37,7 @@ import { cn } from "@app/lib/cn"; import { MAJOR_ASNS } from "@server/db/asns"; import { COUNTRIES } from "@server/db/countries"; import { REGIONS, getRegionNameById } from "@server/db/regions"; +import { HTTP_METHODS, parseHttpMethodList } from "@server/lib/validators"; import { ColumnDef, flexRender, @@ -63,7 +64,8 @@ import { } from "react"; import { validatePolicyRulePriority, - validatePolicyRuleValue + validatePolicyRuleValue, + type PolicyRuleMatchType } from "./policy-access-rule-validation"; import { buildDisplayPrioritiesForResourceOverlay, @@ -112,6 +114,80 @@ function getColumnClassName(columnId: string) { return ""; } +// A METHOD rule stores its methods as a comma-separated list in rule.value, +// e.g. "POST,PUT". Only the common methods are offered here; a value set +// through a blueprint or the API may contain other methods (the WebDAV verbs, +// for instance), so those are kept and shown rather than dropped on edit. +function RuleMethodSelect({ + value, + disabled, + placeholder, + onChange +}: { + value: string; + disabled: boolean; + placeholder: string; + onChange: (value: string) => void; +}) { + const selected = parseHttpMethodList(value); + const knownMethods: readonly string[] = HTTP_METHODS; + const options = [ + ...knownMethods, + ...selected.filter((method) => !knownMethods.includes(method)) + ]; + + function toggle(method: string) { + const next = selected.includes(method) + ? selected.filter((m) => m !== method) + : [...selected, method]; + + // keep a stable order so the stored value does not churn on every edit + onChange(options.filter((m) => next.includes(m)).join(",")); + } + + return ( + + + + + + + + + {options.map((method) => ( + toggle(method)} + > + + {method} + + ))} + + + + + + ); +} + export function PolicyAccessRulesTable({ rules, onRulesChange, @@ -233,7 +309,8 @@ export function PolicyAccessRulesTable({ COUNTRY: t("country"), COUNTRY_IS_NOT: t("countryIsNot"), ASN: "ASN", - REGION: t("region") + REGION: t("region"), + METHOD: t("method") }), [t] ); @@ -438,16 +515,7 @@ export function PolicyAccessRulesTable({ COUNTRIES.some((country) => country.code === value), { message: t("rulesErrorInvalidCountryDescription") } ); + case "METHOD": + return required.refine(isValidHttpMethodList, { + message: t("rulesErrorInvalidMethodDescription") + }); case "ASN": return required.refine( (value) => { From c2902398942703e84e0166f5fde5a52602b5ba3a Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 21 Sep 2026 09:14:16 -0400 Subject: [PATCH 25/37] Use postgresql Fix #3794 --- config/ha-reference/node1/docker-compose.yml | 2 +- config/ha-reference/node2/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/ha-reference/node1/docker-compose.yml b/config/ha-reference/node1/docker-compose.yml index c8f80d603..a473ee8d4 100644 --- a/config/ha-reference/node1/docker-compose.yml +++ b/config/ha-reference/node1/docker-compose.yml @@ -1,7 +1,7 @@ name: pangolin services: pangolin: - image: docker.io/fosrl/pangolin:ee-latest + image: docker.io/fosrl/pangolin:ee-postgresql-latest container_name: pangolin restart: unless-stopped volumes: diff --git a/config/ha-reference/node2/docker-compose.yml b/config/ha-reference/node2/docker-compose.yml index 8a2e6d4d7..fa06f1404 100644 --- a/config/ha-reference/node2/docker-compose.yml +++ b/config/ha-reference/node2/docker-compose.yml @@ -1,7 +1,7 @@ name: pangolin services: pangolin: - image: docker.io/fosrl/pangolin:ee-latest + image: docker.io/fosrl/pangolin:ee-postgresql-latest container_name: pangolin restart: unless-stopped volumes: From 610c228d56ea6a9d670262fcfa1e8b670e4e9c25 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 21 Sep 2026 09:14:16 -0400 Subject: [PATCH 26/37] Use postgresql Fix #3794 --- config/ha-reference/node1/docker-compose.yml | 2 +- config/ha-reference/node2/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/ha-reference/node1/docker-compose.yml b/config/ha-reference/node1/docker-compose.yml index c8f80d603..a473ee8d4 100644 --- a/config/ha-reference/node1/docker-compose.yml +++ b/config/ha-reference/node1/docker-compose.yml @@ -1,7 +1,7 @@ name: pangolin services: pangolin: - image: docker.io/fosrl/pangolin:ee-latest + image: docker.io/fosrl/pangolin:ee-postgresql-latest container_name: pangolin restart: unless-stopped volumes: diff --git a/config/ha-reference/node2/docker-compose.yml b/config/ha-reference/node2/docker-compose.yml index 8a2e6d4d7..fa06f1404 100644 --- a/config/ha-reference/node2/docker-compose.yml +++ b/config/ha-reference/node2/docker-compose.yml @@ -1,7 +1,7 @@ name: pangolin services: pangolin: - image: docker.io/fosrl/pangolin:ee-latest + image: docker.io/fosrl/pangolin:ee-postgresql-latest container_name: pangolin restart: unless-stopped volumes: From d4488ec12510f27ec02395d03fa45e85b6c46092 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Mon, 21 Sep 2026 09:57:03 -0400 Subject: [PATCH 27/37] update ios identifiers --- server/db/ios_models.json | 125 +++++++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 48 deletions(-) diff --git a/server/db/ios_models.json b/server/db/ios_models.json index 99fcbea17..43dfe5687 100644 --- a/server/db/ios_models.json +++ b/server/db/ios_models.json @@ -4,42 +4,18 @@ "iPad2,2": "iPad 2", "iPad2,3": "iPad 2", "iPad2,4": "iPad 2", - "iPad3,1": "iPad 3rd Gen", - "iPad3,3": "iPad 3rd Gen", - "iPad3,2": "iPad 3rd Gen", - "iPad3,4": "iPad 4th Gen", - "iPad3,5": "iPad 4th Gen", - "iPad3,6": "iPad 4th Gen", - "iPad6,11": "iPad 9.7 5th Gen", - "iPad6,12": "iPad 9.7 5th Gen", - "iPad7,5": "iPad 9.7 6th Gen", - "iPad7,6": "iPad 9.7 6th Gen", - "iPad7,11": "iPad 10.2 7th Gen", - "iPad7,12": "iPad 10.2 7th Gen", - "iPad11,6": "iPad 10.2 8th Gen", - "iPad11,7": "iPad 10.2 8th Gen", - "iPad12,1": "iPad 10.2 9th Gen", - "iPad12,2": "iPad 10.2 9th Gen", - "iPad13,18": "iPad 10.9 10th Gen", - "iPad13,19": "iPad 10.9 10th Gen", - "iPad4,1": "iPad Air", - "iPad4,2": "iPad Air", - "iPad4,3": "iPad Air", - "iPad5,3": "iPad Air 2", - "iPad5,4": "iPad Air 2", - "iPad11,3": "iPad Air 3rd Gen", - "iPad11,4": "iPad Air 3rd Gen", - "iPad13,1": "iPad Air 4th Gen", - "iPad13,2": "iPad Air 4th Gen", - "iPad13,16": "iPad Air 5th Gen", - "iPad13,17": "iPad Air 5th Gen", - "iPad14,8": "iPad Air M2 11", - "iPad14,9": "iPad Air M2 11", - "iPad14,10": "iPad Air M2 13", - "iPad14,11": "iPad Air M2 13", "iPad2,5": "iPad mini", "iPad2,6": "iPad mini", "iPad2,7": "iPad mini", + "iPad3,1": "iPad 3rd Gen", + "iPad3,2": "iPad 3rd Gen", + "iPad3,3": "iPad 3rd Gen", + "iPad3,4": "iPad 4th Gen", + "iPad3,5": "iPad 4th Gen", + "iPad3,6": "iPad 4th Gen", + "iPad4,1": "iPad Air", + "iPad4,2": "iPad Air", + "iPad4,3": "iPad Air", "iPad4,4": "iPad mini 2", "iPad4,5": "iPad mini 2", "iPad4,6": "iPad mini 2", @@ -48,18 +24,22 @@ "iPad4,9": "iPad mini 3", "iPad5,1": "iPad mini 4", "iPad5,2": "iPad mini 4", - "iPad11,1": "iPad mini 5th Gen", - "iPad11,2": "iPad mini 5th Gen", - "iPad14,1": "iPad mini 6th Gen", - "iPad14,2": "iPad mini 6th Gen", - "iPad6,7": "iPad Pro 12.9", - "iPad6,8": "iPad Pro 12.9", + "iPad5,3": "iPad Air 2", + "iPad5,4": "iPad Air 2", "iPad6,3": "iPad Pro 9.7", "iPad6,4": "iPad Pro 9.7", - "iPad7,3": "iPad Pro 10.5", - "iPad7,4": "iPad Pro 10.5", + "iPad6,7": "iPad Pro 12.9", + "iPad6,8": "iPad Pro 12.9", + "iPad6,11": "iPad 9.7 5th Gen", + "iPad6,12": "iPad 9.7 5th Gen", "iPad7,1": "iPad Pro 12.9", "iPad7,2": "iPad Pro 12.9", + "iPad7,3": "iPad Pro 10.5", + "iPad7,4": "iPad Pro 10.5", + "iPad7,5": "iPad 9.7 6th Gen", + "iPad7,6": "iPad 9.7 6th Gen", + "iPad7,11": "iPad 10.2 7th Gen", + "iPad7,12": "iPad 10.2 7th Gen", "iPad8,1": "iPad Pro 11", "iPad8,2": "iPad Pro 11", "iPad8,3": "iPad Pro 11", @@ -72,6 +52,16 @@ "iPad8,10": "iPad Pro 11", "iPad8,11": "iPad Pro 12.9", "iPad8,12": "iPad Pro 12.9", + "iPad11,1": "iPad mini 5th Gen", + "iPad11,2": "iPad mini 5th Gen", + "iPad11,3": "iPad Air 3rd Gen", + "iPad11,4": "iPad Air 3rd Gen", + "iPad11,6": "iPad 10.2 8th Gen", + "iPad11,7": "iPad 10.2 8th Gen", + "iPad12,1": "iPad 10.2 9th Gen", + "iPad12,2": "iPad 10.2 9th Gen", + "iPad13,1": "iPad Air 4th Gen", + "iPad13,2": "iPad Air 4th Gen", "iPad13,4": "iPad Pro 11", "iPad13,5": "iPad Pro 11", "iPad13,6": "iPad Pro 11", @@ -80,14 +70,40 @@ "iPad13,9": "iPad Pro 12.9", "iPad13,10": "iPad Pro 12.9", "iPad13,11": "iPad Pro 12.9", + "iPad13,16": "iPad Air M1 5th Gen", + "iPad13,17": "iPad Air M1 5th Gen", + "iPad13,18": "iPad 10.9 10th Gen", + "iPad13,19": "iPad 10.9 10th Gen", + "iPad14,1": "iPad mini 6th Gen", + "iPad14,2": "iPad mini 6th Gen", "iPad14,3": "iPad Pro 11", "iPad14,4": "iPad Pro 11", "iPad14,5": "iPad Pro 12.9", "iPad14,6": "iPad Pro 12.9", + "iPad14,8": "iPad Air M2 11", + "iPad14,9": "iPad Air M2 11", + "iPad14,10": "iPad Air M2 13", + "iPad14,11": "iPad Air M2 13", + "iPad15,3": "iPad Air M3 11", + "iPad15,4": "iPad Air M3 11", + "iPad15,5": "iPad Air M3 13", + "iPad15,6": "iPad Air M3 13", + "iPad15,7": "iPad A16 - 11th Gen", + "iPad15,8": "iPad A16 - 11th Gen", + "iPad16,1": "iPad mini A17 Pro - 7th Gen", + "iPad16,2": "iPad mini A17 Pro - 7th Gen", "iPad16,3": "iPad Pro M4 11", "iPad16,4": "iPad Pro M4 11", "iPad16,5": "iPad Pro M4 13", "iPad16,6": "iPad Pro M4 13", + "iPad16,8": "iPad Air M4 11", + "iPad16,9": "iPad Air M4 11", + "iPad16,10": "iPad Air M4 13", + "iPad16,11": "iPad Air M4 13", + "iPad17,1": "iPad Pro M5 11", + "iPad17,2": "iPad Pro M5 11", + "iPad17,3": "iPad Pro M5 13", + "iPad17,4": "iPad Pro M5 13", "iPhone1,1": "iPhone", "iPhone1,2": "iPhone 3G", "iPhone2,1": "iPhone 3GS", @@ -101,20 +117,20 @@ "iPhone5,4": "iPhone 5c", "iPhone6,1": "iPhone 5s", "iPhone6,2": "iPhone 5s", - "iPhone7,2": "iPhone 6", "iPhone7,1": "iPhone 6 Plus", + "iPhone7,2": "iPhone 6", "iPhone8,1": "iPhone 6s", "iPhone8,2": "iPhone 6s Plus", "iPhone8,4": "iPhone SE", "iPhone9,1": "iPhone 7", - "iPhone9,3": "iPhone 7", "iPhone9,2": "iPhone 7 Plus", + "iPhone9,3": "iPhone 7", "iPhone9,4": "iPhone 7 Plus", "iPhone10,1": "iPhone 8", - "iPhone10,4": "iPhone 8", "iPhone10,2": "iPhone 8 Plus", - "iPhone10,5": "iPhone 8 Plus", "iPhone10,3": "iPhone X", + "iPhone10,4": "iPhone 8", + "iPhone10,5": "iPhone 8 Plus", "iPhone10,6": "iPhone X", "iPhone11,2": "iPhone Xs", "iPhone11,6": "iPhone Xs Max", @@ -127,10 +143,10 @@ "iPhone13,2": "iPhone 12", "iPhone13,3": "iPhone 12 Pro", "iPhone13,4": "iPhone 12 Pro Max", - "iPhone14,4": "iPhone 13 mini", - "iPhone14,5": "iPhone 13", "iPhone14,2": "iPhone 13 Pro", "iPhone14,3": "iPhone 13 Pro Max", + "iPhone14,4": "iPhone 13 mini", + "iPhone14,5": "iPhone 13", "iPhone14,6": "iPhone SE", "iPhone14,7": "iPhone 14", "iPhone14,8": "iPhone 14 Plus", @@ -140,6 +156,19 @@ "iPhone15,5": "iPhone 15 Plus", "iPhone16,1": "iPhone 15 Pro", "iPhone16,2": "iPhone 15 Pro Max", + "iPhone17,1": "iPhone 16 Pro", + "iPhone17,2": "iPhone 16 Pro Max", + "iPhone17,3": "iPhone 16", + "iPhone17,4": "iPhone 16 Plus", + "iPhone17,5": "iPhone 16e", + "iPhone18,1": "iPhone 17 Pro", + "iPhone18,2": "iPhone 17 Pro Max", + "iPhone18,3": "iPhone 17", + "iPhone18,4": "iPhone Air", + "iPhone18,5": "iPhone 17e", + "iPhone19,2": "iPhone 18 Pro", + "iPhone19,3": "iPhone 18 Pro Max", + "iPhone19,7": "iPhone 18 Pro Max", "iPod1,1": "iPod touch Original", "iPod2,1": "iPod touch 2nd", "iPod3,1": "iPod touch 3rd Gen", @@ -147,4 +176,4 @@ "iPod5,1": "iPod touch 5th", "iPod7,1": "iPod touch 6th Gen", "iPod9,1": "iPod touch 7th Gen" -} \ No newline at end of file +} From 6f3e0cf5a636621c382a3dcfb0272cf3c557f999 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 21 Sep 2026 10:18:45 -0400 Subject: [PATCH 28/37] Time is un utc --- server/emails/templates/AlertNotification.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/emails/templates/AlertNotification.tsx b/server/emails/templates/AlertNotification.tsx index c81cf60da..dc6d60131 100644 --- a/server/emails/templates/AlertNotification.tsx +++ b/server/emails/templates/AlertNotification.tsx @@ -235,7 +235,7 @@ export const AlertNotification = (props: AlertNotificationProps) => { } ] : []), - { label: "Time", value: new Date().toUTCString() }, + { label: "Time (UTC)", value: new Date().toUTCString() }, ...dataItems ]; @@ -265,8 +265,8 @@ export const AlertNotification = (props: AlertNotificationProps) => { {isTestAlert && ( - This is a test alert. No action is required, - and no real event has occurred. + This is a test alert. No action is required, and + no real event has occurred. )} From 887c6e4e8b6e0b44c7630501b1495f434b8d78d9 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 21 Sep 2026 11:10:37 -0400 Subject: [PATCH 29/37] Remove linting until 7.1 release --- .github/workflows/linting.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 4bd0d2a90..451d2eb45 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -3,18 +3,25 @@ name: ESLint permissions: contents: read +# Disabled from running on PRs: typescript-eslint does not yet support +# TypeScript 7 (which this repo is on), so eslint currently crashes on +# every run. Kept as workflow_dispatch so it can still be triggered +# manually, and re-enabled on pull_request once upstream support lands. +# https://github.com/typescript-eslint/typescript-eslint/issues/10940 +# on: +# pull_request: +# paths: +# - '**/*.js' +# - '**/*.jsx' +# - '**/*.ts' +# - '**/*.tsx' +# - '.eslintrc*' +# - 'package.json' +# - 'yarn.lock' +# - 'pnpm-lock.yaml' +# - 'package-lock.json' on: - pull_request: - paths: - - '**/*.js' - - '**/*.jsx' - - '**/*.ts' - - '**/*.tsx' - - '.eslintrc*' - - 'package.json' - - 'yarn.lock' - - 'pnpm-lock.yaml' - - 'package-lock.json' + workflow_dispatch: jobs: Linter: From 750f26745172cb0b27293288b89640062d0d5f3c Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 21 Sep 2026 16:25:58 -0400 Subject: [PATCH 30/37] Try to link email to org when creating for first time --- server/lib/billing/index.ts | 1 + server/lib/billing/linkEmailOrg.ts | 6 +++ server/private/lib/billing/index.ts | 1 + server/private/lib/billing/linkEmailOrg.ts | 56 ++++++++++++++++++++++ server/routers/org/createOrg.ts | 3 +- 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 server/lib/billing/linkEmailOrg.ts create mode 100644 server/private/lib/billing/linkEmailOrg.ts diff --git a/server/lib/billing/index.ts b/server/lib/billing/index.ts index 54c9ee2e0..1bc354f7e 100644 --- a/server/lib/billing/index.ts +++ b/server/lib/billing/index.ts @@ -3,3 +3,4 @@ export * from "./features"; export * from "./limitsService"; export * from "./getOrgTierData"; export * from "./createCustomer"; +export * from "./linkEmailOrg"; diff --git a/server/lib/billing/linkEmailOrg.ts b/server/lib/billing/linkEmailOrg.ts new file mode 100644 index 000000000..df67d2ed8 --- /dev/null +++ b/server/lib/billing/linkEmailOrg.ts @@ -0,0 +1,6 @@ +export async function linkEmailOrg( + orgId: string, + email: string | null | undefined +): Promise { + return; +} diff --git a/server/private/lib/billing/index.ts b/server/private/lib/billing/index.ts index 4d52668c0..0223b8aca 100644 --- a/server/private/lib/billing/index.ts +++ b/server/private/lib/billing/index.ts @@ -13,3 +13,4 @@ export * from "./getOrgTierData"; export * from "./createCustomer"; +export * from "./linkEmailOrg"; diff --git a/server/private/lib/billing/linkEmailOrg.ts b/server/private/lib/billing/linkEmailOrg.ts new file mode 100644 index 000000000..c14485a3d --- /dev/null +++ b/server/private/lib/billing/linkEmailOrg.ts @@ -0,0 +1,56 @@ +/* + * This file is part of a proprietary work. + * + * Copyright (c) 2025-2026 Fossorial, Inc. + * All rights reserved. + * + * This file is licensed under the Fossorial Commercial License. + * You may not use this file except in compliance with the License. + * Unauthorized use, copying, modification, or distribution is strictly prohibited. + * + * This file is not licensed under the AGPLv3. + */ + +import logger from "@server/logger"; +import privateConfig from "#private/lib/config"; +import { build } from "@server/build"; + +export async function linkEmailOrg( + orgId: string, + email: string | null | undefined +): Promise { + if (build !== "saas") { + return; + } + + if (!email) { + return; + } + + try { + const response = await fetch( + `${privateConfig.getRawPrivateConfig().server.fossorial_api}/api/v1/license-internal/enterprise/link-email-org`, + { + method: "POST", + headers: { + "api-key": + privateConfig.getRawPrivateConfig().server + .fossorial_api_key!, + "Content-Type": "application/json" + }, + body: JSON.stringify({ email, orgId }) + } + ); + + if (!response.ok && response.status !== 404) { + logger.error( + `Fossorial API returned ${response.status} when linking email ${email} to orgId ${orgId}: ${await response.text()}` + ); + } + } catch (error) { + logger.error( + `Error notifying Fossorial API of email/org link for orgId ${orgId}:`, + error + ); + } +} diff --git a/server/routers/org/createOrg.ts b/server/routers/org/createOrg.ts index a4efc991d..6abc589d6 100644 --- a/server/routers/org/createOrg.ts +++ b/server/routers/org/createOrg.ts @@ -25,7 +25,7 @@ import { fromError } from "zod-validation-error"; import { defaultRoleAllowedActions } from "../role"; import { OpenAPITags, registry } from "@server/openApi"; import { isValidCIDR } from "@server/lib/validators"; -import { createCustomer } from "#dynamic/lib/billing"; +import { createCustomer, linkEmailOrg } from "#dynamic/lib/billing"; import { usageService } from "@server/lib/billing/usageService"; import { LimitId, limitsService, freeLimitSet } from "@server/lib/billing"; import { build } from "@server/build"; @@ -425,6 +425,7 @@ export async function createOrg( customerId ); // Only 1 because we are creating the org } + await linkEmailOrg(orgId, req.user?.email); } if (numOrgs) { From d134304159af114b3c62a690d1205904ad293931 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 22 Sep 2026 09:33:43 -0400 Subject: [PATCH 31/37] Add alpine install commands --- src/components/newt-install-commands.tsx | 82 +++++++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/src/components/newt-install-commands.tsx b/src/components/newt-install-commands.tsx index e1c7422f6..5d24f76dc 100644 --- a/src/components/newt-install-commands.tsx +++ b/src/components/newt-install-commands.tsx @@ -20,7 +20,7 @@ import { FaWindows } from "react-icons/fa"; import { Download, ExternalLink } from "lucide-react"; -import { SiKubernetes, SiNixos } from "react-icons/si"; +import { SiAlpinelinux, SiKubernetes, SiNixos } from "react-icons/si"; import { useEnvContext } from "@app/hooks/useEnvContext"; export type CommandItem = @@ -30,6 +30,7 @@ export type CommandItem = const PLATFORMS = [ "linux", + "alpine", "macos", "docker", "kubernetes", @@ -65,7 +66,8 @@ export function NewtSiteInstallCommands({ ); const showSiteConfiguration = platform !== "advantech"; - const supportsSshOption = platform === "linux" || platform === "nixos"; + const supportsSshOption = + platform === "linux" || platform === "nixos" || platform === "alpine"; const acceptClientsFlag = !acceptClients ? " --disable-clients" : ""; const acceptClientsEnv = !acceptClients @@ -168,6 +170,76 @@ sudo systemctl enable --now pangolin-site` } ] }, + alpine: { + Run: [ + { + title: t("install"), + command: `curl -fsSL https://static.pangolin.net/get-cli.sh | bash` + }, + { + title: t("run"), + command: `${runAsRootPrefix}pangolin up site --id ${id} --secret ${secret} --endpoint ${endpoint}${acceptClientsFlag}${disableSshFlag}` + } + ], + "Manual OpenRC Service": [ + { + title: t("install"), + command: `curl -fsSL https://static.pangolin.net/get-cli.sh | bash` + }, + { + title: t("envFile"), + command: `sudo tee /etc/conf.d/pangolin-site > /dev/null << 'EOF' +export SITE_ID=${id} +export SITE_SECRET=${secret} +export PANGOLIN_ENDPOINT=${endpoint}${ + !acceptClients + ? ` +export DISABLE_CLIENTS=true` + : "" + }${ + !allowPangolinSsh + ? ` +export DISABLE_SSH=true` + : "" + } +EOF +sudo chmod 600 /etc/conf.d/pangolin-site` + }, + { + title: t("serviceFile"), + command: `sudo tee /etc/init.d/pangolin-site > /dev/null << 'EOF' +#!/sbin/openrc-run + +name="pangolin-site" +description="Pangolin Site" + +command="/usr/local/bin/pangolin" +command_args="up site" +command_background="yes" +supervisor="supervise-daemon" + +pidfile="/run/pangolin-site.pid" +output_log="/var/log/pangolin-site.log" +error_log="/var/log/pangolin-site.err" + +depend() { + need net + after firewall +} +EOF +sudo chmod +x /etc/init.d/pangolin-site` + }, + { + title: t("enableAndStart"), + command: `sudo rc-update add pangolin-site default +sudo rc-service pangolin-site start` + }, + { + title: t("check"), + command: `sudo rc-service pangolin-site status` + } + ] + }, macos: { Run: [ { @@ -478,6 +550,8 @@ function getPlatformIcon(platformName: Platform) { return ; case "linux": return ; + case "alpine": + return ; case "macos": return ; case "docker": @@ -501,6 +575,8 @@ function getPlatformName(platformName: Platform) { return "Windows"; case "linux": return "Linux"; + case "alpine": + return "Alpine Linux"; case "macos": return "macOS"; case "docker": @@ -522,6 +598,8 @@ function getArchitectures(platform: Platform) { switch (platform) { case "linux": return ["Run", "Systemd Service", "Manual Systemd Service"]; + case "alpine": + return ["Run", "Manual OpenRC Service"]; case "macos": return ["Run", "Service"]; case "windows": From 9de91e2f81dd1347d36903ed8f8376c32b394ac7 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 22 Sep 2026 09:39:17 -0400 Subject: [PATCH 32/37] Display the quantities again --- messages/en-US.json | 8 + src/app/admin/license/page.tsx | 210 ++++++++++++++++-------- src/components/LicenseKeysDataTable.tsx | 48 ++++++ 3 files changed, 201 insertions(+), 65 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index 6be431209..37d1390e6 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -590,6 +590,14 @@ "licensePurchaseSites": "Purchase Additional Sites", "licenseSitesUsedMax": "{usedSites} of {maxSites} sites used", "licenseSitesUsed": "{count, plural, =0 {# sites} one {# site} other {# sites}} in system.", + "licenseUsage": "License Usage", + "licenseUsageDescription": "View the number of users and sites licensed for this host.", + "licenseUsageSites": "Sites", + "licenseUsageUsers": "Users", + "licenseNoUserLimit": "There is no limit on the number of users using an unlicensed host.", + "licenseUsersUsedMax": "{usedUsers} of {maxUsers} users used", + "licenseUsersUsed": "{count, plural, =0 {# users} one {# user} other {# users}} in system.", + "licenseUnlimited": "Unlimited", "licensePurchaseDescription": "Choose how many sites you want to {selectedMode, select, license {purchase a license for. You can always add more sites later.} other {add to your existing license.}}", "licenseFee": "License fee", "licensePriceSite": "Price per site", diff --git a/src/app/admin/license/page.tsx b/src/app/admin/license/page.tsx index e3051664d..33cf86d96 100644 --- a/src/app/admin/license/page.tsx +++ b/src/app/admin/license/page.tsx @@ -41,6 +41,7 @@ import { SettingsSectionHeader, SettingsSectionFooter } from "@app/components/Settings"; +import { Progress } from "@app/components/ui/progress"; import SettingsSectionTitle from "@app/components/SettingsSectionTitle"; import { ArrowRight, @@ -64,13 +65,6 @@ const ENTERPRISE_DOCS_URL = "https://docs.pangolin.net/self-host/enterprise-edition"; const ENTERPRISE_PRICING_URL = "https://pangolin.net/pricing#Self-Hosted"; -function obfuscateLicenseKey(key: string): string { - if (key.length <= 8) return key; - const firstPart = key.substring(0, 4); - const lastPart = key.substring(key.length - 4); - return `${firstPart}••••••••••••••••••••${lastPart}`; -} - export default function LicensePage() { const api = createApiClient(useEnvContext()); const [rows, setRows] = useState([]); @@ -80,7 +74,6 @@ export default function LicensePage() { useState(null); const { licenseStatus, updateLicenseStatus } = useLicenseStatusContext(); - const [hostLicense, setHostLicense] = useState(null); const [isPurchaseModalOpen, setIsPurchaseModalOpen] = useState(false); const [purchaseMode, setPurchaseMode] = useState<"license">("license"); @@ -128,12 +121,6 @@ export default function LicensePage() { ); const keys = response.data.data; setRows(keys); - const hostKey = keys.find((key) => key.type === "host"); - if (hostKey) { - setHostLicense(hostKey.licenseKey); - } else { - setHostLicense(null); - } } catch (e) { toast({ title: t("licenseErrorKeyLoad"), @@ -399,62 +386,155 @@ export default function LicensePage() { {/* */} - - - {t("licenseHost")} - - {t("licenseHostDescription")} - - -
-
- {licenseStatus?.isLicenseValid ? ( -
-
- - {t("licensed") + - `${licenseStatus?.tier === "personal" ? ` (${t("personalUseOnly")})` : ""}`} -
+ + + + {t("licenseUsage")} + + {t("licenseUsageDescription")} + + +
+
+
+ {t("licenseUsageSites")}
- ) : (
- {t("unlicensed")} + {t("licenseSitesUsed", { + count: licenseStatus?.usedSites || 0 + })} +
+ {licenseStatus?.maxSites ? ( +
+
+ + {t("licenseSitesUsedMax", { + usedSites: + licenseStatus.usedSites || + 0, + maxSites: + licenseStatus.maxSites + })} + + + {Math.round( + ((licenseStatus.usedSites || + 0) / + licenseStatus.maxSites) * + 100 + )} + % + +
+ +
+ ) : ( +
+ {t("licenseNoSiteLimit")} +
+ )} +
+
+
+ {t("licenseUsageUsers")} +
+
+ {t("licenseUsersUsed", { + count: licenseStatus?.usedUsers || 0 + })} +
+ {licenseStatus?.maxUsers ? ( +
+
+ + {t("licenseUsersUsedMax", { + usedUsers: + licenseStatus.usedUsers || + 0, + maxUsers: + licenseStatus.maxUsers + })} + + + {Math.round( + ((licenseStatus.usedUsers || + 0) / + licenseStatus.maxUsers) * + 100 + )} + % + +
+ +
+ ) : ( +
+ {t("licenseNoUserLimit")} +
+ )} +
+
+
+ + + {t("licenseHost")} + + {t("licenseHostDescription")} + + +
+
+ {licenseStatus?.isLicenseValid ? ( +
+
+ + {t("licensed") + + `${licenseStatus?.tier === "personal" ? ` (${t("personalUseOnly")})` : ""}`} +
+
+ ) : ( +
+ {t("unlicensed")} +
+ )} +
+ {licenseStatus?.hostId && ( +
+
+ {t("hostId")} +
+
)}
- {licenseStatus?.hostId && ( -
-
- {t("hostId")} -
- -
- )} - {hostLicense && ( -
-
- {t("licenseKey")} -
- -
- )} -
- - - - + + + + + { diff --git a/src/components/LicenseKeysDataTable.tsx b/src/components/LicenseKeysDataTable.tsx index 4b63a7b28..1e4f47a82 100644 --- a/src/components/LicenseKeysDataTable.tsx +++ b/src/components/LicenseKeysDataTable.tsx @@ -112,6 +112,54 @@ export function LicenseKeysDataTable({ } } }, + { + accessorKey: "quantity", + friendlyName: t("users"), + header: ({ column }) => { + return ( + + ); + }, + cell: ({ row }) => { + const quantity = row.original.quantity; + if (quantity === undefined) { + return "-"; + } + return quantity < 0 ? t("licenseUnlimited") : quantity; + } + }, + { + accessorKey: "quantity_2", + friendlyName: t("sites"), + header: ({ column }) => { + return ( + + ); + }, + cell: ({ row }) => { + const quantity = row.original.quantity_2; + if (quantity === undefined) { + return "-"; + } + return quantity < 0 ? t("licenseUnlimited") : quantity; + } + }, { accessorKey: "terminateAt", friendlyName: t("licenseTableValidUntil"), From 0364257e68d9fb720c31a5f55fc933e1986c44bc Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 22 Sep 2026 09:45:11 -0400 Subject: [PATCH 33/37] Pick key based on tier ranked --- server/private/license/license.ts | 40 +++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/server/private/license/license.ts b/server/private/license/license.ts index 61ea23b48..0ff77bc4f 100644 --- a/server/private/license/license.ts +++ b/server/private/license/license.ts @@ -50,6 +50,27 @@ type ValidateLicenseAPIResponse = { status: number; }; +// Ranks license tiers so that when multiple license keys are active, the +// highest tier among them wins. Order: personal < tier1 < tier2 < ... < +// tier[n] < enterprise. Tier numbers are parsed so this scales to any +// tier[n] without needing updates here. +function tierRank(tier?: LicenseKeyTier): number { + if (!tier) { + return -1; + } + if (tier === "enterprise") { + return Number.MAX_SAFE_INTEGER; + } + if (tier === "personal") { + return 0; + } + const match = /^tier(\d+)$/.exec(tier); + if (match) { + return parseInt(match[1], 10); + } + return 0; +} + type TokenPayload = { valid: boolean; type: LicenseKeyType; @@ -371,12 +392,22 @@ LQIDAQAB } // Compute host status: quantity = users, quantity_2 = sites + // When multiple host keys are active, prefer a valid key over an + // invalid one, and among equally-valid keys prefer the highest tier. + let selectedHostKey: LicenseKeyCache | undefined; for (const key of keys) { const cached = newCache.get(key.licenseKey)!; if (cached.type === "host") { - status.isLicenseValid = cached.valid; - status.tier = cached.tier; + if ( + !selectedHostKey || + (cached.valid && !selectedHostKey.valid) || + (cached.valid === selectedHostKey.valid && + tierRank(cached.tier) > + tierRank(selectedHostKey.tier)) + ) { + selectedHostKey = cached; + } } if (!cached.valid) { @@ -393,6 +424,11 @@ LQIDAQAB } } + if (selectedHostKey) { + status.isLicenseValid = selectedHostKey.valid; + status.tier = selectedHostKey.tier; + } + // Invalidate license if over user or site limits if ( (status.maxSites !== undefined && From 0de5c763b331f4934c1e39edb04fc15903f048a0 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 22 Sep 2026 09:53:05 -0400 Subject: [PATCH 34/37] Order by valid until --- src/components/LicenseKeysDataTable.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/LicenseKeysDataTable.tsx b/src/components/LicenseKeysDataTable.tsx index 1e4f47a82..939686503 100644 --- a/src/components/LicenseKeysDataTable.tsx +++ b/src/components/LicenseKeysDataTable.tsx @@ -206,6 +206,7 @@ export function LicenseKeysDataTable({ title={t("licenseKeys")} searchPlaceholder={t("licenseKeySearch")} searchColumn="licenseKey" + defaultSort={{ id: "terminateAt", desc: false }} onAdd={onCreate} addButtonText={t("licenseKeyAdd")} enableColumnVisibility={true} From d38281b9f7de3b6af518f2c9dc845bfb946c6578 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 22 Sep 2026 10:37:52 -0400 Subject: [PATCH 35/37] Update language and add debug --- messages/en-US.json | 17 +++++++++-------- server/private/license/license.ts | 12 ++++++++++++ src/app/admin/license/page.tsx | 27 ++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index 37d1390e6..f7f4c05f6 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -576,10 +576,10 @@ "licenseQuestionRemove": "Are you sure you want to delete the license key ?", "licenseKeyDelete": "Delete License Key", "licenseKeyDeleteConfirm": "Confirm Delete License Key", - "licenseTitle": "Manage License Status", + "licenseTitle": "Manage Licenses", "licenseTitleDescription": "View and manage license keys in the system", - "licenseHost": "Host License", - "licenseHostDescription": "Manage the main license key for the host.", + "licenseHost": "License", + "licenseHostDescription": "See the license tier and host information", "licensedNot": "Not Licensed", "hostId": "Host ID", "licenseReckeckAll": "Recheck All Keys", @@ -589,15 +589,16 @@ "licensePurchase": "Purchase License", "licensePurchaseSites": "Purchase Additional Sites", "licenseSitesUsedMax": "{usedSites} of {maxSites} sites used", - "licenseSitesUsed": "{count, plural, =0 {# sites} one {# site} other {# sites}} in system.", - "licenseUsage": "License Usage", - "licenseUsageDescription": "View the number of users and sites licensed for this host.", + "licenseSitesUsed": "{count, plural, =0 {# sites} one {# site} other {# sites}}", + "licenseUsage": "Usage", + "licenseUsageDescription": "View the number of users and sites licensed for this host", "licenseUsageSites": "Sites", "licenseUsageUsers": "Users", - "licenseNoUserLimit": "There is no limit on the number of users using an unlicensed host.", + "licenseNoUserLimit": "There is no limit on the number of users using an unlicensed hot", "licenseUsersUsedMax": "{usedUsers} of {maxUsers} users used", - "licenseUsersUsed": "{count, plural, =0 {# users} one {# user} other {# users}} in system.", + "licenseUsersUsed": "{count, plural, =0 {# users} one {# user} other {# users}}", "licenseUnlimited": "Unlimited", + "licenseTierLabel": "Tier", "licensePurchaseDescription": "Choose how many sites you want to {selectedMode, select, license {purchase a license for. You can always add more sites later.} other {add to your existing license.}}", "licenseFee": "License fee", "licensePriceSite": "Price per site", diff --git a/server/private/license/license.ts b/server/private/license/license.ts index 0ff77bc4f..25eac8bc5 100644 --- a/server/private/license/license.ts +++ b/server/private/license/license.ts @@ -297,6 +297,11 @@ LQIDAQAB if (!apiResponse?.success) { throw new Error(apiResponse?.error); } + + logger.debug( + `License server response: ${JSON.stringify(apiResponse)}` + ); + // Reset failure count on success this.phoneHomeFailureCount = 0; } catch (e) { @@ -359,6 +364,11 @@ LQIDAQAB licenseKeyRes, this.publicKey ); + + logger.debug( + `Decoded license key ${key.licenseKey}: ${JSON.stringify(payload)}` + ); + cached.valid = payload.valid; cached.type = payload.type; cached.tier = payload.tier; @@ -451,6 +461,8 @@ LQIDAQAB this.checkInProgress = false; } + logger.debug(`Computed license status: ${JSON.stringify(status)}`); + this.statusCache.set(this.statusKey, status, 0); return status; } diff --git a/src/app/admin/license/page.tsx b/src/app/admin/license/page.tsx index 33cf86d96..8ed2d697d 100644 --- a/src/app/admin/license/page.tsx +++ b/src/app/admin/license/page.tsx @@ -1,7 +1,7 @@ "use client"; import { useState, useEffect } from "react"; -import { LicenseKeyCache } from "@server/license/license"; +import { LicenseKeyCache, LicenseKeyTier } from "@server/license/license"; import { createApiClient } from "@app/lib/api"; import { useEnvContext } from "@app/hooks/useEnvContext"; import { toast } from "@app/hooks/useToast"; @@ -65,6 +65,23 @@ const ENTERPRISE_DOCS_URL = "https://docs.pangolin.net/self-host/enterprise-edition"; const ENTERPRISE_PRICING_URL = "https://pangolin.net/pricing#Self-Hosted"; +function getTierLabel( + tier: LicenseKeyTier | undefined, + t: (key: string) => string +): string { + switch (tier) { + case "enterprise": + return t("licenseTierEnterprise"); + case "tier1": + return t("licenseTierTier1"); + case "tier2": + return t("licenseTierTier2"); + case "personal": + default: + return t("licenseTierPersonal"); + } +} + export default function LicensePage() { const api = createApiClient(useEnvContext()); const [rows, setRows] = useState([]); @@ -514,6 +531,14 @@ export default function LicensePage() {
)}
+
+
+ {t("licenseTierLabel")} +
+
+ {getTierLabel(licenseStatus?.tier, t)} +
+
{licenseStatus?.hostId && (
From 70f677a2775c3d17c9d2c970cafc7938464e6ea8 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 22 Sep 2026 10:40:47 -0400 Subject: [PATCH 36/37] Don't allow personal and non-personal keys at the same time --- server/private/license/license.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/server/private/license/license.ts b/server/private/license/license.ts index 25eac8bc5..16a62c042 100644 --- a/server/private/license/license.ts +++ b/server/private/license/license.ts @@ -401,6 +401,35 @@ LQIDAQAB } } + // Personal-tier licenses cannot coexist with a paid tier: if any + // valid host key is above personal, personal-tier keys are + // invalidated so they don't contribute to the totals below. + const hasHigherTierValidKey = keys.some((key) => { + const cached = newCache.get(key.licenseKey)!; + return ( + cached.type === "host" && + cached.valid && + tierRank(cached.tier) > tierRank("personal") + ); + }); + + if (hasHigherTierValidKey) { + for (const key of keys) { + const cached = newCache.get(key.licenseKey)!; + if ( + cached.type === "host" && + cached.valid && + cached.tier === "personal" + ) { + logger.debug( + `Invalidating personal license key ${key.licenseKey} because a higher tier license is present` + ); + cached.valid = false; + newCache.set(key.licenseKey, cached); + } + } + } + // Compute host status: quantity = users, quantity_2 = sites // When multiple host keys are active, prefer a valid key over an // invalid one, and among equally-valid keys prefer the highest tier. From 5fd4383396ffb69ba238434a6984335e63973a54 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 22 Sep 2026 10:50:58 -0400 Subject: [PATCH 37/37] Show information about how to get more licenses and when you have them --- messages/en-US.json | 6 +++++- src/app/admin/license/page.tsx | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/messages/en-US.json b/messages/en-US.json index f7f4c05f6..38df95476 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -235,7 +235,7 @@ "privateResourcesBannerTitle": "Zero-Trust Private Access", "privateResourcesBannerDescription": "Private resources use zero-trust security, ensuring users and machines can only access resources you explicitly grant. Connect user devices or machine clients to access these resources over a secure virtual private network.", "licenseBillingBannerTitle": "Manage License Billing", - "licenseBillingBannerDescription": "To manage billing for your license keys, including payment methods and invoices, visit the billing page.", + "licenseBillingBannerDescription": "To manage billing for your license keys, including payment methods and invoices, visit the billing page. You can generate additional licenses below to increase server capacity or deploy more instances.", "licenseBillingBannerButton": "Go to Billing", "resourcesSearch": "Search resources...", "resourceAdd": "Add Resource", @@ -558,6 +558,10 @@ "licenseBannerDescription": "Unlock enterprise features for your self-hosted Pangolin instance. Purchase a license key to activate premium capabilities, then add it below.", "licenseBannerGetLicense": "Get a License", "licenseBannerViewDocs": "View Documentation", + "licenseUpgradeBannerTitle": "Need More Capacity?", + "licenseUpgradeBannerDescription": "If you need to increase your site or user capacity, you can buy more licenses from the app.pangolin.net portal and add them below to upgrade your instance.", + "licenseUpgradeBannerButton": "Buy More Licenses", + "licenseMultipleKeysDescription": "You have multiple licenses activated on this server. The highest tier is used.", "communityEdition": "Community Edition", "licenseAboutDescription": "This is for business and enterprise users who are using Pangolin in a commercial environment. If you are using Pangolin for personal use, you can ignore this section.", "licenseKeyActivated": "License key activated", diff --git a/src/app/admin/license/page.tsx b/src/app/admin/license/page.tsx index 8ed2d697d..cdc564297 100644 --- a/src/app/admin/license/page.tsx +++ b/src/app/admin/license/page.tsx @@ -49,6 +49,7 @@ import { ExternalLink, Heart, InfoIcon, + ShoppingCart, TicketCheck } from "lucide-react"; import Link from "next/link"; @@ -64,6 +65,8 @@ import { useTranslations } from "next-intl"; const ENTERPRISE_DOCS_URL = "https://docs.pangolin.net/self-host/enterprise-edition"; const ENTERPRISE_PRICING_URL = "https://pangolin.net/pricing#Self-Hosted"; +const LICENSE_PORTAL_URL = + "https://app.pangolin.net/auth/login?internal_redirect=/settings/license?generate"; function getTierLabel( tier: LicenseKeyTier | undefined, @@ -392,6 +395,33 @@ export default function LicensePage() { )} + {licenseStatus?.isLicenseValid && rows.length > 0 && ( + + } + description={t("licenseUpgradeBannerDescription")} + > + + + + + )} + {/* */} {/* */} {/* */} @@ -538,6 +568,11 @@ export default function LicensePage() {
{getTierLabel(licenseStatus?.tier, t)}
+ {rows.length > 1 && ( +
+ {t("licenseMultipleKeysDescription")} +
+ )}
{licenseStatus?.hostId && (