From 1434465087d809cc2780fe02e741e8ae50440915 Mon Sep 17 00:00:00 2001 From: Cezar Dascal Date: Mon, 15 Dec 2025 10:28:06 +0200 Subject: [PATCH 1/2] Add projectSettings to Principal Type --- .../authentication/context/create-project-auth-context.ts | 1 + .../app/core/security/authn/anonymous-authn-handler.ts | 1 + packages/server/api/test/helpers/auth.ts | 8 ++------ .../server/api/test/unit/ai/chat-request-router.test.ts | 1 + packages/shared/src/lib/authentication/model/principal.ts | 1 + 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/server/api/src/app/authentication/context/create-project-auth-context.ts b/packages/server/api/src/app/authentication/context/create-project-auth-context.ts index 9d045341bf..79ecac7e92 100644 --- a/packages/server/api/src/app/authentication/context/create-project-auth-context.ts +++ b/packages/server/api/src/app/authentication/context/create-project-auth-context.ts @@ -48,6 +48,7 @@ export async function getProjectAndToken( organization: { id: organization.id, }, + projectSettings: {}, }, expiresInSeconds, ); diff --git a/packages/server/api/src/app/core/security/authn/anonymous-authn-handler.ts b/packages/server/api/src/app/core/security/authn/anonymous-authn-handler.ts index fd7420510a..41eb1b7dcd 100644 --- a/packages/server/api/src/app/core/security/authn/anonymous-authn-handler.ts +++ b/packages/server/api/src/app/core/security/authn/anonymous-authn-handler.ts @@ -18,6 +18,7 @@ export class AnonymousAuthnHandler extends BaseSecurityHandler { organization: { id: `ANONYMOUS_${openOpsId()}`, }, + projectSettings: {}, }; } diff --git a/packages/server/api/test/helpers/auth.ts b/packages/server/api/test/helpers/auth.ts index 7f8332de74..a29f7fa749 100644 --- a/packages/server/api/test/helpers/auth.ts +++ b/packages/server/api/test/helpers/auth.ts @@ -1,10 +1,5 @@ import { faker } from '@faker-js/faker'; -import { - openOpsId, - Principal, - PrincipalType, - ProjectMemberRole, -} from '@openops/shared'; +import { openOpsId, Principal, PrincipalType } from '@openops/shared'; import jwt, { Algorithm, JwtPayload, SignOptions } from 'jsonwebtoken'; const generateToken = ({ @@ -34,6 +29,7 @@ export const generateMockToken = async ( organization: principal?.organization ?? { id: openOpsId(), }, + projectSettings: principal?.projectSettings ?? {}, }; return generateToken({ diff --git a/packages/server/api/test/unit/ai/chat-request-router.test.ts b/packages/server/api/test/unit/ai/chat-request-router.test.ts index bf510a1128..7c8df05a3e 100644 --- a/packages/server/api/test/unit/ai/chat-request-router.test.ts +++ b/packages/server/api/test/unit/ai/chat-request-router.test.ts @@ -78,6 +78,7 @@ describe('Chat Request Router', () => { organization: { id: 'test-org-id', }, + projectSettings: {}, }; const mockNewMessage: CoreMessage = { diff --git a/packages/shared/src/lib/authentication/model/principal.ts b/packages/shared/src/lib/authentication/model/principal.ts index 3fc7d3f8df..c778f14334 100644 --- a/packages/shared/src/lib/authentication/model/principal.ts +++ b/packages/shared/src/lib/authentication/model/principal.ts @@ -11,6 +11,7 @@ export type Principal = { organization: { id: OpenOpsId; }; + projectSettings: Record; }; export type WorkerPrincipal = { From ca7abe15725e6f9ff9385412706b0e031af5adc7 Mon Sep 17 00:00:00 2001 From: Cezar Dascal Date: Mon, 15 Dec 2025 11:49:56 +0200 Subject: [PATCH 2/2] Fix test --- .../server/api/test/integration/ce/authentication/signup.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/api/test/integration/ce/authentication/signup.test.ts b/packages/server/api/test/integration/ce/authentication/signup.test.ts index a9cad1af52..d652b801f3 100644 --- a/packages/server/api/test/integration/ce/authentication/signup.test.ts +++ b/packages/server/api/test/integration/ce/authentication/signup.test.ts @@ -90,6 +90,7 @@ beforeAll(async () => { organization: { id: mockOrganization.id, }, + projectSettings: {}, }); });