Skip to content

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

requested changes

Daniel Hougaardbe26dc98727b
diff --git a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts
index 5a74236a9d..c39f07b5ca 100644
--- a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts
+++ b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts
@@ -121,7 +121,7 @@ export const dynamicSecretServiceFactory = ({
if (inputs && typeof inputs === "object" && "gatewayId" in inputs && inputs.gatewayId) {
const gatewayId = inputs.gatewayId as string;
- const [gateway] = await gatewayDAL.find({ id: gatewayId });
+ const [gateway] = await gatewayDAL.find({ id: gatewayId, orgId: actorOrgId });
if (!gateway) {
throw new NotFoundError({
@@ -275,7 +275,7 @@ export const dynamicSecretServiceFactory = ({
if (updatedInput && typeof updatedInput === "object" && "gatewayId" in updatedInput && updatedInput?.gatewayId) {
const gatewayId = updatedInput.gatewayId as string;
- const [gateway] = await gatewayDAL.find({ id: gatewayId });
+ const [gateway] = await gatewayDAL.find({ id: gatewayId, orgId: actorOrgId });
if (!gateway) {
throw new NotFoundError({
message: `Gateway with ID ${gatewayId} not found`
diff --git a/backend/src/ee/services/gateway/gateway-dal.ts b/backend/src/ee/services/gateway/gateway-dal.ts
index b51c781ee5..31b4b727b9 100644
--- a/backend/src/ee/services/gateway/gateway-dal.ts
+++ b/backend/src/ee/services/gateway/gateway-dal.ts
@@ -8,11 +8,14 @@ export type TGatewayDALFactory = ReturnType<typeof gatewayDALFactory>;
export const gatewayDALFactory = (db: TDbClient) => {
const orm = ormify(db, TableName.Gateway);
- const find = async (filter: TFindFilter<TGateways>, { offset, limit, sort, tx }: TFindOpt<TGateways> = {}) => {
+ const find = async (
+ filter: TFindFilter<TGateways> & { orgId?: string },
+ { offset, limit, sort, tx }: TFindOpt<TGateways> = {}
+ ) => {
try {
const query = (tx || db)(TableName.Gateway)
// eslint-disable-next-line @typescript-eslint/no-misused-promises
- .where(buildFindFilter(filter, TableName.Gateway))
+ .where(buildFindFilter(filter, TableName.Gateway, ["orgId"]))
.join(TableName.Identity, `${TableName.Identity}.id`, `${TableName.Gateway}.identityId`)
.join(
TableName.IdentityOrgMembership,
@@ -22,6 +25,10 @@ export const gatewayDALFactory = (db: TDbClient) => {
.select(selectAllTableCols(TableName.Gateway))
.select(db.ref("orgId").withSchema(TableName.IdentityOrgMembership).as("identityOrgId"))
.select(db.ref("name").withSchema(TableName.Identity).as("identityName"));
+
+ if (filter.orgId) {
+ void query.where(`${TableName.IdentityOrgMembership}.orgId`, filter.orgId);
+ }
if (limit) void query.limit(limit);
if (offset) void query.offset(offset);
if (sort) {
diff --git a/backend/src/lib/knex/index.ts b/backend/src/lib/knex/index.ts
index b1e0117098..2e17bff206 100644
--- a/backend/src/lib/knex/index.ts
+++ b/backend/src/lib/knex/index.ts
@@ -32,13 +32,13 @@ export const buildFindFilter =
<R extends object = object>(
{ $in, $notNull, $search, $complex, ...filter }: TFindFilter<R>,
tableName?: TableName,
- excludeKeys?: Array<keyof R>
+ excludeKeys?: string[]
) =>
(bd: Knex.QueryBuilder<R, R>) => {
const processedFilter = tableName
? Object.fromEntries(
Object.entries(filter)
- .filter(([key]) => !excludeKeys || !excludeKeys.includes(key as keyof R))
+ .filter(([key]) => !excludeKeys || !excludeKeys.includes(key))
.map(([key, value]) => [`${tableName}.${key}`, value])
)
: filter;
diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
index 32855d3cbc..2da7c38810 100644
--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
@@ -350,7 +350,7 @@ export const identityKubernetesAuthServiceFactory = ({
});
if (gatewayId) {
- const [gateway] = await gatewayDAL.find({ id: gatewayId });
+ const [gateway] = await gatewayDAL.find({ id: gatewayId, orgId: identityMembershipOrg.orgId });
if (!gateway) {
throw new NotFoundError({
message: `Gateway with ID ${gatewayId} not found`
@@ -466,7 +466,7 @@ export const identityKubernetesAuthServiceFactory = ({
});
if (gatewayId) {
- const [gateway] = await gatewayDAL.find({ id: gatewayId });
+ const [gateway] = await gatewayDAL.find({ id: gatewayId, orgId: identityMembershipOrg.orgId });
if (!gateway) {
throw new NotFoundError({
message: `Gateway with ID ${gatewayId} not found`