Skip to content

Commit 0335f98

Browse files
Add encryptedSession for separate auth tokens for Onboarding API and MCPs (#156)
Co-authored-by: Copilot <[email protected]>
1 parent da60c07 commit 0335f98

File tree

11 files changed

+392
-58
lines changed

11 files changed

+392
-58
lines changed

.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ API_BACKEND_URL=
1616
# Replace this value with a strong, randomly generated string (at least 32 characters).
1717
# Example for generation in Node.js: require('crypto').randomBytes(32).toString('hex')
1818
COOKIE_SECRET=
19+
SESSION_SECRET=

package-lock.json

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@fastify/env": "^5.0.2",
2626
"@fastify/http-proxy": "^11.1.2",
2727
"@fastify/sensible": "^6.0.3",
28+
"@fastify/secure-session": "^8.2.0",
2829
"@fastify/session": "^11.1.0",
2930
"@fastify/static": "^8.1.1",
3031
"@fastify/vite": "^8.1.3",
@@ -83,4 +84,4 @@
8384
"vite": "^6.3.4",
8485
"vitest": "^3.1.4"
8586
}
86-
}
87+
}

server/app.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import path, { join, dirname } from "node:path";
22
import { fileURLToPath } from "node:url";
33
import AutoLoad from "@fastify/autoload";
44
import envPlugin from "./config/env.js";
5+
import encryptedSession from "./encrypted-session.js";
56

67
export const options = {};
78

89
const __filename = fileURLToPath(import.meta.url);
910
const __dirname = dirname(__filename);
1011

11-
export default async function(fastify, opts) {
12+
export default async function (fastify, opts) {
1213
await fastify.register(envPlugin);
14+
fastify.register(encryptedSession, {
15+
...opts,
16+
});
1317

1418
await fastify.register(AutoLoad, {
1519
dir: join(__dirname, "plugins"),
@@ -20,4 +24,6 @@ export default async function(fastify, opts) {
2024
dir: join(__dirname, "routes"),
2125
options: { ...opts },
2226
});
23-
}
27+
28+
29+
}

server/config/env.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const schema = {
1111
'OIDC_SCOPES',
1212
'POST_LOGIN_REDIRECT',
1313
'COOKIE_SECRET',
14+
'SESSION_SECRET',
1415
'API_BACKEND_URL',
1516
],
1617
properties: {
@@ -22,6 +23,7 @@ const schema = {
2223
OIDC_SCOPES: { type: 'string' },
2324
POST_LOGIN_REDIRECT: { type: 'string' },
2425
COOKIE_SECRET: { type: 'string' },
26+
SESSION_SECRET: { type: 'string' },
2527
API_BACKEND_URL: { type: 'string' },
2628

2729
// System variables

0 commit comments

Comments
 (0)