mirror of
https://github.com/fosrl/pangolin.git
synced 2025-05-13 13:50:40 +01:00
Make sure secure_cookies is true
This commit is contained in:
parent
8fe479f809
commit
f5e894e06a
3 changed files with 48 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@fosrl/pangolin",
|
"name": "@fosrl/pangolin",
|
||||||
"version": "1.0.0-beta.9",
|
"version": "1.0.0-beta.10",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Tunneled Reverse Proxy Management Server with Identity and Access Control and Dashboard UI",
|
"description": "Tunneled Reverse Proxy Management Server with Identity and Access Control and Dashboard UI",
|
||||||
|
|
|
@ -4,7 +4,7 @@ import path from "path";
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
import { versionMigrations } from "@server/db/schema";
|
import { versionMigrations } from "@server/db/schema";
|
||||||
import { desc } from "drizzle-orm";
|
import { desc } from "drizzle-orm";
|
||||||
import { __DIRNAME, APP_PATH } from "@server/lib/consts";
|
import { __DIRNAME } from "@server/lib/consts";
|
||||||
import { loadAppVersion } from "@server/lib/loadAppVersion";
|
import { loadAppVersion } from "@server/lib/loadAppVersion";
|
||||||
import m1 from "./scripts/1.0.0-beta1";
|
import m1 from "./scripts/1.0.0-beta1";
|
||||||
import m2 from "./scripts/1.0.0-beta2";
|
import m2 from "./scripts/1.0.0-beta2";
|
||||||
|
@ -12,6 +12,7 @@ import m3 from "./scripts/1.0.0-beta3";
|
||||||
import m4 from "./scripts/1.0.0-beta5";
|
import m4 from "./scripts/1.0.0-beta5";
|
||||||
import m5 from "./scripts/1.0.0-beta6";
|
import m5 from "./scripts/1.0.0-beta6";
|
||||||
import m6 from "./scripts/1.0.0-beta9";
|
import m6 from "./scripts/1.0.0-beta9";
|
||||||
|
import m7 from "./scripts/1.0.0-beta10";
|
||||||
|
|
||||||
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
|
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
|
||||||
// EXCEPT FOR THE DATABASE AND THE SCHEMA
|
// EXCEPT FOR THE DATABASE AND THE SCHEMA
|
||||||
|
@ -23,7 +24,8 @@ const migrations = [
|
||||||
{ version: "1.0.0-beta.3", run: m3 },
|
{ version: "1.0.0-beta.3", run: m3 },
|
||||||
{ version: "1.0.0-beta.5", run: m4 },
|
{ version: "1.0.0-beta.5", run: m4 },
|
||||||
{ version: "1.0.0-beta.6", run: m5 },
|
{ version: "1.0.0-beta.6", run: m5 },
|
||||||
{ version: "1.0.0-beta.9", run: m6 }
|
{ version: "1.0.0-beta.9", run: m6 },
|
||||||
|
{ version: "1.0.0-beta.10", run: m7 }
|
||||||
// Add new migrations here as they are created
|
// Add new migrations here as they are created
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|
43
server/setup/scripts/1.0.0-beta10.ts
Normal file
43
server/setup/scripts/1.0.0-beta10.ts
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import { configFilePath1, configFilePath2 } from "@server/lib/consts";
|
||||||
|
import fs from "fs";
|
||||||
|
import yaml from "js-yaml";
|
||||||
|
|
||||||
|
export default async function migration() {
|
||||||
|
console.log("Running setup script 1.0.0-beta.9...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Determine which config file exists
|
||||||
|
const filePaths = [configFilePath1, configFilePath2];
|
||||||
|
let filePath = "";
|
||||||
|
for (const path of filePaths) {
|
||||||
|
if (fs.existsSync(path)) {
|
||||||
|
filePath = path;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filePath) {
|
||||||
|
throw new Error(
|
||||||
|
`No config file found (expected config.yml or config.yaml).`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read and parse the YAML file
|
||||||
|
let rawConfig: any;
|
||||||
|
const fileContents = fs.readFileSync(filePath, "utf8");
|
||||||
|
rawConfig = yaml.load(fileContents);
|
||||||
|
|
||||||
|
rawConfig.server.secure_cookies = true;
|
||||||
|
|
||||||
|
// Write the updated YAML back to the file
|
||||||
|
const updatedYaml = yaml.dump(rawConfig);
|
||||||
|
fs.writeFileSync(filePath, updatedYaml, "utf8");
|
||||||
|
} catch (e) {
|
||||||
|
console.log(
|
||||||
|
`Failed to set secure_cookies to true in config. Please set it manually. https://docs.fossorial.io/Pangolin/Configuration/config`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Done.");
|
||||||
|
}
|
Loading…
Reference in a new issue