Skip to content

Commit 845dab5

Browse files
andreaskienleenrico-kaack-compCopilotValentinGerlach
authored
fix: Support separate auth tokens for Onboarding API and MCPs (#142)
Co-authored-by: Enrico Kaack <enrico.kaack@sap.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Valentin Gerlach <valentin.gerlach@sap.com>
1 parent 858c820 commit 845dab5

26 files changed

+770
-276
lines changed

.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# OpenID Connect Configuration for Onboarding API
22
OIDC_ISSUER=
33
OIDC_CLIENT_ID=
4+
OIDC_CLIENT_ID_MCP=
45
OIDC_SCOPES=
56
OIDC_REDIRECT_URI=http://localhost:5173
67

@@ -15,6 +16,7 @@ API_BACKEND_URL=
1516
# Replace this value with a strong, randomly generated string (at least 32 characters).
1617
# Example for generation in Node.js: require('crypto').randomBytes(32).toString('hex')
1718
COOKIE_SECRET=
19+
SESSION_SECRET=
1820

1921
FEEDBACK_SLACK_URL=
2022
FEEDBACK_URL_LINK=

package-lock.json

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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
"@fastify/cookie": "^11.0.2",
2525
"@fastify/env": "^5.0.2",
2626
"@fastify/http-proxy": "^11.1.2",
27-
"@fastify/secure-session": "^8.2.0",
2827
"@fastify/sensible": "^6.0.3",
28+
"@fastify/secure-session": "^8.2.0",
29+
"@fastify/session": "^11.1.0",
2930
"@fastify/static": "^8.1.1",
3031
"@fastify/vite": "^8.1.3",
3132
"@hookform/resolvers": "^5.0.0",
@@ -83,4 +84,4 @@
8384
"vite": "^6.3.4",
8485
"vitest": "^3.1.4"
8586
}
86-
}
87+
}

public/locales/en.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,6 @@
252252
},
253253
"learnButton": "Learn how to do this in code"
254254
},
255-
"App": {
256-
"loading": "Loading..."
257-
},
258255
"Providers": {
259256
"headerProviders": "Providers",
260257
"tableHeaderVersion": "Version",

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: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
1-
import fastifyPlugin from "fastify-plugin";
2-
import fastifyEnv from "@fastify/env";
1+
import fastifyPlugin from 'fastify-plugin';
2+
import fastifyEnv from '@fastify/env';
33

44
const schema = {
5-
type: "object",
6-
required: ["OIDC_ISSUER", "OIDC_CLIENT_ID", "OIDC_REDIRECT_URI", "OIDC_SCOPES", "POST_LOGIN_REDIRECT", "COOKIE_SECRET", "API_BACKEND_URL"],
5+
type: 'object',
6+
required: [
7+
'OIDC_ISSUER',
8+
'OIDC_CLIENT_ID',
9+
'OIDC_CLIENT_ID_MCP',
10+
'OIDC_REDIRECT_URI',
11+
'OIDC_SCOPES',
12+
'POST_LOGIN_REDIRECT',
13+
'COOKIE_SECRET',
14+
'SESSION_SECRET',
15+
'API_BACKEND_URL',
16+
],
717
properties: {
818
// Application variables (.env)
9-
OIDC_ISSUER: { type: "string" },
10-
OIDC_CLIENT_ID: { type: "string" },
11-
OIDC_REDIRECT_URI: { type: "string" },
12-
OIDC_SCOPES: { type: "string" },
13-
POST_LOGIN_REDIRECT: { type: "string" },
14-
COOKIE_SECRET: { type: "string" },
15-
API_BACKEND_URL: { type: "string" },
16-
FEEDBACK_SLACK_URL: { type: "string" },
17-
FEEDBACK_URL_LINK: { type: "string" },
19+
OIDC_ISSUER: { type: 'string' },
20+
OIDC_CLIENT_ID: { type: 'string' },
21+
OIDC_CLIENT_ID_MCP: { type: 'string' },
22+
OIDC_REDIRECT_URI: { type: 'string' },
23+
OIDC_SCOPES: { type: 'string' },
24+
POST_LOGIN_REDIRECT: { type: 'string' },
25+
COOKIE_SECRET: { type: 'string' },
26+
SESSION_SECRET: { type: 'string' },
27+
API_BACKEND_URL: { type: 'string' },
28+
FEEDBACK_SLACK_URL: { type: 'string' },
29+
FEEDBACK_URL_LINK: { type: 'string' },
1830

1931
// System variables
20-
NODE_ENV: { type: "string", enum: ["development", "production"] },
32+
NODE_ENV: { type: 'string', enum: ['development', 'production'] },
2133
},
2234
};
2335

0 commit comments

Comments
 (0)