Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Fix: Remove orgId from service token

Daniel Hougaarde7b11eac2b53
diff --git a/backend/src/server/plugins/auth/inject-identity.ts b/backend/src/server/plugins/auth/inject-identity.ts
index 18d21ebfe0..c323687d8f 100644
--- a/backend/src/server/plugins/auth/inject-identity.ts
+++ b/backend/src/server/plugins/auth/inject-identity.ts
@@ -30,7 +30,6 @@ export type TAuthMode =
serviceToken: TServiceTokens & { createdByEmail: string };
actor: ActorType.SERVICE;
serviceTokenId: string;
- orgId: string;
}
| {
authMode: AuthMode.IDENTITY_ACCESS_TOKEN;
@@ -143,7 +142,6 @@ export const injectIdentity = fp(async (server: FastifyZodProvider) => {
req.auth = {
authMode: AuthMode.SERVICE_TOKEN as const,
serviceToken,
- orgId: serviceToken.orgId,
serviceTokenId: serviceToken.id,
actor
};
diff --git a/backend/src/server/plugins/auth/inject-permission.ts b/backend/src/server/plugins/auth/inject-permission.ts
index bd4ac66db8..8510d88c2e 100644
--- a/backend/src/server/plugins/auth/inject-permission.ts
+++ b/backend/src/server/plugins/auth/inject-permission.ts
@@ -13,7 +13,7 @@ export const injectPermission = fp(async (server) => {
} else if (req.auth.actor === ActorType.IDENTITY) {
req.permission = { type: ActorType.IDENTITY, id: req.auth.identityId, orgId: req.auth.orgId };
} else if (req.auth.actor === ActorType.SERVICE) {
- req.permission = { type: ActorType.SERVICE, id: req.auth.serviceTokenId, orgId: req.auth.orgId };
+ req.permission = { type: ActorType.SERVICE, id: req.auth.serviceTokenId };
} else if (req.auth.actor === ActorType.SCIM_CLIENT) {
req.permission = { type: ActorType.SCIM_CLIENT, id: req.auth.scimTokenId, orgId: req.auth.orgId };
}
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 04fb6d1916..464ea7d0da 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -517,7 +517,6 @@ export const registerRoutes = async (
const serviceTokenService = serviceTokenServiceFactory({
projectEnvDAL,
serviceTokenDAL,
- orgDAL,
userDAL,
permissionService
});
diff --git a/backend/src/services/service-token/service-token-service.ts b/backend/src/services/service-token/service-token-service.ts
index 748fbc95d7..3410aacad3 100644
--- a/backend/src/services/service-token/service-token-service.ts
+++ b/backend/src/services/service-token/service-token-service.ts
@@ -9,7 +9,6 @@ import { getConfig } from "@app/lib/config/env";
import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
import { ActorType } from "../auth/auth-type";
-import { TOrgDALFactory } from "../org/org-dal";
import { TProjectEnvDALFactory } from "../project-env/project-env-dal";
import { TUserDALFactory } from "../user/user-dal";
import { TServiceTokenDALFactory } from "./service-token-dal";
@@ -24,7 +23,6 @@ type TServiceTokenServiceFactoryDep = {
serviceTokenDAL: TServiceTokenDALFactory;
userDAL: TUserDALFactory;
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
- orgDAL: Pick<TOrgDALFactory, "findOrgByProjectId">;
projectEnvDAL: Pick<TProjectEnvDALFactory, "findBySlugs">;
};
@@ -33,7 +31,6 @@ export type TServiceTokenServiceFactory = ReturnType<typeof serviceTokenServiceF
export const serviceTokenServiceFactory = ({
serviceTokenDAL,
userDAL,
- orgDAL,
permissionService,
projectEnvDAL
}: TServiceTokenServiceFactoryDep) => {
@@ -147,9 +144,7 @@ export const serviceTokenServiceFactory = ({
lastUsed: new Date()
});
- const organization = await orgDAL.findOrgByProjectId(serviceToken.projectId);
-
- return { ...serviceToken, lastUsed: updatedToken.lastUsed, orgId: organization.id };
+ return { ...serviceToken, lastUsed: updatedToken.lastUsed };
};
return {